Browse Source

Carla: Proper isProcessing value

tags/v0.9.0
falkTX 12 years ago
parent
commit
b3d7f1bbae
4 changed files with 40 additions and 35 deletions
  1. +0
    -4
      c++/carla-backend/carla_engine.h
  2. +0
    -11
      c++/carla-backend/carla_engine_jack.cpp
  3. +39
    -19
      c++/carla-backend/vst.cpp
  4. +1
    -1
      c++/carla-bridge/Makefile

+ 0
- 4
c++/carla-backend/carla_engine.h View File

@@ -198,7 +198,6 @@ public:


virtual bool init(const char* const clientName); virtual bool init(const char* const clientName);
virtual bool close(); virtual bool close();
virtual bool isOnAudioThread() = 0;
virtual bool isOffline() = 0; virtual bool isOffline() = 0;
virtual bool isRunning() = 0; virtual bool isRunning() = 0;


@@ -503,7 +502,6 @@ private:
jack_transport_state_t state; jack_transport_state_t state;
jack_position_t pos; jack_position_t pos;
bool freewheel; bool freewheel;
QThread* procThread;


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


@@ -534,7 +532,6 @@ public:
bool init(const char* const clientName); bool init(const char* const clientName);
bool close(); bool close();


bool isOnAudioThread();
bool isOffline(); bool isOffline();
bool isRunning(); bool isRunning();


@@ -546,7 +543,6 @@ public:


private: private:
RtAudio adac; RtAudio adac;
QThread* procThread;
}; };
#endif #endif




+ 0
- 11
c++/carla-backend/carla_engine_jack.cpp View File

@@ -89,7 +89,6 @@ CarlaEngineJack::CarlaEngineJack()
client = nullptr; client = nullptr;
state = JackTransportStopped; state = JackTransportStopped;
freewheel = false; freewheel = false;
procThread = nullptr;


memset(&pos, 0, sizeof(jack_position_t)); memset(&pos, 0, sizeof(jack_position_t));


@@ -113,7 +112,6 @@ bool CarlaEngineJack::init(const char* const clientName)
client = jackbridge_client_open(clientName, JackNullOption, nullptr); client = jackbridge_client_open(clientName, JackNullOption, nullptr);
state = JackTransportStopped; state = JackTransportStopped;
freewheel = false; freewheel = false;
procThread = nullptr;


if (client) if (client)
{ {
@@ -212,11 +210,6 @@ bool CarlaEngineJack::close()
return false; return false;
} }


bool CarlaEngineJack::isOnAudioThread()
{
return (QThread::currentThread() == procThread);
}

bool CarlaEngineJack::isOffline() bool CarlaEngineJack::isOffline()
{ {
return freewheel; return freewheel;
@@ -273,9 +266,6 @@ void CarlaEngineJack::handleFreewheelCallback(bool isFreewheel)


void CarlaEngineJack::handleProcessCallback(uint32_t nframes) void CarlaEngineJack::handleProcessCallback(uint32_t nframes)
{ {
if (procThread == nullptr)
procThread = QThread::currentThread();

if (maxPluginNumber == 0) if (maxPluginNumber == 0)
return; return;


@@ -598,7 +588,6 @@ void CarlaEngineJack::handleShutdownCallback()
//} //}


client = nullptr; client = nullptr;
procThread = nullptr;
callback(CALLBACK_QUIT, 0, 0, 0, 0.0); callback(CALLBACK_QUIT, 0, 0, 0, 0.0);
} }




+ 39
- 19
c++/carla-backend/vst.cpp View File

@@ -27,10 +27,6 @@


CARLA_BACKEND_START_NAMESPACE CARLA_BACKEND_START_NAMESPACE


#if 0
} /* adjust editor indent */
#endif

/*! /*!
* @defgroup CarlaBackendVstPlugin Carla Backend VST Plugin * @defgroup CarlaBackendVstPlugin Carla Backend VST Plugin
* *
@@ -67,6 +63,8 @@ public:
gui.width = 0; gui.width = 0;
gui.height = 0; gui.height = 0;


isProcessing = false;

memset(midiEvents, 0, sizeof(VstMidiEvent)*MAX_MIDI_EVENTS*2); memset(midiEvents, 0, sizeof(VstMidiEvent)*MAX_MIDI_EVENTS*2);


for (unsigned short i=0; i < MAX_MIDI_EVENTS*2; i++) for (unsigned short i=0; i < MAX_MIDI_EVENTS*2; i++)
@@ -1171,7 +1169,9 @@ public:
//{ //{
if (m_hints & PLUGIN_CAN_PROCESS_REPLACING) if (m_hints & PLUGIN_CAN_PROCESS_REPLACING)
{ {
isProcessing = true;
effect->processReplacing(effect, inBuffer, outBuffer, frames); effect->processReplacing(effect, inBuffer, outBuffer, frames);
isProcessing = false;
} }
else else
{ {
@@ -1179,7 +1179,9 @@ public:
memset(outBuffer[i], 0, sizeof(float)*frames); memset(outBuffer[i], 0, sizeof(float)*frames);


#if ! VST_FORCE_DEPRECATED #if ! VST_FORCE_DEPRECATED
isProcessing = true;
effect->process(effect, inBuffer, outBuffer, frames); effect->process(effect, inBuffer, outBuffer, frames);
isProcessing = false;
#endif #endif
} }
//} //}
@@ -1396,20 +1398,20 @@ public:
if (index >= param.count /*|| ! m_enabled*/) if (index >= param.count /*|| ! m_enabled*/)
return; return;


if (x_engine->isOnAudioThread() && ! x_engine->isOffline())
if (isProcessing && ! x_engine->isOffline())
{ {
setParameterValue(index, value, false, false, false); setParameterValue(index, value, false, false, false);
postponeEvent(PluginPostEventParameterChange, index, 0, value); postponeEvent(PluginPostEventParameterChange, index, 0, value);
} }
else else
setParameterValue(index, value, true, true, true); // FIXME - dont send to GUI?
setParameterValue(index, value, isProcessing, true, true);
} }


intptr_t handleAudioMasterGetCurrentProcessLevel() intptr_t handleAudioMasterGetCurrentProcessLevel()
{ {
if (x_engine->isOffline()) if (x_engine->isOffline())
return kVstProcessLevelOffline; return kVstProcessLevelOffline;
if (x_engine->isOnAudioThread())
if (isProcessing)
return kVstProcessLevelRealtime; return kVstProcessLevelRealtime;
return kVstProcessLevelUser; return kVstProcessLevelUser;
} }
@@ -1465,10 +1467,31 @@ public:
vstTimeInfo.timeSigDenominator = timeInfo->bbt.beat_type; vstTimeInfo.timeSigDenominator = timeInfo->bbt.beat_type;
vstTimeInfo.flags |= kVstTimeSigValid; vstTimeInfo.flags |= kVstTimeSigValid;
} }
else
{
// Tempo
vstTimeInfo.tempo = 120.0;
vstTimeInfo.flags |= kVstTempoValid;

// Time Signature
vstTimeInfo.timeSigNumerator = 4;
vstTimeInfo.timeSigDenominator = 4;
vstTimeInfo.flags |= kVstTimeSigValid;
}


return &vstTimeInfo; return &vstTimeInfo;
} }


intptr_t handleAudioMasterTempoAt()
{
const CarlaTimeInfo* const timeInfo = x_engine->getTimeInfo();

if (timeInfo->valid & CarlaEngineTimeBBT)
return timeInfo->bbt.beats_per_minute * 10000;

return 0;
}

intptr_t handleAudioMasterIOChanged() intptr_t handleAudioMasterIOChanged()
{ {
qDebug("VstPlugin::handleAudioMasterIOChanged()"); qDebug("VstPlugin::handleAudioMasterIOChanged()");
@@ -1513,6 +1536,8 @@ public:
intptr_t handleAudioMasterProcessEvents(const VstEvents* const vstEvents) intptr_t handleAudioMasterProcessEvents(const VstEvents* const vstEvents)
{ {
Q_ASSERT(m_enabled); Q_ASSERT(m_enabled);
Q_ASSERT(midi.portMout);
Q_ASSERT(isProcessing);


if (! m_enabled) if (! m_enabled)
return 0; return 0;
@@ -1520,7 +1545,7 @@ public:
if (! midi.portMout) if (! midi.portMout)
return 0; return 0;


if (! x_engine->isOnAudioThread())
if (! isProcessing)
{ {
qCritical("VstPlugin:handleAudioMasterProcessEvents(%p) - received MIDI out events outside audio thread, ignoring", vstEvents); qCritical("VstPlugin:handleAudioMasterProcessEvents(%p) - received MIDI out events outside audio thread, ignoring", vstEvents);
return 0; return 0;
@@ -1533,23 +1558,13 @@ public:


const VstMidiEvent* const vstMidiEvent = (const VstMidiEvent*)vstEvents->events[i]; const VstMidiEvent* const vstMidiEvent = (const VstMidiEvent*)vstEvents->events[i];


if (vstMidiEvent->type != kVstMidiType)
if (vstMidiEvent->type == kVstMidiType)
memcpy(&midiEvents[events.numEvents++], vstMidiEvent, sizeof(VstMidiEvent)); memcpy(&midiEvents[events.numEvents++], vstMidiEvent, sizeof(VstMidiEvent));
} }


return 1; return 1;
} }


intptr_t handleAudioMasterTempoAt()
{
const CarlaTimeInfo* const timeInfo = x_engine->getTimeInfo();

if (timeInfo->valid & CarlaEngineTimeBBT)
return timeInfo->bbt.beats_per_minute * 10000;

return 0;
}

intptr_t handleAdioMasterSizeWindow(int32_t width, int32_t height) intptr_t handleAdioMasterSizeWindow(int32_t width, int32_t height)
{ {
qDebug("VstPlugin::handleAudioMasterSizeWindow(%i, %i)", width, height); qDebug("VstPlugin::handleAudioMasterSizeWindow(%i, %i)", width, height);
@@ -2055,7 +2070,10 @@ public:


// special checks // special checks
if (effect->dispatcher(effect, effCanDo, 0, 0, (void*)"hasCockosExtensions", 0.0f) == 0xbeef0000) if (effect->dispatcher(effect, effCanDo, 0, 0, (void*)"hasCockosExtensions", 0.0f) == 0xbeef0000)
{
qDebug("Plugin has Cockos extensions!");
m_hints |= PLUGIN_HAS_COCKOS_EXTENSIONS; m_hints |= PLUGIN_HAS_COCKOS_EXTENSIONS;
}


if (effect->dispatcher(effect, effGetVstVersion, 0, 0, nullptr, 0.0f) < kVstVersion) if (effect->dispatcher(effect, effGetVstVersion, 0, 0, nullptr, 0.0f) < kVstVersion)
m_hints |= PLUGIN_USES_OLD_VSTSDK; m_hints |= PLUGIN_USES_OLD_VSTSDK;
@@ -2126,6 +2144,8 @@ private:
int height; int height;
} gui; } gui;


bool isProcessing;

int unique2; int unique2;
}; };




+ 1
- 1
c++/carla-bridge/Makefile View File

@@ -13,7 +13,7 @@ BASE_FLAGS = -O0 -g
BUILD_FLAGS = $(BASE_FLAGS) -std=c++0x $(CXXFLAGS) BUILD_FLAGS = $(BASE_FLAGS) -std=c++0x $(CXXFLAGS)
BUILD_FLAGS += -I. -I../carla-includes $(shell pkg-config --cflags liblo QtCore) BUILD_FLAGS += -I. -I../carla-includes $(shell pkg-config --cflags liblo QtCore)
BUILD_FLAGS += -DBUILD_BRIDGE -DDEBUG # -DQT_NO_DEBUG -DQT_NO_DEBUG_STREAM -DQT_NO_DEBUG_OUTPUT # -DNDEBUG BUILD_FLAGS += -DBUILD_BRIDGE -DDEBUG # -DQT_NO_DEBUG -DQT_NO_DEBUG_STREAM -DQT_NO_DEBUG_OUTPUT # -DNDEBUG
BUILD_FLAGS += -DVESTIGE_HEADER -I../carla-includes/vestige # Comment this line to not use vestige header
BUILD_FLAGS += -DVESTIGE_HEADER # Comment this line to not use vestige header


32BIT_FLAGS = -m32 32BIT_FLAGS = -m32
64BIT_FLAGS = -m64 64BIT_FLAGS = -m64


Loading…
Cancel
Save