Browse Source

Change zyn master switch to happen during audio output

tags/1.9.7
falkTX 9 years ago
parent
commit
bc57951541
5 changed files with 33 additions and 29 deletions
  1. +15
    -12
      source/native-plugins/zynaddsubfx-synth.cpp
  2. +11
    -0
      source/native-plugins/zynaddsubfx/Misc/Master.cpp
  3. +7
    -0
      source/native-plugins/zynaddsubfx/Misc/Master.h
  4. +0
    -15
      source/native-plugins/zynaddsubfx/Misc/MiddleWare.cpp
  5. +0
    -2
      source/native-plugins/zynaddsubfx/Misc/MiddleWare.h

+ 15
- 12
source/native-plugins/zynaddsubfx-synth.cpp View File

@@ -676,7 +676,6 @@ protected:
fMiddleWare->updateResources(fMaster);

_setMasterParameters();

}

// -------------------------------------------------------------------
@@ -752,11 +751,9 @@ private:
void _initMaster()
{
fMiddleWare = new MiddleWare(fSynth);
fMaster = fMiddleWare->spawnMaster();

fMiddleWare->setIdleCallback(_idleCallback, this);
fMiddleWare->setUiCallback(__uiCallback, this);
fMiddleWare->setMasterChangedCallback(_masterChangedCallback, this);
fMiddleWare->setIdleCallback(_idleCallback, this);
_masterChangedCallback(fMiddleWare->spawnMaster());
}

void _setMasterParameters()
@@ -803,6 +800,17 @@ private:
fMiddleWare = nullptr;
}

void _masterChangedCallback(Master* m)
{
fMaster = m;
fMaster->setMasterChangedCallback(__masterChangedCallback, this);
}

static void __masterChangedCallback(void* ptr, Master* m)
{
((ZynAddSubFxPlugin*)ptr)->_masterChangedCallback(m);
}

void _uiCallback(const char* const msg)
{
if (std::strncmp(msg, "/part", 5) != 0)
@@ -853,19 +861,14 @@ private:
}
}

static void _idleCallback(void* ptr)
{
((ZynAddSubFxPlugin*)ptr)->hostGiveIdle();
}

static void __uiCallback(void* ptr, const char* msg)
{
((ZynAddSubFxPlugin*)ptr)->_uiCallback(msg);
}

static void _masterChangedCallback(void* ptr, Master* m)
static void _idleCallback(void* ptr)
{
((ZynAddSubFxPlugin*)ptr)->fMaster = m;
((ZynAddSubFxPlugin*)ptr)->hostGiveIdle();
}

// -------------------------------------------------------------------


+ 11
- 0
source/native-plugins/zynaddsubfx/Misc/Master.cpp View File

@@ -332,6 +332,9 @@ Master::Master(const SYNTH_T &synth_)
{
fprintf(stderr, "MIDI- got an error '%s' -- '%s'\n",a,b);
};

mastercb = 0;
mastercb_ptr = 0;
}

void Master::applyOscEvent(const char *msg)
@@ -535,6 +538,12 @@ void Master::partonoff(int npart, int what)
}
}

void Master::setMasterChangedCallback(void(*cb)(void*,Master*), void *ptr)
{
mastercb = cb;
mastercb_ptr = ptr;
}

#if 0
template <class T>
struct def_skip
@@ -617,6 +626,8 @@ void Master::AudioOut(float *outl, float *outr)
Master *new_master = *(Master**)rtosc_argument(msg, 0).b.data;
new_master->AudioOut(outl, outr);
Nio::masterSwap(new_master);
if (mastercb)
mastercb(mastercb_ptr, new_master);
bToU->write("/free", "sb", "Master", sizeof(Master*), &this_master);
return;
}


+ 7
- 0
source/native-plugins/zynaddsubfx/Misc/Master.h View File

@@ -108,6 +108,9 @@ class Master

void partonoff(int npart, int what);

//Set callback to run when master changes
void setMasterChangedCallback(void(*cb)(void*,Master*),void *ptr);

/**parts \todo see if this can be made to be dynamic*/
class Part * part[NUM_MIDI_PARTS];

@@ -178,6 +181,10 @@ class Master
float *bufr;
off_t off;
size_t smps;

//Callback When Master changes
void(*mastercb)(void*,Master*);
void* mastercb_ptr;
};

#endif

+ 0
- 15
source/native-plugins/zynaddsubfx/Misc/MiddleWare.cpp View File

@@ -686,9 +686,6 @@ public:

master = m;

if (mastercb)
mastercb(mastercb_ptr, m);

//Give it to the backend and wait for the old part to return for
//deallocation
uToB->write("/load-master", "b", sizeof(Master*), &m);
@@ -815,10 +812,6 @@ public:
void(*idle)(void*);
void* idle_ptr;

//Callback When Master changes
void(*mastercb)(void*,Master*);
void* mastercb_ptr;

//General UI callback
cb_t cb;
//UI handle
@@ -862,8 +855,6 @@ MiddleWareImpl::MiddleWareImpl(MiddleWare *mw, SYNTH_T synth_, int prefered_port
cb = [](void*, const char*){};
idle = 0;
idle_ptr = 0;
mastercb = 0;
mastercb_ptr = 0;

the_bToU = bToU;
master = new Master(synth);
@@ -1312,12 +1303,6 @@ void MiddleWare::setIdleCallback(void(*cb)(void*), void *ptr)
impl->idle_ptr = ptr;
}

void MiddleWare::setMasterChangedCallback(void(*cb)(void*,Master*), void *ptr)
{
impl->mastercb = cb;
impl->mastercb_ptr = ptr;
}

void MiddleWare::transmitMsg(const char *msg)
{
impl->handleMsg(msg);


+ 0
- 2
source/native-plugins/zynaddsubfx/Misc/MiddleWare.h View File

@@ -19,8 +19,6 @@ class MiddleWare
void setUiCallback(void(*cb)(void*,const char *),void *ui);
//Set callback to run while busy
void setIdleCallback(void(*cb)(void*),void *ptr);
//Set callback to run when master changed
void setMasterChangedCallback(void(*cb)(void*,Master*),void *ptr);
//Handle events
void tick(void);
//Do A Readonly Operation (For Parameter Copy)


Loading…
Cancel
Save