Browse Source

Proper handling of VST param changes

tags/1.9.4
falkTX 10 years ago
parent
commit
372d5bd419
2 changed files with 52 additions and 29 deletions
  1. +3
    -0
      source/backend/plugin/Lv2Plugin.cpp
  2. +49
    -29
      source/backend/plugin/VstPlugin.cpp

+ 3
- 0
source/backend/plugin/Lv2Plugin.cpp View File

@@ -1158,6 +1158,9 @@ public:
if (fUi.window == nullptr) if (fUi.window == nullptr)
return pData->engine->callback(ENGINE_CALLBACK_UI_STATE_CHANGED, pData->id, -1, 0, 0.0f, msg); return pData->engine->callback(ENGINE_CALLBACK_UI_STATE_CHANGED, pData->id, -1, 0, 0.0f, msg);


if (uintptr_t winId = pData->engine->getOptions().frontendWinId)
fUi.window->setTransientWinId(winId);

fUi.window->setTitle(fUi.title); fUi.window->setTitle(fUi.title);


fFeatures[kFeatureIdUiParent]->data = fUi.window->getPtr(); fFeatures[kFeatureIdUiParent]->data = fUi.window->getPtr();


+ 49
- 29
source/backend/plugin/VstPlugin.cpp View File

@@ -32,6 +32,8 @@


#include <QtCore/QFile> #include <QtCore/QFile>


#include <pthread.h>

#undef VST_FORCE_DEPRECATED #undef VST_FORCE_DEPRECATED
#define VST_FORCE_DEPRECATED 0 #define VST_FORCE_DEPRECATED 0


@@ -60,10 +62,10 @@ public:
: CarlaPlugin(engine, id), : CarlaPlugin(engine, id),
fUnique1(1), fUnique1(1),
fEffect(nullptr), fEffect(nullptr),
fLastChunk(nullptr),
fMidiEventCount(0), fMidiEventCount(0),
fIsProcessing(false),
fNeedIdle(false), fNeedIdle(false),
fLastChunk(nullptr),
fIsProcessing(false),
fUnique2(2) fUnique2(2)
{ {
carla_debug("VstPlugin::VstPlugin(%p, %i)", engine, id); carla_debug("VstPlugin::VstPlugin(%p, %i)", engine, id);
@@ -76,6 +78,13 @@ public:


pData->osc.thread.setMode(CarlaPluginThread::PLUGIN_THREAD_VST_GUI); pData->osc.thread.setMode(CarlaPluginThread::PLUGIN_THREAD_VST_GUI);


#ifdef CARLA_OS_WIN
fProcThread.p = nullptr;
fProcThread.x = 0;
#else
fProcThread = 0;
#endif

// make plugin valid // make plugin valid
srand(id); srand(id);
fUnique1 = fUnique2 = rand(); fUnique1 = fUnique2 = rand();
@@ -440,6 +449,9 @@ public:
if (fUi.window == nullptr) if (fUi.window == nullptr)
return pData->engine->callback(ENGINE_CALLBACK_UI_STATE_CHANGED, pData->id, -1, 0, 0.0f, msg); return pData->engine->callback(ENGINE_CALLBACK_UI_STATE_CHANGED, pData->id, -1, 0, 0.0f, msg);


if (uintptr_t winId = pData->engine->getOptions().frontendWinId)
fUi.window->setTransientWinId(winId);

QString guiTitle(QString("%1 (GUI)").arg(pData->name)); QString guiTitle(QString("%1 (GUI)").arg(pData->name));
fUi.window->setTitle(guiTitle.toUtf8().constData()); fUi.window->setTitle(guiTitle.toUtf8().constData());
} }
@@ -1000,6 +1012,8 @@ public:


void process(float** const inBuffer, float** const outBuffer, const uint32_t frames) override void process(float** const inBuffer, float** const outBuffer, const uint32_t frames) override
{ {
fProcThread = pthread_self();

// -------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------
// Check if active // Check if active


@@ -1739,8 +1753,7 @@ protected:


switch (opcode) switch (opcode)
{ {
#if 0
case audioMasterAutomate:
case audioMasterAutomate: {
if (! pData->enabled) if (! pData->enabled)
break; break;


@@ -1750,32 +1763,31 @@ protected:
if (index < 0 || index >= static_cast<int32_t>(pData->param.count)) if (index < 0 || index >= static_cast<int32_t>(pData->param.count))
break; break;


if (fGui.isVisible && ! fIsProcessing)
const uint32_t uindex(static_cast<uint32_t>(index));
const float fixedValue(pData->param.getFixedValue(uindex, opt));

// Called from plugin processing, nasty!
if (pthread_equal(pthread_self(), fProcThread))
{ {
// Called from GUI
setParameterValue(index, opt, false, true, true);
CARLA_SAFE_ASSERT(fIsProcessing);

pData->postponeRtEvent(kPluginPostRtEventParameterChange, index, 0, fixedValue);
} }
else if (fIsProcessing)
// Called from UI
else if (fUi.isVisible)
{ {
// Called from engine
const float fixedValue(pData->param.getFixedValue(index, opt));

if (pData->engine->isOffline())
{
CarlaPlugin::setParameterValue(index, fixedValue, true, true, true);
}
else
{
CarlaPlugin::setParameterValue(index, fixedValue, false, false, false);
pData->postponeRtEvent(kPluginPostRtEventParameterChange, index, 0, fixedValue);
}
CarlaPlugin::setParameterValue(uindex, fixedValue, false, true, true);
} }
// Unknown
else else
{ {
carla_stdout("audioMasterAutomate called from unknown source"); carla_stdout("audioMasterAutomate called from unknown source");

setParameterValue(uindex, fixedValue, true, true, true);
//pData->postponeRtEvent(kPluginPostRtEventParameterChange, index, 0, fixedValue);
} }
break; break;
#endif
}


case audioMasterCurrentId: case audioMasterCurrentId:
// TODO // TODO
@@ -1955,10 +1967,15 @@ protected:
#endif #endif


case audioMasterGetCurrentProcessLevel: case audioMasterGetCurrentProcessLevel:
if (pData->engine->isOffline())
ret = kVstProcessLevelOffline;
else if (fIsProcessing)
ret = kVstProcessLevelRealtime;
if (pthread_equal(pthread_self(), fProcThread))
{
CARLA_SAFE_ASSERT(fIsProcessing);

if (pData->engine->isOffline())
ret = kVstProcessLevelOffline;
else
ret = kVstProcessLevelRealtime;
}
else else
ret = kVstProcessLevelUser; ret = kVstProcessLevelUser;
break; break;
@@ -2277,13 +2294,19 @@ public:


private: private:
int fUnique1; int fUnique1;

AEffect* fEffect; AEffect* fEffect;


void* fLastChunk;
uint32_t fMidiEventCount; uint32_t fMidiEventCount;
VstMidiEvent fMidiEvents[kPluginMaxMidiEvents*2]; VstMidiEvent fMidiEvents[kPluginMaxMidiEvents*2];
VstTimeInfo_R fTimeInfo; VstTimeInfo_R fTimeInfo;


bool fNeedIdle;
void* fLastChunk;

volatile bool fIsProcessing;
volatile pthread_t fProcThread;

struct FixedVstEvents { struct FixedVstEvents {
int32_t numEvents; int32_t numEvents;
intptr_t reserved; intptr_t reserved;
@@ -2319,9 +2342,6 @@ private:
} }
} fUi; } fUi;


volatile bool fIsProcessing;

bool fNeedIdle;
int fUnique2; int fUnique2;


static VstPlugin* sLastVstPlugin; static VstPlugin* sLastVstPlugin;


Loading…
Cancel
Save