Skip to content

Commit

Permalink
ZynAddSubFX: imported current head
Browse files Browse the repository at this point in the history
Imported current head of LMMS-specific ZynAddSubFX source code.

The current code is based on version 2.4.4 of ZynAddSubFX.

HEAD: 9a993c4936ce987bb30f93eee2a573466ece3712
  • Loading branch information
tobydox committed Jul 16, 2014
1 parent 330ff65 commit a12774f
Show file tree
Hide file tree
Showing 41 changed files with 597 additions and 261 deletions.
3 changes: 2 additions & 1 deletion plugins/zynaddsubfx/zynaddsubfx/AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ Contributors:
Jonathan Liles (NSM & NTK support)
Johannes Lorenz (Effect Documentation)
Ilario Glasgo (Italian Doc Translation)
Christopher Oliver (Unison + presets fix, mousewheel support)
Christopher Oliver (Unison + presets fix, mousewheel support,
SUBnote overtones, unison enhancements, ...)
Filipe Coelho (Globals Cleanup)
Andre Sklenar (UI Pixmaps)

2 changes: 1 addition & 1 deletion plugins/zynaddsubfx/zynaddsubfx/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 2.8)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/")
project(zynaddsubfx)
set(VERSION "2.4.3")
set(VERSION "2.4.4")

enable_testing()
include(CTestConfig.cmake)
Expand Down
2 changes: 2 additions & 0 deletions plugins/zynaddsubfx/zynaddsubfx/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -1034,3 +1034,5 @@

31 Mar 2012 (Olaf Schulz)
- Added Midi aftertouch support

Please See git log For future information
17 changes: 17 additions & 0 deletions plugins/zynaddsubfx/zynaddsubfx/HISTORY.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
2.4.4 (28 Jun 2014)
- Add UI Mousewheel Support
- Add Spectral Adjust Parameter Rescaling
- Add Subnote filter smoothing
- Add Unison derandomization options
- Add NSM import/export
- Add NTK UI compatiability
- (re)Add OSX Support
- Enhance performance of ADnote and SUBnote
- Enhance Installer
- Fix JACK2 specific segfault
- Fix possible DSSI specific segfaults
- Fix Unison Regressions
- Documentation additions
- Misc bug fixes


2.4.3 (15 Jun 2012)
- Non-session manager support
- Midi aftertouch support
Expand Down
2 changes: 1 addition & 1 deletion plugins/zynaddsubfx/zynaddsubfx/README.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ZynAddSubFX
-----------
It is a realtime software synthesizer for Linux and Windows with many features. Please see the docs for details.
Copyright (c) 2002-2011 Nasca Octavian Paul and others contributors
Copyright (c) 2002-2014 Nasca Octavian Paul and others contributors
e-mail: zynaddsubfx AT yahoo D0T com
ZynAddSubFX is free program and is distributed WITH NO WARRANTY. It is licensed under GNU General Public License version 2 (and only version 2) - see the file COPYING.

Expand Down
22 changes: 0 additions & 22 deletions plugins/zynaddsubfx/zynaddsubfx/ZynAddSubFX.lsm

This file was deleted.

2 changes: 1 addition & 1 deletion plugins/zynaddsubfx/zynaddsubfx/src/Misc/XMLwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ XMLwrapper::XMLwrapper()
{
version.Major = 2;
version.Minor = 4;
version.Revision = 3;
version.Revision = 4;

minimal = true;

Expand Down
12 changes: 5 additions & 7 deletions plugins/zynaddsubfx/zynaddsubfx/src/Nio/InMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,31 +44,30 @@ InMgr::InMgr()
:queue(100), master(Master::getInstance())
{
current = NULL;
sem_init(&work, PTHREAD_PROCESS_PRIVATE, 0);
work.init(PTHREAD_PROCESS_PRIVATE, 0);
}

InMgr::~InMgr()
{
//lets stop the consumer thread
sem_destroy(&work);
}

void InMgr::putEvent(MidiEvent ev)
{
if(queue.push(ev)) //check for error
cerr << "ERROR: Midi Ringbuffer is FULL" << endl;
else
sem_post(&work);
work.post();
}

void InMgr::flush(unsigned frameStart, unsigned frameStop)
{
MidiEvent ev;
while(!sem_trywait(&work)) {
while(!work.trywait()) {
queue.peak(ev);
if(ev.time < (int)frameStart || ev.time > (int)frameStop) {
//Back out of transaction
sem_post(&work);
work.post();
//printf("%d vs [%d..%d]\n",ev.time, frameStart, frameStop);
break;
}
Expand Down Expand Up @@ -102,8 +101,7 @@ void InMgr::flush(unsigned frameStart, unsigned frameStop)

bool InMgr::empty(void) const
{
int semvalue = 0;
sem_getvalue(&work, &semvalue);
int semvalue = work.getvalue();
return semvalue <= 0;
}

Expand Down
3 changes: 2 additions & 1 deletion plugins/zynaddsubfx/zynaddsubfx/src/Nio/InMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define INMGR_H

#include <string>
#include "ZynSema.h"
#include "SafeQueue.h"

enum midi_type {
Expand Down Expand Up @@ -44,7 +45,7 @@ class InMgr
InMgr();
class MidiIn *getIn(std::string name);
SafeQueue<MidiEvent> queue;
mutable sem_t work;
mutable ZynSema work;
class MidiIn * current;

/**the link to the rest of zyn*/
Expand Down
26 changes: 10 additions & 16 deletions plugins/zynaddsubfx/zynaddsubfx/src/Nio/SafeQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ template<class T>
SafeQueue<T>::SafeQueue(size_t maxlen)
:writePtr(0), readPtr(0), bufSize(maxlen)
{
sem_init(&w_space, PTHREAD_PROCESS_PRIVATE, maxlen - 1);
sem_init(&r_space, PTHREAD_PROCESS_PRIVATE, 0);
w_space.init(PTHREAD_PROCESS_PRIVATE, maxlen - 1);
r_space.init(PTHREAD_PROCESS_PRIVATE, 0);
buffer = new T[maxlen];
}

template<class T>
SafeQueue<T>::~SafeQueue()
{
sem_destroy(&w_space);
sem_destroy(&r_space);
delete [] buffer;
}

Expand All @@ -25,17 +23,13 @@ unsigned int SafeQueue<T>::size() const
template<class T>
unsigned int SafeQueue<T>::rSpace() const
{
int space = 0;
sem_getvalue(&r_space, &space);
return space;
return r_space.getvalue();
}

template<class T>
unsigned int SafeQueue<T>::wSpace() const
{
int space = 0;
sem_getvalue(&w_space, &space);
return space;
return w_space.getvalue();
}

template<class T>
Expand All @@ -50,8 +44,8 @@ int SafeQueue<T>::push(const T &in)
writePtr = w;

//adjust ranges
sem_wait(&w_space); //guaranteed not to wait
sem_post(&r_space);
w_space.wait(); //guaranteed not to wait
r_space.post();
return 0;
}

Expand Down Expand Up @@ -80,16 +74,16 @@ int SafeQueue<T>::pop(T &out)
readPtr = r;

//adjust ranges
sem_wait(&r_space); //guaranteed not to wait
sem_post(&w_space);
r_space.wait(); //guaranteed not to wait
w_space.post();
return 0;
}

template<class T>
void SafeQueue<T>::clear()
{
//thread unsafe
while(!sem_trywait(&r_space))
sem_post(&w_space);
while(!r_space.trywait())
w_space.post();
readPtr = writePtr;
}
5 changes: 3 additions & 2 deletions plugins/zynaddsubfx/zynaddsubfx/src/Nio/SafeQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#ifndef SAFEQUEUE_H
#define SAFEQUEUE_H
#include <cstdlib>
#include "ZynSema.h"
#include <pthread.h>
#include <semaphore.h>

Expand Down Expand Up @@ -32,9 +33,9 @@ class SafeQueue
unsigned int rSpace() const;

//write space
mutable sem_t w_space;
mutable ZynSema w_space;
//read space
mutable sem_t r_space;
mutable ZynSema r_space;

//next writing spot
size_t writePtr;
Expand Down
9 changes: 4 additions & 5 deletions plugins/zynaddsubfx/zynaddsubfx/src/Nio/WavEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@ using namespace std;
WavEngine::WavEngine()
:AudioOut(), file(NULL), buffer(synth->samplerate * 4), pThread(NULL)
{
sem_init(&work, PTHREAD_PROCESS_PRIVATE, 0);
work.init(PTHREAD_PROCESS_PRIVATE, 0);
}

WavEngine::~WavEngine()
{
Stop();
sem_destroy(&work);
destroyFile();
}

Expand Down Expand Up @@ -65,7 +64,7 @@ void WavEngine::Stop()
pthread_t *tmp = pThread;
pThread = NULL;

sem_post(&work);
work.post();
pthread_join(*tmp, NULL);
delete pThread;
}
Expand All @@ -81,7 +80,7 @@ void WavEngine::push(Stereo<float *> smps, size_t len)
buffer.push(*smps.l++);
buffer.push(*smps.r++);
}
sem_post(&work);
work.post();
}

void WavEngine::newFile(WavFile *_file)
Expand Down Expand Up @@ -113,7 +112,7 @@ void *WavEngine::AudioThread()
{
short *recordbuf_16bit = new short[2 * synth->buffersize];

while(!sem_wait(&work) && pThread) {
while(!work.wait() && pThread) {
for(int i = 0; i < synth->buffersize; ++i) {
float left = 0.0f, right = 0.0f;
buffer.pop(left);
Expand Down
4 changes: 2 additions & 2 deletions plugins/zynaddsubfx/zynaddsubfx/src/Nio/WavEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "AudioOut.h"
#include <string>
#include <pthread.h>
#include <semaphore.h>
#include "ZynSema.h"
#include "SafeQueue.h"

class WavFile;
Expand Down Expand Up @@ -53,7 +53,7 @@ class WavEngine:public AudioOut

private:
WavFile *file;
sem_t work;
ZynSema work;
SafeQueue<float> buffer;

pthread_t *pThread;
Expand Down
Loading

0 comments on commit a12774f

Please sign in to comment.