Browse Source

Update parameter outputs in JACK targets

gh-pages
falkTX 10 years ago
parent
commit
cc30a221c7
2 changed files with 53 additions and 12 deletions
  1. +43
    -2
      distrho/src/DistrhoPluginJack.cpp
  2. +10
    -10
      distrho/src/DistrhoUIInternal.hpp

+ 43
- 2
distrho/src/DistrhoPluginJack.cpp View File

@@ -36,7 +36,7 @@ static const setStateFunc setStateCallback = nullptr;

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

class PluginJack
class PluginJack : public IdleCallback
{
public:
PluginJack(jack_client_t* const client)
@@ -67,6 +67,23 @@ public:
fPortMidiIn = jack_port_register(fClient, "midi-in", JACK_DEFAULT_MIDI_TYPE, JackPortIsInput, 0);
#endif

if (const uint32_t count = fPlugin.getParameterCount())
{
fLastOutputValues = new float[count];

for (uint32_t i=0; i < count; ++i)
{
if (fPlugin.isParameterOutput(i))
fLastOutputValues[i] = fPlugin.getParameterValue(i);
else
fLastOutputValues[i] = 0.0f;
}
}
else
{
fLastOutputValues = nullptr;
}

jack_set_buffer_size_callback(fClient, jackBufferSizeCallback, this);
jack_set_sample_rate_callback(fClient, jackSampleRateCallback, this);
jack_set_process_callback(fClient, jackProcessCallback, this);
@@ -79,7 +96,7 @@ public:
else
fUI.setTitle(DISTRHO_PLUGIN_NAME);

fUI.exec();
fUI.exec(this);
}

~PluginJack()
@@ -116,6 +133,27 @@ public:
// -------------------------------------------------------------------

protected:
void idleCallback() override
{
float value;

for (uint32_t i=0, count=fPlugin.getParameterCount(); i < count; ++i)
{
if (! fPlugin.isParameterOutput(i))
continue;

value = fPlugin.getParameterValue(i);

if (fLastOutputValues[i] == value)
continue;

fLastOutputValues[i] = value;
fUI.parameterChanged(i, value);
}

fUI.exec_idle();
}

void jackBufferSize(const jack_nframes_t nframes)
{
fPlugin.setBufferSize(nframes, true);
@@ -266,6 +304,9 @@ private:
TimePos fTimePos;
#endif

// Temporary data
float* fLastOutputValues;

// -------------------------------------------------------------------
// Callbacks



+ 10
- 10
distrho/src/DistrhoUIInternal.hpp View File

@@ -175,7 +175,7 @@ private:
// -----------------------------------------------------------------------
// UI exporter class

class UIExporter : public IdleCallback
class UIExporter
{
public:
UIExporter(void* const ptr, const intptr_t winId,
@@ -267,15 +267,22 @@ public:

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

void exec()
void exec(IdleCallback* const cb)
{
DISTRHO_SAFE_ASSERT_RETURN(cb != nullptr,);
DISTRHO_SAFE_ASSERT_RETURN(fUi != nullptr,);

glWindow.addIdleCallback(this);
glWindow.addIdleCallback(cb);
glWindow.setVisible(true);
glApp.exec();
}

void exec_idle()
{
if (glWindow.isReady())
fUi->d_uiIdle();
}

bool idle()
{
DISTRHO_SAFE_ASSERT_RETURN(fUi != nullptr, false);
@@ -321,13 +328,6 @@ public:
return ! glApp.isQuiting();
}

protected:
void idleCallback() override
{
if (glWindow.isReady())
fUi->d_uiIdle();
}

private:
// -------------------------------------------------------------------
// DGL Application and Window for this widget


Loading…
Cancel
Save