@@ -805,6 +805,10 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, cons | |||
//plugin = CarlaPlugin::newVST3(init); | |||
break; | |||
case PLUGIN_AU: | |||
//plugin = CarlaPlugin::newAU(init); | |||
break; | |||
case PLUGIN_GIG: | |||
plugin = CarlaPlugin::newGIG(init, (extra != nullptr)); | |||
break; | |||
@@ -1517,98 +1521,91 @@ void CarlaEngine::setAboutToClose() | |||
// ----------------------------------------------------------------------- | |||
// Global options | |||
#define CARLA_ENGINE_SET_OPTION_RUNNING_CHECK \ | |||
if (isRunning()) \ | |||
return carla_stderr("CarlaEngine::setOption(%s, %i, \"%s\") - Cannot set this option while engine is running!", OptionsType2Str(option), value, valueStr); | |||
void CarlaEngine::setOption(const OptionsType option, const int value, const char* const valueStr) | |||
{ | |||
carla_debug("CarlaEngine::setOption(%s, %i, \"%s\")", OptionsType2Str(option), value, valueStr); | |||
if (option >= OPTION_PROCESS_MODE && option < OPTION_PATH_RESOURCES && isRunning()) | |||
return carla_stderr("CarlaEngine::setOption(%s, %i, \"%s\") - Cannot set this option while engine is running!", OptionsType2Str(option), value, valueStr); | |||
switch (option) | |||
{ | |||
case OPTION_PROCESS_NAME: | |||
carla_setprocname(valueStr); | |||
break; | |||
case OPTION_PROCESS_MODE: | |||
CARLA_ENGINE_SET_OPTION_RUNNING_CHECK | |||
if (value < PROCESS_MODE_SINGLE_CLIENT || value > PROCESS_MODE_BRIDGE) | |||
return carla_stderr("CarlaEngine::setOption(%s, %i, \"%s\") - invalid value", OptionsType2Str(option), value, valueStr); | |||
if (value < PROCESS_MODE_SINGLE_CLIENT || value > PROCESS_MODE_PATCHBAY) | |||
return carla_stderr("CarlaEngine::setOption(OPTION_PROCESS_MODE, %i, \"%s\") - invalid value", value, valueStr); | |||
fOptions.processMode = static_cast<ProcessMode>(value); | |||
break; | |||
case OPTION_TRANSPORT_MODE: | |||
// FIXME: Always enable JACK transport for now | |||
#if 0 | |||
if (value < CarlaBackend::TRANSPORT_MODE_INTERNAL || value > CarlaBackend::TRANSPORT_MODE_BRIDGE) | |||
if (value < CarlaBackend::TRANSPORT_MODE_INTERNAL || value > CarlaBackend::TRANSPORT_MODE_JACK) | |||
return carla_stderr2("carla_set_engine_option(OPTION_TRANSPORT_MODE, %i, \"%s\") - invalid value", value, valueStr); | |||
fOptions.transportMode = static_cast<CarlaBackend::TransportMode>(value); | |||
#endif | |||
break; | |||
case OPTION_MAX_PARAMETERS: | |||
CARLA_ENGINE_SET_OPTION_RUNNING_CHECK | |||
if (value < 0) | |||
return; // TODO error here | |||
fOptions.maxParameters = static_cast<uint>(value); | |||
break; | |||
case OPTION_FORCE_STEREO: | |||
CARLA_ENGINE_SET_OPTION_RUNNING_CHECK | |||
fOptions.forceStereo = (value != 0); | |||
break; | |||
case OPTION_PREFER_PLUGIN_BRIDGES: | |||
CARLA_ENGINE_SET_OPTION_RUNNING_CHECK | |||
fOptions.preferPluginBridges = (value != 0); | |||
break; | |||
case OPTION_PREFER_UI_BRIDGES: | |||
CARLA_ENGINE_SET_OPTION_RUNNING_CHECK | |||
fOptions.preferUiBridges = (value != 0); | |||
break; | |||
case OPTION_UIS_ALWAYS_ON_TOP: | |||
fOptions.uisAlwaysOnTop = (value != 0); | |||
break; | |||
#ifdef WANT_DSSI | |||
case OPTION_USE_DSSI_VST_CHUNKS: | |||
CARLA_ENGINE_SET_OPTION_RUNNING_CHECK | |||
fOptions.useDssiVstChunks = (value != 0); | |||
break; | |||
#endif | |||
case OPTION_UI_BRIDGES_TIMEOUT: | |||
CARLA_ENGINE_SET_OPTION_RUNNING_CHECK | |||
fOptions.oscUiTimeout = static_cast<uint>(value); | |||
case OPTION_MAX_PARAMETERS: | |||
if (value < 1) | |||
return carla_stderr2("carla_set_engine_option(OPTION_MAX_PARAMETERS, %i, \"%s\") - invalid value", value, valueStr); | |||
fOptions.maxParameters = static_cast<uint>(value); | |||
break; | |||
case OPTION_JACK_AUTOCONNECT: | |||
CARLA_ENGINE_SET_OPTION_RUNNING_CHECK | |||
fOptions.jackAutoConnect = (value != 0); | |||
case OPTION_UI_BRIDGES_TIMEOUT: | |||
if (value < 1) | |||
return carla_stderr2("carla_set_engine_option(OPTION_UI_BRIDGES_TIMEOUT, %i, \"%s\") - invalid value", value, valueStr); | |||
fOptions.uiBridgesTimeout = static_cast<uint>(value); | |||
break; | |||
#ifdef WANT_RTAUDIO | |||
case OPTION_RTAUDIO_NUMBER_PERIODS: | |||
CARLA_ENGINE_SET_OPTION_RUNNING_CHECK | |||
fOptions.rtaudioNumberPeriods = static_cast<uint>(value); | |||
if (value < 2 || value > 3) | |||
return carla_stderr2("carla_set_engine_option(OPTION_MAX_PARAMETERS, %i, \"%s\") - invalid value", value, valueStr); | |||
fOptions.rtaudioNumPeriods = static_cast<uint>(value); | |||
break; | |||
case OPTION_RTAUDIO_BUFFER_SIZE: | |||
CARLA_ENGINE_SET_OPTION_RUNNING_CHECK | |||
if (value < 8) | |||
return carla_stderr2("carla_set_engine_option(OPTION_MAX_PARAMETERS, %i, \"%s\") - invalid value", value, valueStr); | |||
fOptions.rtaudioBufferSize = static_cast<uint>(value); | |||
break; | |||
case OPTION_RTAUDIO_SAMPLE_RATE: | |||
CARLA_ENGINE_SET_OPTION_RUNNING_CHECK | |||
if (value < 22050) | |||
return carla_stderr2("carla_set_engine_option(OPTION_MAX_PARAMETERS, %i, \"%s\") - invalid value", value, valueStr); | |||
fOptions.rtaudioSampleRate = static_cast<uint>(value); | |||
break; | |||
case OPTION_RTAUDIO_DEVICE: | |||
CARLA_ENGINE_SET_OPTION_RUNNING_CHECK | |||
fOptions.rtaudioDevice = valueStr; | |||
break; | |||
#endif | |||
@@ -95,7 +95,7 @@ public: | |||
fBuffer = (float*)jackbridge_port_get_buffer(kPort, bufferSize); | |||
if (! kIsInput) | |||
if (! fIsInput) | |||
carla_zeroFloat(fBuffer, bufferSize); | |||
} | |||
@@ -151,7 +151,7 @@ public: | |||
CARLA_ASSERT(engine->getBufferSize() == fBufferSize); | |||
if (kIsInput) | |||
if (fIsInput) | |||
{ | |||
float* const jackBuffer((float*)jackbridge_port_get_buffer(kPort, fBufferSize)); | |||
carla_copyFloat(fBuffer, jackBuffer, fBufferSize); | |||
@@ -164,9 +164,9 @@ public: | |||
void writeBuffer(const uint32_t frames, const uint32_t timeOffset) override | |||
{ | |||
CARLA_ASSERT(! kIsInput); | |||
CARLA_ASSERT(! fIsInput); | |||
if (kIsInput) | |||
if (fIsInput) | |||
return; | |||
float* const jackBuffer((float*)jackbridge_port_get_buffer(kPort, fBufferSize)); | |||
@@ -226,7 +226,7 @@ public: | |||
fJackBuffer = jackbridge_port_get_buffer(kPort, engine->getBufferSize()); | |||
if (! kIsInput) | |||
if (! fIsInput) | |||
jackbridge_midi_clear_buffer(fJackBuffer); | |||
} | |||
@@ -235,10 +235,10 @@ public: | |||
if (kPort == nullptr) | |||
return CarlaEngineEventPort::getEventCount(); | |||
CARLA_ASSERT(kIsInput); | |||
CARLA_ASSERT(fIsInput); | |||
CARLA_ASSERT(fJackBuffer != nullptr); | |||
if (! kIsInput) | |||
if (! fIsInput) | |||
return 0; | |||
if (fJackBuffer == nullptr) | |||
return 0; | |||
@@ -251,10 +251,10 @@ public: | |||
if (kPort == nullptr) | |||
return CarlaEngineEventPort::getEvent(index); | |||
CARLA_ASSERT(kIsInput); | |||
CARLA_ASSERT(fIsInput); | |||
CARLA_ASSERT(fJackBuffer != nullptr); | |||
if (! kIsInput) | |||
if (! fIsInput) | |||
return kFallbackJackEngineEvent; | |||
if (fJackBuffer == nullptr) | |||
return kFallbackJackEngineEvent; | |||
@@ -342,14 +342,14 @@ public: | |||
if (kPort == nullptr) | |||
return CarlaEngineEventPort::writeControlEvent(time, channel, type, param, value); | |||
CARLA_ASSERT(! kIsInput); | |||
CARLA_ASSERT(! fIsInput); | |||
CARLA_ASSERT(fJackBuffer != nullptr); | |||
CARLA_ASSERT(type != kEngineControlEventTypeNull); | |||
CARLA_ASSERT(channel < MAX_MIDI_CHANNELS); | |||
CARLA_ASSERT(param < MAX_MIDI_VALUE); | |||
CARLA_SAFE_ASSERT(value >= 0.0f && value <= 1.0f); | |||
if (kIsInput) | |||
if (fIsInput) | |||
return; | |||
if (fJackBuffer == nullptr) | |||
return; | |||
@@ -413,13 +413,13 @@ public: | |||
if (kPort == nullptr) | |||
return CarlaEngineEventPort::writeMidiEvent(time, channel, port, data, size); | |||
CARLA_ASSERT(! kIsInput); | |||
CARLA_ASSERT(! fIsInput); | |||
CARLA_ASSERT(fJackBuffer != nullptr); | |||
CARLA_ASSERT(channel < MAX_MIDI_CHANNELS); | |||
CARLA_ASSERT(data != nullptr); | |||
CARLA_ASSERT(size != 0); | |||
if (kIsInput) | |||
if (fIsInput) | |||
return; | |||
if (fJackBuffer == nullptr) | |||
return; | |||
@@ -475,7 +475,7 @@ public: | |||
{ | |||
carla_debug("CarlaEngineClient::~CarlaEngineClient()"); | |||
if (kEngine.getProccessMode() == PROCESS_MODE_MULTIPLE_CLIENTS && kClient != nullptr) | |||
if (fEngine.getProccessMode() == PROCESS_MODE_MULTIPLE_CLIENTS && kClient != nullptr) | |||
jackbridge_client_close(kClient); | |||
} | |||
@@ -483,7 +483,7 @@ public: | |||
{ | |||
carla_debug("CarlaEngineJackClient::activate()"); | |||
if (kEngine.getProccessMode() == PROCESS_MODE_MULTIPLE_CLIENTS) | |||
if (fEngine.getProccessMode() == PROCESS_MODE_MULTIPLE_CLIENTS) | |||
{ | |||
CARLA_ASSERT(kClient != nullptr && ! fActive); | |||
@@ -498,7 +498,7 @@ public: | |||
{ | |||
carla_debug("CarlaEngineJackClient::deactivate()"); | |||
if (kEngine.getProccessMode() == PROCESS_MODE_MULTIPLE_CLIENTS) | |||
if (fEngine.getProccessMode() == PROCESS_MODE_MULTIPLE_CLIENTS) | |||
{ | |||
CARLA_ASSERT(kClient != nullptr && fActive); | |||
@@ -560,11 +560,11 @@ public: | |||
case kEnginePortTypeNull: | |||
break; | |||
case kEnginePortTypeAudio: | |||
return new CarlaEngineJackAudioPort(isInput, kEngine.getProccessMode(), kClient, port); | |||
return new CarlaEngineJackAudioPort(isInput, fEngine.getProccessMode(), kClient, port); | |||
case kEnginePortTypeCV: | |||
return new CarlaEngineJackCVPort(isInput, kEngine.getProccessMode(), kEngine.getBufferSize(), kClient, port); | |||
return new CarlaEngineJackCVPort(isInput, fEngine.getProccessMode(), fEngine.getBufferSize(), kClient, port); | |||
case kEnginePortTypeEvent: | |||
return new CarlaEngineJackEventPort(isInput, kEngine.getProccessMode(), kClient, port); | |||
return new CarlaEngineJackEventPort(isInput, fEngine.getProccessMode(), kClient, port); | |||
} | |||
carla_stderr("CarlaEngineJackClient::addPort(%s, \"%s\", %s) - invalid type", EnginePortType2Str(portType), name, bool2str(isInput)); | |||
@@ -633,20 +633,20 @@ public: | |||
// ------------------------------------------------------------------- | |||
// Maximum values | |||
unsigned int maxClientNameSize() const override | |||
unsigned int getMaxClientNameSize() const noexcept override | |||
{ | |||
if (fOptions.processMode == PROCESS_MODE_SINGLE_CLIENT || fOptions.processMode == PROCESS_MODE_MULTIPLE_CLIENTS) | |||
return static_cast<unsigned int>(jackbridge_client_name_size()); | |||
return CarlaEngine::maxClientNameSize(); | |||
return CarlaEngine::getMaxClientNameSize(); | |||
} | |||
unsigned int maxPortNameSize() const override | |||
unsigned int getMaxPortNameSize() const noexcept override | |||
{ | |||
if (fOptions.processMode == PROCESS_MODE_SINGLE_CLIENT || fOptions.processMode == PROCESS_MODE_MULTIPLE_CLIENTS) | |||
return static_cast<unsigned int>(jackbridge_port_name_size()); | |||
return CarlaEngine::maxPortNameSize(); | |||
return CarlaEngine::getMaxPortNameSize(); | |||
} | |||
// ------------------------------------------------------------------- | |||
@@ -844,7 +844,7 @@ public: | |||
} | |||
#endif | |||
bool isRunning() const override | |||
bool isRunning() const noexcept override | |||
{ | |||
#ifdef BUILD_BRIDGE | |||
return (fClient != nullptr || ! fHasQuit); | |||
@@ -853,19 +853,19 @@ public: | |||
#endif | |||
} | |||
bool isOffline() const override | |||
bool isOffline() const noexcept override | |||
{ | |||
return fFreewheel; | |||
} | |||
EngineType type() const override | |||
EngineType getType() const noexcept override | |||
{ | |||
return kEngineTypeJack; | |||
} | |||
CarlaEngineClient* addClient(CarlaPlugin* const plugin) override | |||
{ | |||
const char* const iconName(plugin->iconName()); | |||
const char* const iconName(plugin->getIconName()); | |||
jack_client_t* client = nullptr; | |||
#ifdef BUILD_BRIDGE | |||
@@ -894,7 +894,7 @@ public: | |||
} | |||
else if (fOptions.processMode == PROCESS_MODE_MULTIPLE_CLIENTS) | |||
{ | |||
client = jackbridge_client_open(plugin->name(), JackNullOption, nullptr); | |||
client = jackbridge_client_open(plugin->getName(), JackNullOption, nullptr); | |||
CARLA_ASSERT(client != nullptr); | |||
@@ -914,18 +914,18 @@ public: | |||
#ifndef BUILD_BRIDGE | |||
const char* renamePlugin(const unsigned int id, const char* const newName) override | |||
{ | |||
CARLA_ASSERT(kData->curPluginCount > 0); | |||
CARLA_ASSERT(id < kData->curPluginCount); | |||
CARLA_ASSERT(kData->plugins != nullptr); | |||
CARLA_ASSERT(pData->curPluginCount > 0); | |||
CARLA_ASSERT(id < pData->curPluginCount); | |||
CARLA_ASSERT(pData->plugins != nullptr); | |||
CARLA_ASSERT(newName != nullptr); | |||
if (kData->plugins == nullptr) | |||
if (pData->plugins == nullptr) | |||
{ | |||
setLastError("Critical error: no plugins are currently loaded!"); | |||
return nullptr; | |||
} | |||
CarlaPlugin* const plugin(kData->plugins[id].plugin); | |||
CarlaPlugin* const plugin(pData->plugins[id].plugin); | |||
if (plugin == nullptr) | |||
{ | |||
@@ -933,7 +933,7 @@ public: | |||
return nullptr; | |||
} | |||
CARLA_ASSERT(plugin->id() == id); | |||
CARLA_ASSERT(plugin->getId() == id); | |||
bool needsReinit = (fOptions.processMode == PROCESS_MODE_SINGLE_CLIENT); | |||
const char* name = getUniquePluginName(newName); | |||
@@ -956,7 +956,7 @@ public: | |||
if (jack_client_t* jclient = jackbridge_client_open(name, JackNullOption, nullptr)) | |||
{ | |||
const char* const iconName(plugin->iconName()); | |||
const char* const iconName(plugin->getIconName()); | |||
jackbridge_custom_publish_data(jclient, URI_CANVAS_ICON, iconName, std::strlen(iconName)+1); | |||
// close old client | |||
@@ -1178,7 +1178,7 @@ protected: | |||
{ | |||
saveTransportInfo(); | |||
if (kData->curPluginCount == 0) | |||
if (pData->curPluginCount == 0) | |||
{ | |||
#ifndef BUILD_BRIDGE | |||
// pass-through | |||
@@ -1202,13 +1202,13 @@ protected: | |||
} | |||
#endif | |||
return proccessPendingEvents(); | |||
return runPendingRtEvents(); | |||
} | |||
#ifdef BUILD_BRIDGE | |||
CarlaPlugin* const plugin(kData->plugins[0].plugin); | |||
CarlaPlugin* const plugin(pData->plugins[0].plugin); | |||
if (plugin != nullptr && plugin->enabled() && plugin->tryLock()) | |||
if (plugin != nullptr && plugin->isEnabled() && plugin->tryLock()) | |||
{ | |||
plugin->initBuffers(); | |||
processPlugin(plugin, nframes); | |||
@@ -1217,11 +1217,11 @@ protected: | |||
#else | |||
if (fOptions.processMode == PROCESS_MODE_SINGLE_CLIENT) | |||
{ | |||
for (unsigned int i=0; i < kData->curPluginCount; ++i) | |||
for (unsigned int i=0; i < pData->curPluginCount; ++i) | |||
{ | |||
CarlaPlugin* const plugin(kData->plugins[i].plugin); | |||
CarlaPlugin* const plugin(pData->plugins[i].plugin); | |||
if (plugin != nullptr && plugin->enabled() && plugin->tryLock()) | |||
if (plugin != nullptr && plugin->isEnabled() && plugin->tryLock()) | |||
{ | |||
plugin->initBuffers(); | |||
processPlugin(plugin, nframes); | |||
@@ -1252,7 +1252,7 @@ protected: | |||
float* outBuf[2] = { audioOut1, audioOut2 }; | |||
// initialize input events | |||
carla_zeroStruct<EngineEvent>(kData->bufEvents.in, INTERNAL_EVENT_COUNT); | |||
carla_zeroStruct<EngineEvent>(pData->bufEvents.in, INTERNAL_EVENT_COUNT); | |||
{ | |||
uint32_t engineEventIndex = 0; | |||
@@ -1264,7 +1264,7 @@ protected: | |||
if (! jackbridge_midi_event_get(&jackEvent, eventIn, jackEventIndex)) | |||
continue; | |||
EngineEvent* const engineEvent(&kData->bufEvents.in[engineEventIndex++]); | |||
EngineEvent* const engineEvent(&pData->bufEvents.in[engineEventIndex++]); | |||
engineEvent->clear(); | |||
const uint8_t midiStatus = MIDI_GET_STATUS_FROM_DATA(jackEvent.buffer); | |||
@@ -1347,7 +1347,7 @@ protected: | |||
for (unsigned short i=0; i < INTERNAL_EVENT_COUNT; ++i) | |||
{ | |||
EngineEvent* const engineEvent = &kData->bufEvents.out[i]; | |||
EngineEvent* const engineEvent = &pData->bufEvents.out[i]; | |||
uint8_t data[3] = { 0 }; | |||
uint8_t size = 0; | |||
@@ -1423,7 +1423,7 @@ protected: | |||
} | |||
#endif // ! BUILD_BRIDGE | |||
proccessPendingEvents(); | |||
runPendingRtEvents(); | |||
} | |||
void handleJackLatencyCallback(const jack_latency_callback_mode_t mode) | |||
@@ -1431,11 +1431,11 @@ protected: | |||
if (fOptions.processMode != PROCESS_MODE_SINGLE_CLIENT) | |||
return; | |||
for (unsigned int i=0; i < kData->curPluginCount; ++i) | |||
for (unsigned int i=0; i < pData->curPluginCount; ++i) | |||
{ | |||
CarlaPlugin* const plugin(kData->plugins[i].plugin); | |||
CarlaPlugin* const plugin(pData->plugins[i].plugin); | |||
if (plugin != nullptr && plugin->enabled()) | |||
if (plugin != nullptr && plugin->isEnabled()) | |||
latencyPlugin(plugin, mode); | |||
} | |||
} | |||
@@ -1652,9 +1652,9 @@ protected: | |||
void handleJackShutdownCallback() | |||
{ | |||
for (unsigned int i=0; i < kData->curPluginCount; ++i) | |||
for (unsigned int i=0; i < pData->curPluginCount; ++i) | |||
{ | |||
//CarlaPlugin* const plugin(kData->plugins[i].plugin); | |||
//CarlaPlugin* const plugin(pData->plugins[i].plugin); | |||
//if (plugin) | |||
// plugin->x_client = nullptr; | |||
@@ -2026,8 +2026,8 @@ private: | |||
void processPlugin(CarlaPlugin* const plugin, const uint32_t nframes) | |||
{ | |||
const uint32_t inCount(plugin->audioInCount()); | |||
const uint32_t outCount(plugin->audioOutCount()); | |||
const uint32_t inCount(plugin->getAudioInCount()); | |||
const uint32_t outCount(plugin->getAudioOutCount()); | |||
float* inBuffer[inCount]; | |||
float* outBuffer[outCount]; | |||
@@ -2071,14 +2071,14 @@ private: | |||
} | |||
} | |||
setPeaks(plugin->id(), inPeaks, outPeaks); | |||
setPluginPeaks(plugin->getId(), inPeaks, outPeaks); | |||
} | |||
void latencyPlugin(CarlaPlugin* const plugin, jack_latency_callback_mode_t mode) | |||
{ | |||
//const uint32_t inCount(plugin->audioInCount()); | |||
//const uint32_t outCount(plugin->audioOutCount()); | |||
const uint32_t latency(plugin->latency()); | |||
const uint32_t latency(plugin->getLatencyInFrames()); | |||
if (latency == 0) | |||
return; | |||
@@ -2201,7 +2201,7 @@ private: | |||
{ | |||
CarlaPlugin* const plugin((CarlaPlugin*)arg); | |||
if (plugin != nullptr && plugin->enabled() && plugin->tryLock()) | |||
if (plugin != nullptr && plugin->isEnabled() && plugin->tryLock()) | |||
{ | |||
CarlaEngineJack* const engine((CarlaEngineJack*)CarlaPluginGetEngine(plugin)); | |||
CARLA_ASSERT(engine != nullptr); | |||
@@ -2219,7 +2219,7 @@ private: | |||
{ | |||
CarlaPlugin* const plugin((CarlaPlugin*)arg); | |||
if (plugin != nullptr && plugin->enabled()) | |||
if (plugin != nullptr && plugin->isEnabled()) | |||
{ | |||
CarlaEngineJack* const engine((CarlaEngineJack*)CarlaPluginGetEngine(plugin)); | |||
CARLA_ASSERT(engine != nullptr); | |||
@@ -162,7 +162,7 @@ public: | |||
init("Carla-Plugin"); | |||
// set control thread binary | |||
CarlaString threadBinary(hostResourceDir()); | |||
CarlaString threadBinary(getResourceDir()); | |||
threadBinary += "/../"; | |||
threadBinary += "carla_control.py"; | |||
@@ -207,21 +207,21 @@ protected: | |||
{ | |||
carla_debug("CarlaEngineNative::close()"); | |||
proccessPendingEvents(); | |||
runPendingRtEvents(); | |||
return CarlaEngine::close(); | |||
} | |||
bool isRunning() const override | |||
bool isRunning() const noexcept override | |||
{ | |||
return fIsRunning; | |||
} | |||
bool isOffline() const override | |||
bool isOffline() const noexcept override | |||
{ | |||
return false; | |||
} | |||
EngineType type() const override | |||
EngineType getType() const noexcept override | |||
{ | |||
return kEngineTypePlugin; | |||
} | |||
@@ -231,15 +231,15 @@ protected: | |||
uint32_t getParameterCount() override | |||
{ | |||
if (kData->curPluginCount == 0 || kData->plugins == nullptr) | |||
if (pData->curPluginCount == 0 || pData->plugins == nullptr) | |||
return 0; | |||
CarlaPlugin* const plugin(kData->plugins[0].plugin); | |||
CarlaPlugin* const plugin(pData->plugins[0].plugin); | |||
if (plugin == nullptr || ! plugin->enabled()) | |||
if (plugin == nullptr || ! plugin->isEnabled()) | |||
return 0; | |||
return kData->plugins[0].plugin->parameterCount(); | |||
return pData->plugins[0].plugin->getParameterCount(); | |||
} | |||
const Parameter* getParameterInfo(const uint32_t index) override | |||
@@ -247,17 +247,17 @@ protected: | |||
if (index >= getParameterCount()) | |||
return nullptr; | |||
CarlaPlugin* const plugin(kData->plugins[0].plugin); | |||
CarlaPlugin* const plugin(pData->plugins[0].plugin); | |||
if (plugin == nullptr || ! plugin->enabled()) | |||
if (plugin == nullptr || ! plugin->isEnabled()) | |||
return nullptr; | |||
static ::Parameter param; | |||
static char strBufName[STR_MAX+1]; | |||
static char strBufUnit[STR_MAX+1]; | |||
const ParameterData& paramData(plugin->parameterData(index)); | |||
const ParameterRanges& paramRanges(plugin->parameterRanges(index)); | |||
const ParameterData& paramData(plugin->getParameterData(index)); | |||
const ParameterRanges& paramRanges(plugin->getParameterRanges(index)); | |||
plugin->getParameterName(index, strBufName); | |||
plugin->getParameterUnit(index, strBufUnit); | |||
@@ -307,9 +307,9 @@ protected: | |||
if (index >= getParameterCount()) | |||
return 0.0f; | |||
CarlaPlugin* const plugin(kData->plugins[0].plugin); | |||
CarlaPlugin* const plugin(pData->plugins[0].plugin); | |||
if (plugin == nullptr || ! plugin->enabled()) | |||
if (plugin == nullptr || ! plugin->isEnabled()) | |||
return 0.0f; | |||
return plugin->getParameterValue(index); | |||
@@ -320,9 +320,9 @@ protected: | |||
if (index >= getParameterCount()) | |||
return nullptr; | |||
CarlaPlugin* const plugin(kData->plugins[0].plugin); | |||
CarlaPlugin* const plugin(pData->plugins[0].plugin); | |||
if (plugin == nullptr || ! plugin->enabled()) | |||
if (plugin == nullptr || ! plugin->isEnabled()) | |||
return nullptr; | |||
static char strBuf[STR_MAX+1]; | |||
@@ -337,15 +337,15 @@ protected: | |||
uint32_t getMidiProgramCount() override | |||
{ | |||
if (kData->curPluginCount == 0 || kData->plugins == nullptr) | |||
if (pData->curPluginCount == 0 || pData->plugins == nullptr) | |||
return 0; | |||
CarlaPlugin* const plugin(kData->plugins[0].plugin); | |||
CarlaPlugin* const plugin(pData->plugins[0].plugin); | |||
if (plugin == nullptr || ! plugin->enabled()) | |||
if (plugin == nullptr || ! plugin->isEnabled()) | |||
return 0.0f; | |||
return plugin->midiProgramCount(); | |||
return plugin->getMidiProgramCount(); | |||
} | |||
const MidiProgram* getMidiProgramInfo(const uint32_t index) override | |||
@@ -353,15 +353,15 @@ protected: | |||
if (index >= getMidiProgramCount()) | |||
return nullptr; | |||
CarlaPlugin* const plugin(kData->plugins[0].plugin); | |||
CarlaPlugin* const plugin(pData->plugins[0].plugin); | |||
if (plugin == nullptr || ! plugin->enabled()) | |||
if (plugin == nullptr || ! plugin->isEnabled()) | |||
return nullptr; | |||
static ::MidiProgram midiProg; | |||
{ | |||
const MidiProgramData& midiProgData(plugin->midiProgramData(index)); | |||
const MidiProgramData& midiProgData(plugin->getMidiProgramData(index)); | |||
midiProg.bank = midiProgData.bank; | |||
midiProg.program = midiProgData.program; | |||
@@ -379,9 +379,9 @@ protected: | |||
if (index >= getParameterCount()) | |||
return; | |||
CarlaPlugin* const plugin(kData->plugins[0].plugin); | |||
CarlaPlugin* const plugin(pData->plugins[0].plugin); | |||
if (plugin == nullptr || ! plugin->enabled()) | |||
if (plugin == nullptr || ! plugin->isEnabled()) | |||
return; | |||
plugin->setParameterValue(index, value, false, false, false); | |||
@@ -389,12 +389,12 @@ protected: | |||
void setMidiProgram(const uint8_t, const uint32_t bank, const uint32_t program) override | |||
{ | |||
if (kData->curPluginCount == 0 || kData->plugins == nullptr) | |||
if (pData->curPluginCount == 0 || pData->plugins == nullptr) | |||
return; | |||
CarlaPlugin* const plugin(kData->plugins[0].plugin); | |||
CarlaPlugin* const plugin(pData->plugins[0].plugin); | |||
if (plugin == nullptr || ! plugin->enabled()) | |||
if (plugin == nullptr || ! plugin->isEnabled()) | |||
return; | |||
plugin->setMidiProgramById(bank, program, false, false, false); | |||
@@ -418,11 +418,11 @@ protected: | |||
void activate() override | |||
{ | |||
for (uint32_t i=0; i < kData->curPluginCount; ++i) | |||
for (uint32_t i=0; i < pData->curPluginCount; ++i) | |||
{ | |||
CarlaPlugin* const plugin(kData->plugins[i].plugin); | |||
CarlaPlugin* const plugin(pData->plugins[i].plugin); | |||
if (plugin == nullptr || ! plugin->enabled()) | |||
if (plugin == nullptr || ! plugin->isEnabled()) | |||
continue; | |||
plugin->setActive(true, true, false); | |||
@@ -431,27 +431,27 @@ protected: | |||
void deactivate() override | |||
{ | |||
for (uint32_t i=0; i < kData->curPluginCount; ++i) | |||
for (uint32_t i=0; i < pData->curPluginCount; ++i) | |||
{ | |||
CarlaPlugin* const plugin(kData->plugins[i].plugin); | |||
CarlaPlugin* const plugin(pData->plugins[i].plugin); | |||
if (plugin == nullptr || ! plugin->enabled()) | |||
if (plugin == nullptr || ! plugin->isEnabled()) | |||
continue; | |||
plugin->setActive(false, true, false); | |||
} | |||
// just in case | |||
proccessPendingEvents(); | |||
runPendingRtEvents(); | |||
} | |||
void process(float** const inBuffer, float** const outBuffer, const uint32_t frames, const uint32_t midiEventCount, const ::MidiEvent* const midiEvents) override | |||
{ | |||
if (kData->curPluginCount == 0) | |||
if (pData->curPluginCount == 0) | |||
{ | |||
carla_zeroFloat(outBuffer[0], frames); | |||
carla_zeroFloat(outBuffer[1], frames); | |||
return proccessPendingEvents(); | |||
return runPendingRtEvents();; | |||
} | |||
// --------------------------------------------------------------- | |||
@@ -483,7 +483,7 @@ protected: | |||
// --------------------------------------------------------------- | |||
// initialize input events | |||
carla_zeroStruct<EngineEvent>(kData->bufEvents.in, INTERNAL_EVENT_COUNT); | |||
carla_zeroStruct<EngineEvent>(pData->bufEvents.in, INTERNAL_EVENT_COUNT); | |||
{ | |||
uint32_t engineEventIndex = 0; | |||
@@ -511,7 +511,7 @@ protected: | |||
if (control == MIDI_CONTROL_ALL_SOUND_OFF || control == MIDI_CONTROL_ALL_NOTES_OFF) | |||
{ | |||
EngineEvent& engineEvent(kData->bufEvents.in[engineEventIndex++]); | |||
EngineEvent& engineEvent(pData->bufEvents.in[engineEventIndex++]); | |||
engineEvent.clear(); | |||
engineEvent.type = kEngineEventTypeControl; | |||
@@ -526,7 +526,7 @@ protected: | |||
} | |||
} | |||
EngineEvent& engineEvent(kData->bufEvents.in[engineEventIndex++]); | |||
EngineEvent& engineEvent(pData->bufEvents.in[engineEventIndex++]); | |||
engineEvent.clear(); | |||
engineEvent.type = kEngineEventTypeMidi; | |||
@@ -551,7 +551,7 @@ protected: | |||
// process | |||
processRack(inBuf, outBuf, frames); | |||
proccessPendingEvents(); | |||
runPendingRtEvents(); | |||
} | |||
// ------------------------------------------------------------------- | |||
@@ -566,9 +566,9 @@ protected: | |||
else | |||
{ | |||
#if 0 | |||
for (uint32_t i=0; i < kData->curPluginCount; ++i) | |||
for (uint32_t i=0; i < pData->curPluginCount; ++i) | |||
{ | |||
CarlaPlugin* const plugin(kData->plugins[i].plugin); | |||
CarlaPlugin* const plugin(pData->plugins[i].plugin); | |||
if (plugin == nullptr || ! plugin->enabled()) | |||
continue; | |||
@@ -604,9 +604,9 @@ protected: | |||
if (index >= getParameterCount()) | |||
return; | |||
CarlaPlugin* const plugin(kData->plugins[0].plugin); | |||
CarlaPlugin* const plugin(pData->plugins[0].plugin); | |||
if (plugin == nullptr || ! plugin->enabled()) | |||
if (plugin == nullptr || ! plugin->isEnabled()) | |||
return; | |||
plugin->uiParameterChange(index, value); | |||
@@ -652,11 +652,11 @@ protected: | |||
bool firstPlugin = true; | |||
char strBuf[STR_MAX+1]; | |||
for (unsigned int i=0; i < kData->curPluginCount; ++i) | |||
for (unsigned int i=0; i < pData->curPluginCount; ++i) | |||
{ | |||
CarlaPlugin* const plugin(kData->plugins[i].plugin); | |||
CarlaPlugin* const plugin(pData->plugins[i].plugin); | |||
if (plugin != nullptr && plugin->enabled()) | |||
if (plugin != nullptr && plugin->isEnabled()) | |||
{ | |||
if (! firstPlugin) | |||
out << "\n"; | |||
@@ -666,8 +666,11 @@ protected: | |||
if (*strBuf != 0) | |||
out << QString(" <!-- %1 -->\n").arg(xmlSafeString(strBuf, true)); | |||
QString content; | |||
fillXmlStringFromSaveState(content, plugin->getSaveState()); | |||
out << " <Plugin>\n"; | |||
out << getXMLFromSaveState(plugin->getSaveState()); | |||
out << content; | |||
out << " </Plugin>\n"; | |||
firstPlugin = false; | |||
@@ -698,11 +701,10 @@ protected: | |||
{ | |||
if (node.toElement().tagName() == "Plugin") | |||
{ | |||
const SaveState& saveState(getSaveStateDictFromXML(node)); | |||
CARLA_ASSERT(saveState.type != nullptr); | |||
SaveState saveState; | |||
fillSaveStateFromXmlNode(saveState, node); | |||
if (saveState.type == nullptr) | |||
continue; | |||
CARLA_SAFE_ASSERT_CONTINUE(saveState.type != nullptr) | |||
const void* extraStuff = nullptr; | |||
@@ -713,7 +715,7 @@ protected: | |||
// TODO - proper find&load plugins | |||
if (addPlugin(getPluginTypeFromString(saveState.type), saveState.binary, saveState.name, saveState.label, extraStuff)) | |||
{ | |||
if (CarlaPlugin* plugin = getPlugin(kData->curPluginCount-1)) | |||
if (CarlaPlugin* plugin = getPlugin(pData->curPluginCount-1)) | |||
plugin->loadSaveState(saveState); | |||
} | |||
} | |||
@@ -751,7 +753,8 @@ static const PluginDescriptor carlaDesc = { | |||
PluginDescriptorFILL(CarlaEngineNative) | |||
}; | |||
void CarlaEngine::registerNativePlugin() | |||
CARLA_EXPORT | |||
void carla_register_native_plugin_carla() | |||
{ | |||
carla_register_native_plugin(&carlaDesc); | |||
} | |||
@@ -253,7 +253,7 @@ int CarlaEngineOsc::handleMessage(const bool isTCP, const char* const path, cons | |||
return 1; | |||
} | |||
if (pluginId > kEngine->currentPluginCount()) | |||
if (pluginId > kEngine->getCurrentPluginCount()) | |||
{ | |||
carla_stderr("CarlaEngineOsc::handleMessage() - failed to get plugin, wrong id '%i'", pluginId); | |||
return 1; | |||
@@ -262,7 +262,7 @@ int CarlaEngineOsc::handleMessage(const bool isTCP, const char* const path, cons | |||
// Get plugin | |||
CarlaPlugin* const plugin = kEngine->getPluginUnchecked(pluginId); | |||
if (plugin == nullptr || plugin->id() != pluginId) | |||
if (plugin == nullptr || plugin->getId() != pluginId) | |||
{ | |||
carla_stderr("CarlaEngineOsc::handleMessage() - invalid plugin id '%i', probably has been removed", pluginId); | |||
return 1; | |||
@@ -325,7 +325,7 @@ int CarlaEngineOsc::handleMessage(const bool isTCP, const char* const path, cons | |||
return handleMsgNoteOff(plugin, argc, argv, types); | |||
// Plugin Bridges | |||
if ((plugin->hints() & PLUGIN_IS_BRIDGE) > 0 && std::strlen(method) > 11 && std::strncmp(method, "bridge_", 7) == 0) | |||
if ((plugin->getHints() & PLUGIN_IS_BRIDGE) > 0 && std::strlen(method) > 11 && std::strncmp(method, "bridge_", 7) == 0) | |||
{ | |||
if (std::strcmp(method+7, "audio_count") == 0) | |||
return CarlaPluginSetOscBridgeInfo(plugin, kPluginBridgeAudioCount, argc, argv, types); | |||
@@ -416,11 +416,11 @@ int CarlaEngineOsc::handleMsgRegister(const bool isTCP, const int argc, const lo | |||
std::free(port); | |||
} | |||
for (unsigned short i=0; i < kEngine->currentPluginCount(); ++i) | |||
for (unsigned short i=0; i < kEngine->getCurrentPluginCount(); ++i) | |||
{ | |||
CarlaPlugin* const plugin = kEngine->getPluginUnchecked(i); | |||
if (plugin && plugin->enabled()) | |||
if (plugin && plugin->isEnabled()) | |||
plugin->registerToOscClient(); | |||
} | |||
@@ -516,7 +516,7 @@ int CarlaEngineOsc::handleMsgProgram(CARLA_ENGINE_OSC_HANDLE_ARGS2) | |||
if (program < 0) | |||
return 1; | |||
if (program < static_cast<int32_t>(plugin->programCount())) | |||
if (program < static_cast<int32_t>(plugin->getProgramCount())) | |||
{ | |||
plugin->setProgram(program, false, true, true); | |||
return 0; | |||
@@ -540,7 +540,7 @@ int CarlaEngineOsc::handleMsgMidi(CARLA_ENGINE_OSC_HANDLE_ARGS2) | |||
(void)plugin; | |||
(void)argv; | |||
#else | |||
if (plugin->midiInCount() == 0) | |||
if (plugin->getMidiInCount() == 0) | |||
{ | |||
carla_stderr("CarlaEngineOsc::handleMsgMidi() - recived midi when plugin has no midi inputs"); | |||
return 1; | |||
@@ -590,9 +590,10 @@ int CarlaEngineOsc::handleMsgExiting(CARLA_ENGINE_OSC_HANDLE_ARGS1) | |||
carla_debug("CarlaEngineOsc::handleMsgExiting()"); | |||
// TODO - check for non-UIs (dssi-vst) and set to -1 instead | |||
kEngine->callback(CALLBACK_SHOW_GUI, plugin->id(), 0, 0, 0.0f, nullptr); | |||
kEngine->callback(CALLBACK_SHOW_GUI, plugin->getId(), 0, 0, 0.0f, nullptr); | |||
plugin->freeOscData(); | |||
// TODO | |||
//plugin->freeOscData(); | |||
return 0; | |||
} | |||
@@ -361,17 +361,17 @@ public: | |||
return (! hasError); | |||
} | |||
bool isRunning() const override | |||
bool isRunning() const noexcept override | |||
{ | |||
return fAudio.isStreamRunning(); | |||
} | |||
bool isOffline() const override | |||
bool isOffline() const noexcept override | |||
{ | |||
return false; | |||
} | |||
EngineType type() const override | |||
EngineType getType() const noexcept override | |||
{ | |||
return kEngineTypeRtAudio; | |||
} | |||
@@ -802,12 +802,12 @@ protected: | |||
CARLA_ASSERT_INT2(nframes == fBufferSize, nframes, fBufferSize); | |||
CARLA_ASSERT(outsPtr != nullptr); | |||
if (kData->curPluginCount == 0 || fAudioCountOut == 0 || ! fAudioIsReady) | |||
if (pData->curPluginCount == 0 || fAudioCountOut == 0 || ! fAudioIsReady) | |||
{ | |||
if (fAudioCountOut > 0 && fAudioIsReady) | |||
carla_zeroFloat(outsPtr, nframes*fAudioCountOut); | |||
return proccessPendingEvents(); | |||
return runPendingRtEvents(); | |||
} | |||
// initialize audio input | |||
@@ -835,7 +835,7 @@ protected: | |||
carla_zeroFloat(fAudioBufRackOut[1], nframes); | |||
// initialize input events | |||
carla_zeroMem(kData->bufEvents.in, sizeof(EngineEvent)*INTERNAL_EVENT_COUNT); | |||
carla_zeroMem(pData->bufEvents.in, sizeof(EngineEvent)*INTERNAL_EVENT_COUNT); | |||
if (fMidiInEvents.mutex.tryLock()) | |||
{ | |||
@@ -846,7 +846,7 @@ protected: | |||
{ | |||
const RtMidiEvent& midiEvent(fMidiInEvents.data.getFirst(true)); | |||
EngineEvent& engineEvent(kData->bufEvents.in[engineEventIndex++]); | |||
EngineEvent& engineEvent(pData->bufEvents.in[engineEventIndex++]); | |||
engineEvent.clear(); | |||
const uint8_t midiStatus = MIDI_GET_STATUS_FROM_DATA(midiEvent.data); | |||
@@ -1033,7 +1033,7 @@ protected: | |||
//fMidiOutEvents... | |||
} | |||
proccessPendingEvents(); | |||
runPendingRtEvents(); | |||
return; | |||
// unused | |||
@@ -69,32 +69,32 @@ void CarlaEngineThread::stopNow() | |||
void CarlaEngineThread::run() | |||
{ | |||
carla_debug("CarlaEngineThread::run()"); | |||
CARLA_ASSERT(kEngine->isRunning()); | |||
CARLA_ASSERT(fEngine->isRunning()); | |||
bool oscRegisted, usesSingleThread; | |||
unsigned int i, count; | |||
float value; | |||
while (kEngine->isRunning() && ! fStopNow) | |||
while (fEngine->isRunning() && ! fStopNow) | |||
{ | |||
const CarlaMutex::ScopedLocker sl(fMutex); | |||
#ifdef BUILD_BRIDGE | |||
oscRegisted = kEngine->isOscBridgeRegistered(); | |||
oscRegisted = fEngine->isOscBridgeRegistered(); | |||
#else | |||
oscRegisted = kEngine->isOscControlRegistered(); | |||
oscRegisted = fEngine->isOscControlRegistered(); | |||
#endif | |||
for (i=0, count = kEngine->currentPluginCount(); i < count; ++i) | |||
for (i=0, count = fEngine->getCurrentPluginCount(); i < count; ++i) | |||
{ | |||
CarlaPlugin* const plugin = kEngine->getPluginUnchecked(i); | |||
CarlaPlugin* const plugin = fEngine->getPluginUnchecked(i); | |||
if (plugin == nullptr || ! plugin->enabled()) | |||
if (plugin == nullptr || ! plugin->isEnabled()) | |||
continue; | |||
CARLA_SAFE_ASSERT_INT2(i == plugin->id(), i, plugin->id()); | |||
CARLA_SAFE_ASSERT_INT2(i == plugin->getId(), i, plugin->getId()); | |||
usesSingleThread = (plugin->hints() & PLUGIN_HAS_SINGLE_THREAD); | |||
usesSingleThread = (plugin->getHints() & PLUGIN_HAS_SINGLE_THREAD); | |||
// ------------------------------------------------------- | |||
// Process postponed events | |||
@@ -107,9 +107,9 @@ void CarlaEngineThread::run() | |||
// --------------------------------------------------- | |||
// Update parameter outputs | |||
for (uint32_t j=0; j < plugin->parameterCount(); ++j) | |||
for (uint32_t j=0; j < plugin->getParameterCount(); ++j) | |||
{ | |||
if (! plugin->parameterIsOutput(j)) | |||
if (! plugin->isParameterOutput(j)) | |||
continue; | |||
value = plugin->getParameterValue(j); | |||
@@ -122,9 +122,9 @@ void CarlaEngineThread::run() | |||
if (oscRegisted) | |||
{ | |||
#ifdef BUILD_BRIDGE | |||
kEngine->osc_send_bridge_set_parameter_value(j, value); | |||
fEngine->oscSend_bridge_set_parameter_value(j, value); | |||
#else | |||
kEngine->osc_send_control_set_parameter_value(i, j, value); | |||
fEngine->oscSend_control_set_parameter_value(i, j, value); | |||
#endif | |||
} | |||
} | |||
@@ -134,12 +134,12 @@ void CarlaEngineThread::run() | |||
// Update OSC control client peaks | |||
if (oscRegisted) | |||
kEngine->osc_send_control_set_peaks(i); | |||
fEngine->oscSend_control_set_peaks(i); | |||
#endif | |||
} | |||
} | |||
kEngine->idleOsc(); | |||
fEngine->idleOsc(); | |||
carla_msleep(oscRegisted ? 30 : 50); | |||
} | |||
} | |||
@@ -266,7 +266,7 @@ public: | |||
{ | |||
carla_debug("BridgePlugin::BridgePlugin(%p, %i, %s, %s)", engine, id, BinaryType2Str(btype), PluginType2Str(ptype)); | |||
kData->osc.thread.setMode(CarlaPluginThread::PLUGIN_THREAD_BRIDGE); | |||
pData->osc.thread.setMode(CarlaPluginThread::PLUGIN_THREAD_BRIDGE); | |||
fHints |= PLUGIN_IS_BRIDGE; | |||
} | |||
@@ -275,38 +275,38 @@ public: | |||
{ | |||
carla_debug("BridgePlugin::~BridgePlugin()"); | |||
kData->singleMutex.lock(); | |||
kData->masterMutex.lock(); | |||
pData->singleMutex.lock(); | |||
pData->masterMutex.lock(); | |||
if (kData->client != nullptr && kData->client->isActive()) | |||
kData->client->deactivate(); | |||
if (pData->client != nullptr && pData->client->isActive()) | |||
pData->client->deactivate(); | |||
if (kData->active) | |||
if (pData->active) | |||
{ | |||
deactivate(); | |||
kData->active = false; | |||
pData->active = false; | |||
} | |||
if (kData->osc.thread.isRunning()) | |||
if (pData->osc.thread.isRunning()) | |||
{ | |||
fShmControl.writeOpcode(kPluginBridgeOpcodeQuit); | |||
fShmControl.commitWrite(); | |||
fShmControl.waitForServer(); | |||
} | |||
if (kData->osc.data.target != nullptr) | |||
if (pData->osc.data.target != nullptr) | |||
{ | |||
osc_send_hide(&kData->osc.data); | |||
osc_send_quit(&kData->osc.data); | |||
osc_send_hide(&pData->osc.data); | |||
osc_send_quit(&pData->osc.data); | |||
} | |||
kData->osc.data.free(); | |||
pData->osc.data.free(); | |||
// Wait a bit first, then force kill | |||
if (kData->osc.thread.isRunning() && ! kData->osc.thread.wait(kData->engine->getOptions().oscUiTimeout)) | |||
if (pData->osc.thread.isRunning() && ! pData->osc.thread.wait(pData->engine->getOptions().oscUiTimeout)) | |||
{ | |||
carla_stderr("Failed to properly stop Plugin Bridge thread"); | |||
kData->osc.thread.terminate(); | |||
pData->osc.thread.terminate(); | |||
} | |||
if (fNeedsSemDestroy) | |||
@@ -398,7 +398,7 @@ public: | |||
float getParameterValue(const uint32_t parameterId) override | |||
{ | |||
CARLA_ASSERT(parameterId < kData->param.count); | |||
CARLA_ASSERT(parameterId < pData->param.count); | |||
return fParams[parameterId].value; | |||
} | |||
@@ -425,14 +425,14 @@ public: | |||
void getParameterName(const uint32_t parameterId, char* const strBuf) override | |||
{ | |||
CARLA_ASSERT(parameterId < kData->param.count); | |||
CARLA_ASSERT(parameterId < pData->param.count); | |||
std::strncpy(strBuf, (const char*)fParams[parameterId].name, STR_MAX); | |||
} | |||
void getParameterUnit(const uint32_t parameterId, char* const strBuf) override | |||
{ | |||
CARLA_ASSERT(parameterId < kData->param.count); | |||
CARLA_ASSERT(parameterId < pData->param.count); | |||
std::strncpy(strBuf, (const char*)fParams[parameterId].unit, STR_MAX); | |||
} | |||
@@ -470,15 +470,15 @@ public: | |||
void setParameterValue(const uint32_t parameterId, const float value, const bool sendGui, const bool sendOsc, const bool sendCallback) override | |||
{ | |||
CARLA_ASSERT(parameterId < kData->param.count); | |||
CARLA_ASSERT(parameterId < pData->param.count); | |||
const float fixedValue(kData->param.fixValue(parameterId, value)); | |||
const float fixedValue(pData->param.fixValue(parameterId, value)); | |||
fParams[parameterId].value = fixedValue; | |||
const bool doLock(sendGui || sendOsc || sendCallback); | |||
if (doLock) | |||
kData->singleMutex.lock(); | |||
pData->singleMutex.lock(); | |||
fShmControl.writeOpcode(kPluginBridgeOpcodeSetParameter); | |||
fShmControl.writeInt(parameterId); | |||
@@ -487,7 +487,7 @@ public: | |||
if (doLock) | |||
{ | |||
fShmControl.commitWrite(); | |||
kData->singleMutex.unlock(); | |||
pData->singleMutex.unlock(); | |||
} | |||
CarlaPlugin::setParameterValue(parameterId, fixedValue, sendGui, sendOsc, sendCallback); | |||
@@ -495,17 +495,17 @@ public: | |||
void setProgram(int32_t index, const bool sendGui, const bool sendOsc, const bool sendCallback) override | |||
{ | |||
CARLA_ASSERT(index >= -1 && index < static_cast<int32_t>(kData->prog.count)); | |||
CARLA_ASSERT(index >= -1 && index < static_cast<int32_t>(pData->prog.count)); | |||
if (index < -1) | |||
index = -1; | |||
else if (index > static_cast<int32_t>(kData->prog.count)) | |||
else if (index > static_cast<int32_t>(pData->prog.count)) | |||
return; | |||
const bool doLock(sendGui || sendOsc || sendCallback); | |||
if (doLock) | |||
kData->singleMutex.lock(); | |||
pData->singleMutex.lock(); | |||
fShmControl.writeOpcode(kPluginBridgeOpcodeSetProgram); | |||
fShmControl.writeInt(index); | |||
@@ -513,7 +513,7 @@ public: | |||
if (doLock) | |||
{ | |||
fShmControl.commitWrite(); | |||
kData->singleMutex.unlock(); | |||
pData->singleMutex.unlock(); | |||
} | |||
CarlaPlugin::setProgram(index, sendGui, sendOsc, sendCallback); | |||
@@ -521,17 +521,17 @@ public: | |||
void setMidiProgram(int32_t index, const bool sendGui, const bool sendOsc, const bool sendCallback) override | |||
{ | |||
CARLA_ASSERT(index >= -1 && index < static_cast<int32_t>(kData->midiprog.count)); | |||
CARLA_ASSERT(index >= -1 && index < static_cast<int32_t>(pData->midiprog.count)); | |||
if (index < -1) | |||
index = -1; | |||
else if (index > static_cast<int32_t>(kData->midiprog.count)) | |||
else if (index > static_cast<int32_t>(pData->midiprog.count)) | |||
return; | |||
const bool doLock(sendGui || sendOsc || sendCallback); | |||
if (doLock) | |||
kData->singleMutex.lock(); | |||
pData->singleMutex.lock(); | |||
fShmControl.writeOpcode(kPluginBridgeOpcodeSetMidiProgram); | |||
fShmControl.writeInt(index); | |||
@@ -539,7 +539,7 @@ public: | |||
if (doLock) | |||
{ | |||
fShmControl.commitWrite(); | |||
kData->singleMutex.unlock(); | |||
pData->singleMutex.unlock(); | |||
} | |||
CarlaPlugin::setMidiProgram(index, sendGui, sendOsc, sendCallback); | |||
@@ -597,14 +597,14 @@ public: | |||
void showGui(const bool yesNo) override | |||
{ | |||
if (yesNo) | |||
osc_send_show(&kData->osc.data); | |||
osc_send_show(&pData->osc.data); | |||
else | |||
osc_send_hide(&kData->osc.data); | |||
osc_send_hide(&pData->osc.data); | |||
} | |||
void idleGui() override | |||
{ | |||
if (! kData->osc.thread.isRunning()) | |||
if (! pData->osc.thread.isRunning()) | |||
carla_stderr2("TESTING: Bridge has closed!"); | |||
CarlaPlugin::idleGui(); | |||
@@ -616,12 +616,12 @@ public: | |||
void reload() override | |||
{ | |||
carla_debug("BridgePlugin::reload() - start"); | |||
CARLA_ASSERT(kData->engine != nullptr); | |||
CARLA_ASSERT(pData->engine != nullptr); | |||
if (kData->engine == nullptr) | |||
if (pData->engine == nullptr) | |||
return; | |||
const ProcessMode processMode(kData->engine->getProccessMode()); | |||
const ProcessMode processMode(pData->engine->getProccessMode()); | |||
// Safely disable plugin for reload | |||
const ScopedDisabler sd(this); | |||
@@ -631,12 +631,12 @@ public: | |||
if (fInfo.aIns > 0) | |||
{ | |||
kData->audioIn.createNew(fInfo.aIns); | |||
pData->audioIn.createNew(fInfo.aIns); | |||
} | |||
if (fInfo.aOuts > 0) | |||
{ | |||
kData->audioOut.createNew(fInfo.aOuts); | |||
pData->audioOut.createNew(fInfo.aOuts); | |||
needsCtrlIn = true; | |||
} | |||
@@ -646,7 +646,7 @@ public: | |||
if (fInfo.mOuts > 0) | |||
needsCtrlOut = true; | |||
const uint portNameSize(kData->engine->maxPortNameSize()); | |||
const uint portNameSize(pData->engine->maxPortNameSize()); | |||
CarlaString portName; | |||
// Audio Ins | |||
@@ -669,8 +669,8 @@ public: | |||
portName += "input"; | |||
portName.truncate(portNameSize); | |||
kData->audioIn.ports[j].port = (CarlaEngineAudioPort*)kData->client->addPort(kEnginePortTypeAudio, portName, true); | |||
kData->audioIn.ports[j].rindex = j; | |||
pData->audioIn.ports[j].port = (CarlaEngineAudioPort*)pData->client->addPort(kEnginePortTypeAudio, portName, true); | |||
pData->audioIn.ports[j].rindex = j; | |||
} | |||
// Audio Outs | |||
@@ -693,8 +693,8 @@ public: | |||
portName += "output"; | |||
portName.truncate(portNameSize); | |||
kData->audioOut.ports[j].port = (CarlaEngineAudioPort*)kData->client->addPort(kEnginePortTypeAudio, portName, false); | |||
kData->audioOut.ports[j].rindex = j; | |||
pData->audioOut.ports[j].port = (CarlaEngineAudioPort*)pData->client->addPort(kEnginePortTypeAudio, portName, false); | |||
pData->audioOut.ports[j].rindex = j; | |||
} | |||
if (needsCtrlIn) | |||
@@ -710,7 +710,7 @@ public: | |||
portName += "event-in"; | |||
portName.truncate(portNameSize); | |||
kData->event.portIn = (CarlaEngineEventPort*)kData->client->addPort(kEnginePortTypeEvent, portName, true); | |||
pData->event.portIn = (CarlaEngineEventPort*)pData->client->addPort(kEnginePortTypeEvent, portName, true); | |||
} | |||
if (needsCtrlOut) | |||
@@ -726,10 +726,10 @@ public: | |||
portName += "event-out"; | |||
portName.truncate(portNameSize); | |||
kData->event.portOut = (CarlaEngineEventPort*)kData->client->addPort(kEnginePortTypeEvent, portName, false); | |||
pData->event.portOut = (CarlaEngineEventPort*)pData->client->addPort(kEnginePortTypeEvent, portName, false); | |||
} | |||
bufferSizeChanged(kData->engine->getBufferSize()); | |||
bufferSizeChanged(pData->engine->getBufferSize()); | |||
reloadPrograms(true); | |||
carla_debug("BridgePlugin::reload() - end"); | |||
@@ -765,10 +765,10 @@ public: | |||
// -------------------------------------------------------------------------------------------------------- | |||
// Check if active | |||
if (! kData->active) | |||
if (! pData->active) | |||
{ | |||
// disable any output sound | |||
for (i=0; i < kData->audioOut.count; ++i) | |||
for (i=0; i < pData->audioOut.count; ++i) | |||
carla_zeroFloat(outBuffer[i], frames); | |||
return; | |||
@@ -777,26 +777,26 @@ public: | |||
// -------------------------------------------------------------------------------------------------------- | |||
// Check if needs reset | |||
if (kData->needsReset) | |||
if (pData->needsReset) | |||
{ | |||
// TODO | |||
kData->needsReset = false; | |||
pData->needsReset = false; | |||
} | |||
// -------------------------------------------------------------------------------------------------------- | |||
// Event Input | |||
if (kData->event.portIn != nullptr) | |||
if (pData->event.portIn != nullptr) | |||
{ | |||
// ---------------------------------------------------------------------------------------------------- | |||
// MIDI Input (External) | |||
if (kData->extNotes.mutex.tryLock()) | |||
if (pData->extNotes.mutex.tryLock()) | |||
{ | |||
while (! kData->extNotes.data.isEmpty()) | |||
while (! pData->extNotes.data.isEmpty()) | |||
{ | |||
const ExternalMidiNote& note(kData->extNotes.data.getFirst(true)); | |||
const ExternalMidiNote& note(pData->extNotes.data.getFirst(true)); | |||
CARLA_ASSERT(note.channel >= 0 && note.channel < MAX_MIDI_CHANNELS); | |||
@@ -814,7 +814,7 @@ public: | |||
fShmControl.writeChar(data3); | |||
} | |||
kData->extNotes.mutex.unlock(); | |||
pData->extNotes.mutex.unlock(); | |||
} // End of MIDI Input (External) | |||
@@ -823,15 +823,15 @@ public: | |||
bool allNotesOffSent = false; | |||
uint32_t nEvents = kData->event.portIn->getEventCount(); | |||
uint32_t nEvents = pData->event.portIn->getEventCount(); | |||
uint32_t nextBankId = 0; | |||
if (kData->midiprog.current >= 0 && kData->midiprog.count > 0) | |||
nextBankId = kData->midiprog.data[kData->midiprog.current].bank; | |||
if (pData->midiprog.current >= 0 && pData->midiprog.count > 0) | |||
nextBankId = pData->midiprog.data[pData->midiprog.current].bank; | |||
for (i=0; i < nEvents; ++i) | |||
{ | |||
const EngineEvent& event(kData->event.portIn->getEvent(i)); | |||
const EngineEvent& event(pData->event.portIn->getEvent(i)); | |||
// Control change | |||
switch (event.type) | |||
@@ -851,7 +851,7 @@ public: | |||
case kEngineControlEventTypeParameter: | |||
{ | |||
// Control backend stuff | |||
if (event.channel == kData->ctrlChannel) | |||
if (event.channel == pData->ctrlChannel) | |||
{ | |||
float value; | |||
@@ -898,28 +898,28 @@ public: | |||
} | |||
// Control plugin parameters | |||
for (k=0; k < kData->param.count; ++k) | |||
for (k=0; k < pData->param.count; ++k) | |||
{ | |||
if (kData->param.data[k].midiChannel != event.channel) | |||
if (pData->param.data[k].midiChannel != event.channel) | |||
continue; | |||
if (kData->param.data[k].midiCC != ctrlEvent.param) | |||
if (pData->param.data[k].midiCC != ctrlEvent.param) | |||
continue; | |||
if (kData->param.data[k].type != PARAMETER_INPUT) | |||
if (pData->param.data[k].type != PARAMETER_INPUT) | |||
continue; | |||
if ((kData->param.data[k].hints & PARAMETER_IS_AUTOMABLE) == 0) | |||
if ((pData->param.data[k].hints & PARAMETER_IS_AUTOMABLE) == 0) | |||
continue; | |||
float value; | |||
if (kData->param.data[k].hints & PARAMETER_IS_BOOLEAN) | |||
if (pData->param.data[k].hints & PARAMETER_IS_BOOLEAN) | |||
{ | |||
value = (ctrlEvent.value < 0.5f) ? kData->param.ranges[k].min : kData->param.ranges[k].max; | |||
value = (ctrlEvent.value < 0.5f) ? pData->param.ranges[k].min : pData->param.ranges[k].max; | |||
} | |||
else | |||
{ | |||
value = kData->param.ranges[k].unnormalizeValue(ctrlEvent.value); | |||
value = pData->param.ranges[k].unnormalizeValue(ctrlEvent.value); | |||
if (kData->param.data[k].hints & PARAMETER_IS_INTEGER) | |||
if (pData->param.data[k].hints & PARAMETER_IS_INTEGER) | |||
value = std::rint(value); | |||
} | |||
@@ -941,20 +941,20 @@ public: | |||
} | |||
case kEngineControlEventTypeMidiBank: | |||
if (event.channel == kData->ctrlChannel && (fOptions & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0) | |||
if (event.channel == pData->ctrlChannel && (fOptions & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0) | |||
nextBankId = ctrlEvent.param; | |||
break; | |||
case kEngineControlEventTypeMidiProgram: | |||
if (event.channel == kData->ctrlChannel && (fOptions & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0) | |||
if (event.channel == pData->ctrlChannel && (fOptions & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0) | |||
{ | |||
const uint32_t nextProgramId(ctrlEvent.param); | |||
if (kData->midiprog.count > 0) | |||
if (pData->midiprog.count > 0) | |||
{ | |||
for (k=0; k < kData->midiprog.count; ++k) | |||
for (k=0; k < pData->midiprog.count; ++k) | |||
{ | |||
if (kData->midiprog.data[k].bank == nextBankId && kData->midiprog.data[k].program == nextProgramId) | |||
if (pData->midiprog.data[k].bank == nextBankId && pData->midiprog.data[k].program == nextProgramId) | |||
{ | |||
setMidiProgram(k, false, false, false); | |||
postponeRtEvent(kPluginPostRtEventMidiProgramChange, k, 0, 0.0f); | |||
@@ -978,7 +978,7 @@ public: | |||
case kEngineControlEventTypeAllNotesOff: | |||
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF) | |||
{ | |||
if (event.channel == kData->ctrlChannel && ! allNotesOffSent) | |||
if (event.channel == pData->ctrlChannel && ! allNotesOffSent) | |||
{ | |||
allNotesOffSent = true; | |||
sendMidiAllNotesOffToCallback(); | |||
@@ -1035,7 +1035,7 @@ public: | |||
} | |||
} | |||
kData->postRtEvents.trySplice(); | |||
pData->postRtEvents.trySplice(); | |||
} // End of Event Input | |||
@@ -1049,13 +1049,13 @@ public: | |||
if (frames == 0) | |||
return false; | |||
if (kData->audioIn.count > 0) | |||
if (pData->audioIn.count > 0) | |||
{ | |||
CARLA_ASSERT(inBuffer != nullptr); | |||
if (inBuffer == nullptr) | |||
return false; | |||
} | |||
if (kData->audioOut.count > 0) | |||
if (pData->audioOut.count > 0) | |||
{ | |||
CARLA_ASSERT(outBuffer != nullptr); | |||
if (outBuffer == nullptr) | |||
@@ -1067,13 +1067,13 @@ public: | |||
// -------------------------------------------------------------------------------------------------------- | |||
// Try lock, silence otherwise | |||
if (kData->engine->isOffline()) | |||
if (pData->engine->isOffline()) | |||
{ | |||
kData->singleMutex.lock(); | |||
pData->singleMutex.lock(); | |||
} | |||
else if (! kData->singleMutex.tryLock()) | |||
else if (! pData->singleMutex.tryLock()) | |||
{ | |||
for (i=0; i < kData->audioOut.count; ++i) | |||
for (i=0; i < pData->audioOut.count; ++i) | |||
carla_zeroFloat(outBuffer[i], frames); | |||
return false; | |||
@@ -1093,7 +1093,7 @@ public: | |||
if (! waitForServer()) | |||
{ | |||
kData->singleMutex.unlock(); | |||
pData->singleMutex.unlock(); | |||
return true; | |||
} | |||
@@ -1104,22 +1104,22 @@ public: | |||
// Post-processing (dry/wet, volume and balance) | |||
{ | |||
const bool doVolume = (fHints & PLUGIN_CAN_VOLUME) != 0 && kData->postProc.volume != 1.0f; | |||
const bool doDryWet = (fHints & PLUGIN_CAN_DRYWET) != 0 && kData->postProc.dryWet != 1.0f; | |||
const bool doBalance = (fHints & PLUGIN_CAN_BALANCE) != 0 && (kData->postProc.balanceLeft != -1.0f || kData->postProc.balanceRight != 1.0f); | |||
const bool doVolume = (fHints & PLUGIN_CAN_VOLUME) != 0 && pData->postProc.volume != 1.0f; | |||
const bool doDryWet = (fHints & PLUGIN_CAN_DRYWET) != 0 && pData->postProc.dryWet != 1.0f; | |||
const bool doBalance = (fHints & PLUGIN_CAN_BALANCE) != 0 && (pData->postProc.balanceLeft != -1.0f || pData->postProc.balanceRight != 1.0f); | |||
bool isPair; | |||
float bufValue, oldBufLeft[doBalance ? frames : 1]; | |||
for (i=0; i < kData->audioOut.count; ++i) | |||
for (i=0; i < pData->audioOut.count; ++i) | |||
{ | |||
// Dry/Wet | |||
if (doDryWet) | |||
{ | |||
for (k=0; k < frames; ++k) | |||
{ | |||
bufValue = inBuffer[(kData->audioIn.count == 1) ? 0 : i][k]; | |||
outBuffer[i][k] = (outBuffer[i][k] * kData->postProc.dryWet) + (bufValue * (1.0f - kData->postProc.dryWet)); | |||
bufValue = inBuffer[(pData->audioIn.count == 1) ? 0 : i][k]; | |||
outBuffer[i][k] = (outBuffer[i][k] * pData->postProc.dryWet) + (bufValue * (1.0f - pData->postProc.dryWet)); | |||
} | |||
} | |||
@@ -1130,12 +1130,12 @@ public: | |||
if (isPair) | |||
{ | |||
CARLA_ASSERT(i+1 < kData->audioOut.count); | |||
CARLA_ASSERT(i+1 < pData->audioOut.count); | |||
carla_copyFloat(oldBufLeft, outBuffer[i], frames); | |||
} | |||
float balRangeL = (kData->postProc.balanceLeft + 1.0f)/2.0f; | |||
float balRangeR = (kData->postProc.balanceRight + 1.0f)/2.0f; | |||
float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f; | |||
float balRangeR = (pData->postProc.balanceRight + 1.0f)/2.0f; | |||
for (k=0; k < frames; ++k) | |||
{ | |||
@@ -1158,7 +1158,7 @@ public: | |||
if (doVolume) | |||
{ | |||
for (k=0; k < frames; ++k) | |||
outBuffer[i][k] *= kData->postProc.volume; | |||
outBuffer[i][k] *= pData->postProc.volume; | |||
} | |||
} | |||
@@ -1166,7 +1166,7 @@ public: | |||
// -------------------------------------------------------------------------------------------------------- | |||
kData->singleMutex.unlock(); | |||
pData->singleMutex.unlock(); | |||
return true; | |||
} | |||
@@ -1269,7 +1269,7 @@ public: | |||
CARLA_ASSERT(pIns + pOuts <= pTotal); | |||
// delete old data | |||
kData->param.clear(); | |||
pData->param.clear(); | |||
if (fParams != nullptr) | |||
{ | |||
@@ -1277,13 +1277,13 @@ public: | |||
fParams = nullptr; | |||
} | |||
CARLA_SAFE_ASSERT_INT2(pTotal < static_cast<int32_t>(kData->engine->getOptions().maxParameters), pTotal, kData->engine->getOptions().maxParameters); | |||
CARLA_SAFE_ASSERT_INT2(pTotal < static_cast<int32_t>(pData->engine->getOptions().maxParameters), pTotal, pData->engine->getOptions().maxParameters); | |||
const int32_t count(carla_min<int32_t>(pTotal, kData->engine->getOptions().maxParameters, 0)); | |||
const int32_t count(carla_min<int32_t>(pTotal, pData->engine->getOptions().maxParameters, 0)); | |||
if (count > 0) | |||
{ | |||
kData->param.createNew(count); | |||
pData->param.createNew(count); | |||
fParams = new BridgeParamInfo[count]; | |||
} | |||
@@ -1302,10 +1302,10 @@ public: | |||
CARLA_ASSERT(count >= 0); | |||
kData->prog.clear(); | |||
pData->prog.clear(); | |||
if (count > 0) | |||
kData->prog.createNew(count); | |||
pData->prog.createNew(count); | |||
break; | |||
} | |||
@@ -1318,10 +1318,10 @@ public: | |||
CARLA_ASSERT(count >= 0); | |||
kData->midiprog.clear(); | |||
pData->midiprog.clear(); | |||
if (count > 0) | |||
kData->midiprog.createNew(count); | |||
pData->midiprog.createNew(count); | |||
break; | |||
} | |||
@@ -1369,11 +1369,11 @@ public: | |||
const char* const name = (const char*)&argv[1]->s; | |||
const char* const unit = (const char*)&argv[2]->s; | |||
CARLA_ASSERT_INT2(index >= 0 && index < static_cast<int32_t>(kData->param.count), index, kData->param.count); | |||
CARLA_ASSERT_INT2(index >= 0 && index < static_cast<int32_t>(pData->param.count), index, pData->param.count); | |||
CARLA_ASSERT(name != nullptr); | |||
CARLA_ASSERT(unit != nullptr); | |||
if (index >= 0 && static_cast<int32_t>(kData->param.count)) | |||
if (index >= 0 && static_cast<int32_t>(pData->param.count)) | |||
{ | |||
fParams[index].name = name; | |||
fParams[index].unit = unit; | |||
@@ -1393,21 +1393,21 @@ public: | |||
const int32_t channel = argv[4]->i; | |||
const int32_t cc = argv[5]->i; | |||
CARLA_ASSERT_INT2(index >= 0 && index < static_cast<int32_t>(kData->param.count), index, kData->param.count); | |||
CARLA_ASSERT_INT2(index >= 0 && index < static_cast<int32_t>(pData->param.count), index, pData->param.count); | |||
CARLA_ASSERT(type >= 0); | |||
CARLA_ASSERT(rindex >= 0); | |||
CARLA_ASSERT(hints >= 0); | |||
CARLA_ASSERT(channel >= 0 && channel < 16); | |||
CARLA_ASSERT(cc >= -1); | |||
if (index >= 0 && static_cast<int32_t>(kData->param.count)) | |||
if (index >= 0 && static_cast<int32_t>(pData->param.count)) | |||
{ | |||
kData->param.data[index].type = static_cast<ParameterType>(type); | |||
kData->param.data[index].index = index; | |||
kData->param.data[index].rindex = rindex; | |||
kData->param.data[index].hints = hints; | |||
kData->param.data[index].midiChannel = channel; | |||
kData->param.data[index].midiCC = cc; | |||
pData->param.data[index].type = static_cast<ParameterType>(type); | |||
pData->param.data[index].index = index; | |||
pData->param.data[index].rindex = rindex; | |||
pData->param.data[index].hints = hints; | |||
pData->param.data[index].midiChannel = channel; | |||
pData->param.data[index].midiCC = cc; | |||
} | |||
break; | |||
@@ -1425,19 +1425,19 @@ public: | |||
const float stepSmall = argv[5]->f; | |||
const float stepLarge = argv[6]->f; | |||
CARLA_ASSERT_INT2(index >= 0 && index < static_cast<int32_t>(kData->param.count), index, kData->param.count); | |||
CARLA_ASSERT_INT2(index >= 0 && index < static_cast<int32_t>(pData->param.count), index, pData->param.count); | |||
CARLA_ASSERT(min < max); | |||
CARLA_ASSERT(def >= min); | |||
CARLA_ASSERT(def <= max); | |||
if (index >= 0 && static_cast<int32_t>(kData->param.count)) | |||
if (index >= 0 && static_cast<int32_t>(pData->param.count)) | |||
{ | |||
kData->param.ranges[index].def = def; | |||
kData->param.ranges[index].min = min; | |||
kData->param.ranges[index].max = max; | |||
kData->param.ranges[index].step = step; | |||
kData->param.ranges[index].stepSmall = stepSmall; | |||
kData->param.ranges[index].stepLarge = stepLarge; | |||
pData->param.ranges[index].def = def; | |||
pData->param.ranges[index].min = min; | |||
pData->param.ranges[index].max = max; | |||
pData->param.ranges[index].step = step; | |||
pData->param.ranges[index].stepSmall = stepSmall; | |||
pData->param.ranges[index].stepLarge = stepLarge; | |||
} | |||
break; | |||
@@ -1450,15 +1450,15 @@ public: | |||
const int32_t index = argv[0]->i; | |||
const char* const name = (const char*)&argv[1]->s; | |||
CARLA_ASSERT_INT2(index >= 0 && index < static_cast<int32_t>(kData->prog.count), index, kData->prog.count); | |||
CARLA_ASSERT_INT2(index >= 0 && index < static_cast<int32_t>(pData->prog.count), index, pData->prog.count); | |||
CARLA_ASSERT(name != nullptr); | |||
if (index >= 0 && index < static_cast<int32_t>(kData->prog.count)) | |||
if (index >= 0 && index < static_cast<int32_t>(pData->prog.count)) | |||
{ | |||
if (kData->prog.names[index] != nullptr) | |||
delete[] kData->prog.names[index]; | |||
if (pData->prog.names[index] != nullptr) | |||
delete[] pData->prog.names[index]; | |||
kData->prog.names[index] = carla_strdup(name); | |||
pData->prog.names[index] = carla_strdup(name); | |||
} | |||
break; | |||
@@ -1473,19 +1473,19 @@ public: | |||
const int32_t program = argv[2]->i; | |||
const char* const name = (const char*)&argv[3]->s; | |||
CARLA_ASSERT_INT2(index < static_cast<int32_t>(kData->midiprog.count), index, kData->midiprog.count); | |||
CARLA_ASSERT_INT2(index < static_cast<int32_t>(pData->midiprog.count), index, pData->midiprog.count); | |||
CARLA_ASSERT(bank >= 0); | |||
CARLA_ASSERT(program >= 0 && program < 128); | |||
CARLA_ASSERT(name != nullptr); | |||
if (index >= 0 && index < static_cast<int32_t>(kData->midiprog.count)) | |||
if (index >= 0 && index < static_cast<int32_t>(pData->midiprog.count)) | |||
{ | |||
if (kData->midiprog.data[index].name != nullptr) | |||
delete[] kData->midiprog.data[index].name; | |||
if (pData->midiprog.data[index].name != nullptr) | |||
delete[] pData->midiprog.data[index].name; | |||
kData->midiprog.data[index].bank = bank; | |||
kData->midiprog.data[index].program = program; | |||
kData->midiprog.data[index].name = carla_strdup(name); | |||
pData->midiprog.data[index].bank = bank; | |||
pData->midiprog.data[index].program = program; | |||
pData->midiprog.data[index].name = carla_strdup(name); | |||
} | |||
break; | |||
@@ -1505,7 +1505,7 @@ public: | |||
break; | |||
if (std::strcmp(key, CARLA_BRIDGE_MSG_HIDE_GUI) == 0) | |||
kData->engine->callback(CALLBACK_SHOW_GUI, fId, 0, 0, 0.0f, nullptr); | |||
pData->engine->callback(CALLBACK_SHOW_GUI, fId, 0, 0, 0.0f, nullptr); | |||
else if (std::strcmp(key, CARLA_BRIDGE_MSG_SAVED) == 0) | |||
fSaved = true; | |||
@@ -1519,11 +1519,11 @@ public: | |||
const int32_t index = argv[0]->i; | |||
const float value = argv[1]->f; | |||
CARLA_ASSERT_INT2(index >= 0 && index < static_cast<int32_t>(kData->param.count), index, kData->param.count); | |||
CARLA_ASSERT_INT2(index >= 0 && index < static_cast<int32_t>(pData->param.count), index, pData->param.count); | |||
if (index >= 0 && static_cast<int32_t>(kData->param.count)) | |||
if (index >= 0 && static_cast<int32_t>(pData->param.count)) | |||
{ | |||
const float fixedValue(kData->param.fixValue(index, value)); | |||
const float fixedValue(pData->param.fixValue(index, value)); | |||
fParams[index].value = fixedValue; | |||
CarlaPlugin::setParameterValue(index, fixedValue, false, true, true); | |||
@@ -1539,10 +1539,10 @@ public: | |||
const int32_t index = argv[0]->i; | |||
const float value = argv[1]->f; | |||
CARLA_ASSERT_INT2(index >= 0 && index < static_cast<int32_t>(kData->param.count), index, kData->param.count); | |||
CARLA_ASSERT_INT2(index >= 0 && index < static_cast<int32_t>(pData->param.count), index, pData->param.count); | |||
if (index >= 0 && static_cast<int32_t>(kData->param.count)) | |||
kData->param.ranges[index].def = value; | |||
if (index >= 0 && static_cast<int32_t>(pData->param.count)) | |||
pData->param.ranges[index].def = value; | |||
break; | |||
} | |||
@@ -1553,7 +1553,7 @@ public: | |||
const int32_t index = argv[0]->i; | |||
CARLA_ASSERT_INT2(index >= 0 && index < static_cast<int32_t>(kData->prog.count), index, kData->prog.count); | |||
CARLA_ASSERT_INT2(index >= 0 && index < static_cast<int32_t>(pData->prog.count), index, pData->prog.count); | |||
setProgram(index, false, true, true); | |||
@@ -1566,7 +1566,7 @@ public: | |||
const int32_t index = argv[0]->i; | |||
CARLA_ASSERT_INT2(index < static_cast<int32_t>(kData->midiprog.count), index, kData->midiprog.count); | |||
CARLA_ASSERT_INT2(index < static_cast<int32_t>(pData->midiprog.count), index, pData->midiprog.count); | |||
setMidiProgram(index, false, true, true); | |||
@@ -1655,7 +1655,7 @@ public: | |||
CARLA_ASSERT(error != nullptr); | |||
kData->engine->setLastError(error); | |||
pData->engine->setLastError(error); | |||
fInitError = true; | |||
fInitiated = true; | |||
@@ -1675,20 +1675,20 @@ public: | |||
bool init(const char* const filename, const char* const name, const char* const label, const char* const bridgeBinary) | |||
{ | |||
CARLA_ASSERT(kData->engine != nullptr); | |||
CARLA_ASSERT(kData->client == nullptr); | |||
CARLA_ASSERT(pData->engine != nullptr); | |||
CARLA_ASSERT(pData->client == nullptr); | |||
// --------------------------------------------------------------- | |||
// first checks | |||
if (kData->engine == nullptr) | |||
if (pData->engine == nullptr) | |||
{ | |||
return false; | |||
} | |||
if (kData->client != nullptr) | |||
if (pData->client != nullptr) | |||
{ | |||
kData->engine->setLastError("Plugin client is already registered"); | |||
pData->engine->setLastError("Plugin client is already registered"); | |||
return false; | |||
} | |||
@@ -1696,7 +1696,7 @@ public: | |||
// set info | |||
if (name != nullptr) | |||
fName = kData->engine->getUniquePluginName(name); | |||
fName = pData->engine->getUniquePluginName(name); | |||
fFilename = filename; | |||
fBridgeBinary = bridgeBinary; | |||
@@ -1776,16 +1776,16 @@ public: | |||
// initial values | |||
fShmControl.writeOpcode(kPluginBridgeOpcodeSetBufferSize); | |||
fShmControl.writeInt(kData->engine->getBufferSize()); | |||
fShmControl.writeInt(pData->engine->getBufferSize()); | |||
fShmControl.writeOpcode(kPluginBridgeOpcodeSetSampleRate); | |||
fShmControl.writeFloat(kData->engine->getSampleRate()); | |||
fShmControl.writeFloat(pData->engine->getSampleRate()); | |||
fShmControl.commitWrite(); | |||
// register plugin now so we can receive OSC (and wait for it) | |||
fHints |= PLUGIN_IS_BRIDGE; | |||
registerEnginePlugin(kData->engine, fId, this); | |||
registerEnginePlugin(pData->engine, fId, this); | |||
// init OSC | |||
{ | |||
@@ -1793,13 +1793,13 @@ public: | |||
std::strncpy(shmIdStr, &fShmAudioPool.filename[fShmAudioPool.filename.length()-6], 6); | |||
std::strncat(shmIdStr, &fShmControl.filename[fShmControl.filename.length()-6], 6); | |||
kData->osc.thread.setOscData(bridgeBinary, label, getPluginTypeAsString(fPluginType), shmIdStr); | |||
kData->osc.thread.start(); | |||
pData->osc.thread.setOscData(bridgeBinary, label, getPluginTypeAsString(fPluginType), shmIdStr); | |||
pData->osc.thread.start(); | |||
} | |||
for (int i=0; i < 200; ++i) | |||
{ | |||
if (fInitiated || ! kData->osc.thread.isRunning()) | |||
if (fInitiated || ! pData->osc.thread.isRunning()) | |||
break; | |||
carla_msleep(50); | |||
} | |||
@@ -1807,15 +1807,15 @@ public: | |||
if (fInitError || ! fInitiated) | |||
{ | |||
// unregister so it gets handled properly | |||
registerEnginePlugin(kData->engine, fId, nullptr); | |||
registerEnginePlugin(pData->engine, fId, nullptr); | |||
kData->osc.thread.quit(); | |||
pData->osc.thread.quit(); | |||
if (kData->osc.thread.isRunning()) | |||
kData->osc.thread.terminate(); | |||
if (pData->osc.thread.isRunning()) | |||
pData->osc.thread.terminate(); | |||
if (! fInitError) | |||
kData->engine->setLastError("Timeout while waiting for a response from plugin-bridge\n(or the plugin crashed on initialization?)"); | |||
pData->engine->setLastError("Timeout while waiting for a response from plugin-bridge\n(or the plugin crashed on initialization?)"); | |||
return false; | |||
} | |||
@@ -1826,18 +1826,18 @@ public: | |||
if (fName.isEmpty()) | |||
{ | |||
if (name != nullptr) | |||
fName = kData->engine->getUniquePluginName(name); | |||
fName = pData->engine->getUniquePluginName(name); | |||
else if (label != nullptr) | |||
fName = kData->engine->getUniquePluginName(label); | |||
fName = pData->engine->getUniquePluginName(label); | |||
else | |||
fName = kData->engine->getUniquePluginName("unknown"); | |||
fName = pData->engine->getUniquePluginName("unknown"); | |||
} | |||
kData->client = kData->engine->addClient(this); | |||
pData->client = pData->engine->addClient(this); | |||
if (kData->client == nullptr || ! kData->client->isOk()) | |||
if (pData->client == nullptr || ! pData->client->isOk()) | |||
{ | |||
kData->engine->setLastError("Failed to register plugin client"); | |||
pData->engine->setLastError("Failed to register plugin client"); | |||
return false; | |||
} | |||
@@ -1896,7 +1896,7 @@ private: | |||
if (! fShmControl.waitForServer()) | |||
{ | |||
carla_stderr("waitForServer() timeout"); | |||
kData->active = false; // TODO | |||
pData->active = false; // TODO | |||
return false; | |||
} | |||
@@ -117,8 +117,8 @@ public: | |||
private: | |||
struct Lib { | |||
void* const lib; | |||
const char* const filename; | |||
void* lib; | |||
const char* filename; | |||
int count; | |||
#ifndef CARLA_PROPER_CPP11_SUPPORT | |||
@@ -256,29 +256,6 @@ unsigned int CarlaPluginProtectedData::loadSettings(const unsigned int options, | |||
return newOptions; | |||
} | |||
// ------------------------------------------------------------------- | |||
// Plugin Helpers | |||
CarlaEngine* CarlaPluginGetEngine(CarlaPlugin* const plugin) | |||
{ | |||
return CarlaPluginProtectedData::getEngine(plugin); | |||
} | |||
CarlaEngineClient* CarlaPluginGetEngineClient(CarlaPlugin* const plugin) | |||
{ | |||
return CarlaPluginProtectedData::getEngineClient(plugin); | |||
} | |||
CarlaEngineAudioPort* CarlaPluginGetAudioInPort(CarlaPlugin* const plugin, const uint32_t index) | |||
{ | |||
return CarlaPluginProtectedData::getAudioInPort(plugin, index); | |||
} | |||
CarlaEngineAudioPort* CarlaPluginGetAudioOutPort(CarlaPlugin* const plugin, const uint32_t index) | |||
{ | |||
return CarlaPluginProtectedData::getAudioOutPort(plugin, index); | |||
} | |||
// ------------------------------------------------------------------- | |||
// Constructor and destructor | |||
@@ -290,10 +267,10 @@ CarlaPlugin::CarlaPlugin(CarlaEngine* const engine, const unsigned int id) | |||
fIconName("plugin"), | |||
pData(new CarlaPluginProtectedData(engine, this)) | |||
{ | |||
CARLA_ASSERT(kData != nullptr); | |||
CARLA_ASSERT(pData != nullptr); | |||
CARLA_ASSERT(engine != nullptr); | |||
CARLA_ASSERT(id < engine->maxPluginNumber()); | |||
CARLA_ASSERT(id == engine->currentPluginCount()); | |||
CARLA_ASSERT(id < engine->getMaxPluginNumber()); | |||
CARLA_ASSERT(id == engine->getCurrentPluginCount()); | |||
carla_debug("CarlaPlugin::CarlaPlugin(%p, %i)", engine, id); | |||
switch (engine->getProccessMode()) | |||
@@ -454,7 +431,7 @@ unsigned int CarlaPlugin::getAvailableOptions() const | |||
float CarlaPlugin::getParameterValue(const uint32_t parameterId) const | |||
{ | |||
CARLA_ASSERT(parameterId < parameterCount()); | |||
CARLA_ASSERT(parameterId < getParameterCount()); | |||
CARLA_ASSERT(false); // this should never happen | |||
return 0.0f; | |||
@@ -464,8 +441,8 @@ float CarlaPlugin::getParameterValue(const uint32_t parameterId) const | |||
float CarlaPlugin::getParameterScalePointValue(const uint32_t parameterId, const uint32_t scalePointId) const | |||
{ | |||
CARLA_ASSERT(parameterId < parameterCount()); | |||
CARLA_ASSERT(scalePointId < parameterScalePointCount(parameterId)); | |||
CARLA_ASSERT(parameterId < getParameterCount()); | |||
CARLA_ASSERT(scalePointId < getParameterScalePointCount(parameterId)); | |||
CARLA_ASSERT(false); // this should never happen | |||
return 0.0f; | |||
@@ -496,7 +473,7 @@ void CarlaPlugin::getRealName(char* const strBuf) const noexcept | |||
void CarlaPlugin::getParameterName(const uint32_t parameterId, char* const strBuf) const | |||
{ | |||
CARLA_ASSERT(parameterId < parameterCount()); | |||
CARLA_ASSERT(parameterId < getParameterCount()); | |||
CARLA_ASSERT(false); // this should never happen | |||
*strBuf = '\0'; | |||
return; | |||
@@ -507,7 +484,7 @@ void CarlaPlugin::getParameterName(const uint32_t parameterId, char* const strBu | |||
void CarlaPlugin::getParameterSymbol(const uint32_t parameterId, char* const strBuf) const | |||
{ | |||
CARLA_ASSERT(parameterId < parameterCount()); | |||
CARLA_ASSERT(parameterId < getParameterCount()); | |||
*strBuf = '\0'; | |||
return; | |||
@@ -517,7 +494,7 @@ void CarlaPlugin::getParameterSymbol(const uint32_t parameterId, char* const str | |||
void CarlaPlugin::getParameterText(const uint32_t parameterId, char* const strBuf) const | |||
{ | |||
CARLA_ASSERT(parameterId < parameterCount()); | |||
CARLA_ASSERT(parameterId < getParameterCount()); | |||
CARLA_ASSERT(false); // this should never happen | |||
*strBuf = '\0'; | |||
return; | |||
@@ -528,7 +505,7 @@ void CarlaPlugin::getParameterText(const uint32_t parameterId, char* const strBu | |||
void CarlaPlugin::getParameterUnit(const uint32_t parameterId, char* const strBuf) const | |||
{ | |||
CARLA_ASSERT(parameterId < parameterCount()); | |||
CARLA_ASSERT(parameterId < getParameterCount()); | |||
*strBuf = '\0'; | |||
return; | |||
@@ -538,8 +515,8 @@ void CarlaPlugin::getParameterUnit(const uint32_t parameterId, char* const strBu | |||
void CarlaPlugin::getParameterScalePointLabel(const uint32_t parameterId, const uint32_t scalePointId, char* const strBuf) const | |||
{ | |||
CARLA_ASSERT(parameterId < parameterCount()); | |||
CARLA_ASSERT(scalePointId < parameterScalePointCount(parameterId)); | |||
CARLA_ASSERT(parameterId < getParameterCount()); | |||
CARLA_ASSERT(scalePointId < getParameterScalePointCount(parameterId)); | |||
CARLA_ASSERT(false); // this should never happen | |||
*strBuf = '\0'; | |||
return; | |||
@@ -611,7 +588,7 @@ const SaveState& CarlaPlugin::getSaveState() | |||
// ---------------------------- | |||
// Basic info | |||
switch (type()) | |||
switch (getType()) | |||
{ | |||
case PLUGIN_NONE: | |||
saveState.type = carla_strdup("None"); | |||
@@ -634,6 +611,9 @@ const SaveState& CarlaPlugin::getSaveState() | |||
case PLUGIN_VST3: | |||
saveState.type = carla_strdup("VST3"); | |||
break; | |||
case PLUGIN_AU: | |||
saveState.type = carla_strdup("AU"); | |||
break; | |||
case PLUGIN_GIG: | |||
saveState.type = carla_strdup("GIG"); | |||
break; | |||
@@ -650,7 +630,7 @@ const SaveState& CarlaPlugin::getSaveState() | |||
saveState.name = carla_strdup(fName); | |||
saveState.label = carla_strdup(strBuf); | |||
saveState.binary = carla_strdup(fFilename); | |||
saveState.uniqueID = uniqueId(); | |||
saveState.uniqueID = getUniqueId(); | |||
// ---------------------------- | |||
// Internals | |||
@@ -672,7 +652,7 @@ const SaveState& CarlaPlugin::getSaveState() | |||
if (fOptions & PLUGIN_OPTION_USE_CHUNKS) | |||
{ | |||
void* data = nullptr; | |||
const int32_t dataSize(chunkData(&data)); | |||
const int32_t dataSize(getChunkData(&data)); | |||
if (data != nullptr && dataSize > 0) | |||
{ | |||
@@ -785,7 +765,7 @@ struct ParamSymbol { | |||
void CarlaPlugin::loadSaveState(const SaveState& saveState) | |||
{ | |||
char strBuf[STR_MAX+1]; | |||
const bool usesMultiProgs(type() == PLUGIN_SF2 || (type() == PLUGIN_INTERNAL && (fHints & PLUGIN_IS_SYNTH) != 0)); | |||
const bool usesMultiProgs(getType() == PLUGIN_SF2 || (getType() == PLUGIN_INTERNAL && (fHints & PLUGIN_IS_SYNTH) != 0)); | |||
// --------------------------------------------------------------------- | |||
// Part 1 - PRE-set custom data (only that which reload programs) | |||
@@ -797,7 +777,7 @@ void CarlaPlugin::loadSaveState(const SaveState& saveState) | |||
bool wantData = false; | |||
if (type() == PLUGIN_DSSI && (std::strcmp(key, "reloadprograms") == 0 || std::strcmp(key, "load") == 0 || std::strncmp(key, "patches", 7) == 0)) | |||
if (getType() == PLUGIN_DSSI && (std::strcmp(key, "reloadprograms") == 0 || std::strcmp(key, "load") == 0 || std::strncmp(key, "patches", 7) == 0)) | |||
wantData = true; | |||
else if (usesMultiProgs && std::strcmp(key, "midiPrograms") == 0) | |||
wantData = true; | |||
@@ -856,7 +836,7 @@ void CarlaPlugin::loadSaveState(const SaveState& saveState) | |||
NonRtList<ParamSymbol*> paramSymbols; | |||
if (type() == PLUGIN_LADSPA || type() == PLUGIN_LV2) | |||
if (getType() == PLUGIN_LADSPA || getType() == PLUGIN_LV2) | |||
{ | |||
for (uint32_t i=0; i < pData->param.count; ++i) | |||
{ | |||
@@ -881,7 +861,7 @@ void CarlaPlugin::loadSaveState(const SaveState& saveState) | |||
int32_t index = -1; | |||
if (type() == PLUGIN_LADSPA) | |||
if (getType() == PLUGIN_LADSPA) | |||
{ | |||
// Try to set by symbol, otherwise use index | |||
if (stateParameter->symbol != nullptr && *stateParameter->symbol != 0) | |||
@@ -902,7 +882,7 @@ void CarlaPlugin::loadSaveState(const SaveState& saveState) | |||
else | |||
index = stateParameter->index; | |||
} | |||
else if (type() == PLUGIN_LV2) | |||
else if (getType() == PLUGIN_LV2) | |||
{ | |||
// Symbol only | |||
if (stateParameter->symbol != nullptr && *stateParameter->symbol != 0) | |||
@@ -963,7 +943,7 @@ void CarlaPlugin::loadSaveState(const SaveState& saveState) | |||
const StateCustomData* const stateCustomData(*it); | |||
const char* const key(stateCustomData->key); | |||
if (type() == PLUGIN_DSSI && (std::strcmp(key, "reloadprograms") == 0 || std::strcmp(key, "load") == 0 || std::strncmp(key, "patches", 7) == 0)) | |||
if (getType() == PLUGIN_DSSI && (std::strcmp(key, "reloadprograms") == 0 || std::strcmp(key, "load") == 0 || std::strncmp(key, "patches", 7) == 0)) | |||
continue; | |||
if (usesMultiProgs && std::strcmp(key, "midiPrograms") == 0) | |||
continue; | |||
@@ -1002,11 +982,14 @@ bool CarlaPlugin::saveStateToFile(const char* const filename) | |||
if (! file.open(QIODevice::WriteOnly | QIODevice::Text)) | |||
return false; | |||
QString content; | |||
fillXmlStringFromSaveState(content, getSaveState()); | |||
QTextStream out(&file); | |||
out << "<?xml version='1.0' encoding='UTF-8'?>\n"; | |||
out << "<!DOCTYPE CARLA-PRESET>\n"; | |||
out << "<CARLA-PRESET VERSION='1.0'>\n"; | |||
out << getXMLFromSaveState(getSaveState()); | |||
out << content; | |||
out << "</CARLA-PRESET>\n"; | |||
file.close(); | |||
@@ -1035,7 +1018,9 @@ bool CarlaPlugin::loadStateFromFile(const char* const filename) | |||
return false; | |||
} | |||
loadSaveState(getSaveStateDictFromXML(xmlNode)); | |||
SaveState saveState; | |||
fillSaveStateFromXmlNode(saveState, xmlNode); | |||
loadSaveState(saveState); | |||
return true; | |||
} | |||
@@ -1057,7 +1042,7 @@ void CarlaPlugin::setName(const char* const newName) | |||
void CarlaPlugin::setOption(const unsigned int option, const bool yesNo) | |||
{ | |||
CARLA_ASSERT(availableOptions() & option); | |||
CARLA_ASSERT(getAvailableOptions() & option); | |||
if (yesNo) | |||
fOptions |= option; | |||
@@ -1105,7 +1090,7 @@ void CarlaPlugin::setActive(const bool active, const bool sendOsc, const bool se | |||
const float value(active ? 1.0f : 0.0f); | |||
if (sendOsc) | |||
pData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_ACTIVE, value); | |||
pData->engine->oscSend_control_set_parameter_value(fId, PARAMETER_ACTIVE, value); | |||
if (sendCallback) | |||
pData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_ACTIVE, 0, value, nullptr); | |||
@@ -1131,7 +1116,7 @@ void CarlaPlugin::setDryWet(const float value, const bool sendOsc, const bool se | |||
pData->postProc.dryWet = fixedValue; | |||
if (sendOsc) | |||
pData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_DRYWET, fixedValue); | |||
pData->engine->oscSend_control_set_parameter_value(fId, PARAMETER_DRYWET, fixedValue); | |||
if (sendCallback) | |||
pData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_DRYWET, 0, fixedValue, nullptr); | |||
@@ -1149,7 +1134,7 @@ void CarlaPlugin::setVolume(const float value, const bool sendOsc, const bool se | |||
pData->postProc.volume = fixedValue; | |||
if (sendOsc) | |||
pData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_VOLUME, fixedValue); | |||
pData->engine->oscSend_control_set_parameter_value(fId, PARAMETER_VOLUME, fixedValue); | |||
if (sendCallback) | |||
pData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_VOLUME, 0, fixedValue, nullptr); | |||
@@ -1167,7 +1152,7 @@ void CarlaPlugin::setBalanceLeft(const float value, const bool sendOsc, const bo | |||
pData->postProc.balanceLeft = fixedValue; | |||
if (sendOsc) | |||
pData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_BALANCE_LEFT, fixedValue); | |||
pData->engine->oscSend_control_set_parameter_value(fId, PARAMETER_BALANCE_LEFT, fixedValue); | |||
if (sendCallback) | |||
pData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_BALANCE_LEFT, 0, fixedValue, nullptr); | |||
@@ -1185,7 +1170,7 @@ void CarlaPlugin::setBalanceRight(const float value, const bool sendOsc, const b | |||
pData->postProc.balanceRight = fixedValue; | |||
if (sendOsc) | |||
pData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_BALANCE_RIGHT, fixedValue); | |||
pData->engine->oscSend_control_set_parameter_value(fId, PARAMETER_BALANCE_RIGHT, fixedValue); | |||
if (sendCallback) | |||
pData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_BALANCE_RIGHT, 0, fixedValue, nullptr); | |||
@@ -1203,7 +1188,7 @@ void CarlaPlugin::setPanning(const float value, const bool sendOsc, const bool s | |||
pData->postProc.panning = fixedValue; | |||
if (sendOsc) | |||
pData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_PANNING, fixedValue); | |||
pData->engine->oscSend_control_set_parameter_value(fId, PARAMETER_PANNING, fixedValue); | |||
if (sendCallback) | |||
pData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_PANNING, 0, fixedValue, nullptr); | |||
@@ -1226,13 +1211,13 @@ void CarlaPlugin::setCtrlChannel(const int8_t channel, const bool sendOsc, const | |||
const float ctrlf(channel); | |||
if (sendOsc) | |||
pData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_CTRL_CHANNEL, ctrlf); | |||
pData->engine->oscSend_control_set_parameter_value(fId, PARAMETER_CTRL_CHANNEL, ctrlf); | |||
if (sendCallback) | |||
pData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_CTRL_CHANNEL, 0, ctrlf, nullptr); | |||
if (fHints & PLUGIN_IS_BRIDGE) | |||
osc_send_control(&pData->osc.data, PARAMETER_CTRL_CHANNEL, ctrlf); | |||
osc_send_control(pData->osc.data, PARAMETER_CTRL_CHANNEL, ctrlf); | |||
#else | |||
return; | |||
@@ -1257,7 +1242,7 @@ void CarlaPlugin::setParameterValue(const uint32_t parameterId, const float valu | |||
uiParameterChange(parameterId, value); | |||
if (sendOsc) | |||
pData->engine->osc_send_control_set_parameter_value(fId, parameterId, value); | |||
pData->engine->oscSend_control_set_parameter_value(fId, parameterId, value); | |||
#endif | |||
if (sendCallback) | |||
@@ -1323,7 +1308,7 @@ void CarlaPlugin::setParameterMidiChannel(const uint32_t parameterId, uint8_t ch | |||
#ifndef BUILD_BRIDGE | |||
if (sendOsc) | |||
pData->engine->osc_send_control_set_parameter_midi_channel(fId, parameterId, channel); | |||
pData->engine->oscSend_control_set_parameter_midi_channel(fId, parameterId, channel); | |||
if (sendCallback) | |||
pData->engine->callback(CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED, fId, parameterId, channel, 0.0f, nullptr); | |||
@@ -1352,7 +1337,7 @@ void CarlaPlugin::setParameterMidiCC(const uint32_t parameterId, int16_t cc, con | |||
#ifndef BUILD_BRIDGE | |||
if (sendOsc) | |||
pData->engine->osc_send_control_set_parameter_midi_cc(fId, parameterId, cc); | |||
pData->engine->oscSend_control_set_parameter_midi_cc(fId, parameterId, cc); | |||
if (sendCallback) | |||
pData->engine->callback(CALLBACK_PARAMETER_MIDI_CC_CHANGED, fId, parameterId, cc, 0.0f, nullptr); | |||
@@ -1459,7 +1444,7 @@ void CarlaPlugin::setProgram(int32_t index, const bool sendGui, const bool sendO | |||
#ifndef BUILD_BRIDGE | |||
if (sendOsc) | |||
pData->engine->osc_send_control_set_program(fId, fixedIndex); | |||
pData->engine->oscSend_control_set_program(fId, fixedIndex); | |||
#endif | |||
if (sendCallback) | |||
@@ -1473,20 +1458,20 @@ void CarlaPlugin::setProgram(int32_t index, const bool sendGui, const bool sendO | |||
uiProgramChange(fixedIndex); | |||
#endif | |||
if (type() == PLUGIN_GIG || type() == PLUGIN_SF2 || type() == PLUGIN_SFZ) | |||
if (getType() == PLUGIN_GIG || getType() == PLUGIN_SF2 || getType() == PLUGIN_SFZ) | |||
return; | |||
for (uint32_t i=0; i < pData->param.count; ++i) | |||
{ | |||
const float value(pData->param.ranges[i].fixValue(getParameterValue(i))); | |||
const float value(pData->param.ranges[i].getFixedValue(getParameterValue(i))); | |||
pData->param.ranges[i].def = value; | |||
if (sendOsc || sendCallback) | |||
{ | |||
#ifndef BUILD_BRIDGE | |||
pData->engine->osc_send_control_set_default_value(fId, i, value); | |||
pData->engine->osc_send_control_set_parameter_value(fId, i, value); | |||
pData->engine->oscSend_control_set_default_value(fId, i, value); | |||
pData->engine->oscSend_control_set_parameter_value(fId, i, value); | |||
#endif | |||
pData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, i, 0, value, nullptr); | |||
@@ -1519,7 +1504,7 @@ void CarlaPlugin::setMidiProgram(int32_t index, const bool sendGui, const bool s | |||
#ifndef BUILD_BRIDGE | |||
if (sendOsc) | |||
pData->engine->osc_send_control_set_midi_program(fId, fixedIndex); | |||
pData->engine->oscSend_control_set_midi_program(fId, fixedIndex); | |||
#endif | |||
if (sendCallback) | |||
@@ -1532,20 +1517,20 @@ void CarlaPlugin::setMidiProgram(int32_t index, const bool sendGui, const bool s | |||
uiMidiProgramChange(fixedIndex); | |||
#endif | |||
if (type() == PLUGIN_GIG || type() == PLUGIN_SF2 || type() == PLUGIN_SFZ) | |||
if (getType() == PLUGIN_GIG || getType() == PLUGIN_SF2 || getType() == PLUGIN_SFZ) | |||
return; | |||
for (uint32_t i=0; i < pData->param.count; ++i) | |||
{ | |||
const float value(pData->param.ranges[i].fixValue(getParameterValue(i))); | |||
const float value(pData->param.ranges[i].getFixedValue(getParameterValue(i))); | |||
pData->param.ranges[i].def = value; | |||
if (sendOsc || sendCallback) | |||
{ | |||
#ifndef BUILD_BRIDGE | |||
pData->engine->osc_send_control_set_default_value(fId, i, value); | |||
pData->engine->osc_send_control_set_parameter_value(fId, i, value); | |||
pData->engine->oscSend_control_set_default_value(fId, i, value); | |||
pData->engine->oscSend_control_set_parameter_value(fId, i, value); | |||
#endif | |||
pData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, i, 0, value, nullptr); | |||
@@ -1641,7 +1626,7 @@ bool CarlaPlugin::tryLock() | |||
void CarlaPlugin::unlock() | |||
{ | |||
pData->masterMutex.unlock(true); | |||
pData->masterMutex.unlock(); | |||
} | |||
// ------------------------------------------------------------------- | |||
@@ -1673,7 +1658,7 @@ void CarlaPlugin::registerToOscClient() | |||
#endif | |||
#ifndef BUILD_BRIDGE | |||
pData->engine->osc_send_control_add_plugin_start(fId, fName); | |||
pData->engine->oscSend_control_add_plugin_start(fId, fName); | |||
#endif | |||
// Base data | |||
@@ -1690,7 +1675,7 @@ void CarlaPlugin::registerToOscClient() | |||
#ifdef BUILD_BRIDGE | |||
pData->engine->osc_send_bridge_plugin_info(category(), fHints, bufName, bufLabel, bufMaker, bufCopyright, uniqueId()); | |||
#else | |||
pData->engine->osc_send_control_set_plugin_data(fId, type(), category(), fHints, bufName, bufLabel, bufMaker, bufCopyright, uniqueId()); | |||
pData->engine->oscSend_control_set_plugin_data(fId, getType(), getCategory(), fHints, bufName, bufLabel, bufMaker, bufCopyright, getUniqueId()); | |||
#endif | |||
} | |||
@@ -1704,7 +1689,7 @@ void CarlaPlugin::registerToOscClient() | |||
pData->engine->osc_send_bridge_midi_count(midiInCount(), midiOutCount(), midiInCount() + midiOutCount()); | |||
pData->engine->osc_send_bridge_parameter_count(cIns, cOuts, cTotals); | |||
#else | |||
pData->engine->osc_send_control_set_plugin_ports(fId, audioInCount(), audioOutCount(), midiInCount(), midiOutCount(), cIns, cOuts, cTotals); | |||
pData->engine->oscSend_control_set_plugin_ports(fId, getAudioInCount(), getAudioOutCount(), getMidiInCount(), getMidiOutCount(), cIns, cOuts, cTotals); | |||
#endif | |||
} | |||
@@ -1730,10 +1715,10 @@ void CarlaPlugin::registerToOscClient() | |||
pData->engine->osc_send_bridge_parameter_ranges(i, paramRanges.def, paramRanges.min, paramRanges.max, paramRanges.step, paramRanges.stepSmall, paramRanges.stepLarge); | |||
pData->engine->osc_send_bridge_set_parameter_value(i, getParameterValue(i)); | |||
#else | |||
pData->engine->osc_send_control_set_parameter_data(fId, i, paramData.type, paramData.hints, bufName, bufUnit, getParameterValue(i)); | |||
pData->engine->osc_send_control_set_parameter_ranges(fId, i, paramRanges.min, paramRanges.max, paramRanges.def, paramRanges.step, paramRanges.stepSmall, paramRanges.stepLarge); | |||
pData->engine->osc_send_control_set_parameter_midi_cc(fId, i, paramData.midiCC); | |||
pData->engine->osc_send_control_set_parameter_midi_channel(fId, i, paramData.midiChannel); | |||
pData->engine->oscSend_control_set_parameter_data(fId, i, paramData.type, paramData.hints, bufName, bufUnit, getParameterValue(i)); | |||
pData->engine->oscSend_control_set_parameter_ranges(fId, i, paramRanges.min, paramRanges.max, paramRanges.def, paramRanges.step, paramRanges.stepSmall, paramRanges.stepLarge); | |||
pData->engine->oscSend_control_set_parameter_midi_cc(fId, i, paramData.midiCC); | |||
pData->engine->oscSend_control_set_parameter_midi_channel(fId, i, paramData.midiChannel); | |||
#endif | |||
} | |||
} | |||
@@ -1749,12 +1734,12 @@ void CarlaPlugin::registerToOscClient() | |||
pData->engine->osc_send_bridge_set_program(pData->prog.current); | |||
#else | |||
pData->engine->osc_send_control_set_program_count(fId, pData->prog.count); | |||
pData->engine->oscSend_control_set_program_count(fId, pData->prog.count); | |||
for (uint32_t i=0; i < pData->prog.count; ++i) | |||
pData->engine->osc_send_control_set_program_name(fId, i, pData->prog.names[i]); | |||
pData->engine->oscSend_control_set_program_name(fId, i, pData->prog.names[i]); | |||
pData->engine->osc_send_control_set_program(fId, pData->prog.current); | |||
pData->engine->oscSend_control_set_program(fId, pData->prog.current); | |||
#endif | |||
} | |||
@@ -1773,31 +1758,31 @@ void CarlaPlugin::registerToOscClient() | |||
pData->engine->osc_send_bridge_set_midi_program(pData->midiprog.current); | |||
#else | |||
pData->engine->osc_send_control_set_midi_program_count(fId, pData->midiprog.count); | |||
pData->engine->oscSend_control_set_midi_program_count(fId, pData->midiprog.count); | |||
for (uint32_t i=0; i < pData->midiprog.count; ++i) | |||
{ | |||
const MidiProgramData& mpData(pData->midiprog.data[i]); | |||
pData->engine->osc_send_control_set_midi_program_data(fId, i, mpData.bank, mpData.program, mpData.name); | |||
pData->engine->oscSend_control_set_midi_program_data(fId, i, mpData.bank, mpData.program, mpData.name); | |||
} | |||
pData->engine->osc_send_control_set_midi_program(fId, pData->midiprog.current); | |||
pData->engine->oscSend_control_set_midi_program(fId, pData->midiprog.current); | |||
#endif | |||
} | |||
#ifndef BUILD_BRIDGE | |||
pData->engine->osc_send_control_add_plugin_end(fId); | |||
pData->engine->oscSend_control_add_plugin_end(fId); | |||
// Internal Parameters | |||
{ | |||
pData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_DRYWET, pData->postProc.dryWet); | |||
pData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_VOLUME, pData->postProc.volume); | |||
pData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_BALANCE_LEFT, pData->postProc.balanceLeft); | |||
pData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_BALANCE_RIGHT, pData->postProc.balanceRight); | |||
pData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_PANNING, pData->postProc.panning); | |||
pData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_CTRL_CHANNEL, pData->ctrlChannel); | |||
pData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_ACTIVE, pData->active ? 1.0f : 0.0f); | |||
pData->engine->oscSend_control_set_parameter_value(fId, PARAMETER_DRYWET, pData->postProc.dryWet); | |||
pData->engine->oscSend_control_set_parameter_value(fId, PARAMETER_VOLUME, pData->postProc.volume); | |||
pData->engine->oscSend_control_set_parameter_value(fId, PARAMETER_BALANCE_LEFT, pData->postProc.balanceLeft); | |||
pData->engine->oscSend_control_set_parameter_value(fId, PARAMETER_BALANCE_RIGHT, pData->postProc.balanceRight); | |||
pData->engine->oscSend_control_set_parameter_value(fId, PARAMETER_PANNING, pData->postProc.panning); | |||
pData->engine->oscSend_control_set_parameter_value(fId, PARAMETER_CTRL_CHANNEL, pData->ctrlChannel); | |||
pData->engine->oscSend_control_set_parameter_value(fId, PARAMETER_ACTIVE, pData->active ? 1.0f : 0.0f); | |||
} | |||
#endif | |||
} | |||
@@ -1835,7 +1820,7 @@ void CarlaPlugin::updateOscData(const lo_address& source, const char* const url) | |||
return; | |||
#endif | |||
osc_send_sample_rate(&pData->osc.data, pData->engine->getSampleRate()); | |||
osc_send_sample_rate(pData->osc.data, pData->engine->getSampleRate()); | |||
for (NonRtList<CustomData>::Itenerator it = pData->custom.begin(); it.valid(); it.next()) | |||
{ | |||
@@ -1846,37 +1831,37 @@ void CarlaPlugin::updateOscData(const lo_address& source, const char* const url) | |||
CARLA_ASSERT(cData.value != nullptr); | |||
if (std::strcmp(cData.type, CUSTOM_DATA_STRING) == 0) | |||
osc_send_configure(&pData->osc.data, cData.key, cData.value); | |||
osc_send_configure(pData->osc.data, cData.key, cData.value); | |||
} | |||
if (pData->prog.current >= 0) | |||
osc_send_program(&pData->osc.data, pData->prog.current); | |||
osc_send_program(pData->osc.data, pData->prog.current); | |||
if (pData->midiprog.current >= 0) | |||
{ | |||
const MidiProgramData& curMidiProg(pData->midiprog.getCurrent()); | |||
if (type() == PLUGIN_DSSI) | |||
osc_send_program(&pData->osc.data, curMidiProg.bank, curMidiProg.program); | |||
if (getType() == PLUGIN_DSSI) | |||
osc_send_program(pData->osc.data, curMidiProg.bank, curMidiProg.program); | |||
else | |||
osc_send_midi_program(&pData->osc.data, curMidiProg.bank, curMidiProg.program); | |||
osc_send_midi_program(pData->osc.data, curMidiProg.bank, curMidiProg.program); | |||
} | |||
for (uint32_t i=0; i < pData->param.count; ++i) | |||
osc_send_control(&pData->osc.data, pData->param.data[i].rindex, getParameterValue(i)); | |||
osc_send_control(pData->osc.data, pData->param.data[i].rindex, getParameterValue(i)); | |||
carla_stdout("CarlaPlugin::updateOscData() - done"); | |||
} | |||
void CarlaPlugin::freeOscData() | |||
{ | |||
pData->osc.data.free(); | |||
} | |||
// void CarlaPlugin::freeOscData() | |||
// { | |||
// pData->osc.data.free(); | |||
// } | |||
bool CarlaPlugin::waitForOscGuiShow() | |||
{ | |||
carla_stdout("CarlaPlugin::waitForOscGuiShow()"); | |||
uint i=0, oscUiTimeout = pData->engine->getOptions().oscUiTimeout; | |||
uint i=0, oscUiTimeout = pData->engine->getOptions().uiBridgesTimeout; | |||
// wait for UI 'update' call | |||
for (; i < oscUiTimeout/100; ++i) | |||
@@ -1884,7 +1869,7 @@ bool CarlaPlugin::waitForOscGuiShow() | |||
if (pData->osc.data.target != nullptr) | |||
{ | |||
carla_stdout("CarlaPlugin::waitForOscGuiShow() - got response, asking UI to show itself now"); | |||
osc_send_show(&pData->osc.data); | |||
osc_send_show(pData->osc.data); | |||
return true; | |||
} | |||
else | |||
@@ -1926,9 +1911,9 @@ void CarlaPlugin::sendMidiSingleNote(const uint8_t channel, const uint8_t note, | |||
if (sendOsc) | |||
{ | |||
if (velo > 0) | |||
pData->engine->osc_send_control_note_on(fId, channel, note, velo); | |||
pData->engine->oscSend_control_note_on(fId, channel, note, velo); | |||
else | |||
pData->engine->osc_send_control_note_off(fId, channel, note); | |||
pData->engine->oscSend_control_note_off(fId, channel, note); | |||
} | |||
if (sendCallback) | |||
@@ -1986,7 +1971,7 @@ void CarlaPlugin::postRtEventsRun() | |||
{ | |||
// Update OSC control client | |||
if (pData->engine->isOscControlRegistered()) | |||
pData->engine->osc_send_control_set_parameter_value(fId, event.value1, event.value3); | |||
pData->engine->oscSend_control_set_parameter_value(fId, event.value1, event.value3); | |||
// Update Host | |||
pData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, event.value1, 0, event.value3, nullptr); | |||
@@ -2002,7 +1987,7 @@ void CarlaPlugin::postRtEventsRun() | |||
#ifndef BUILD_BRIDGE | |||
// Update OSC control client | |||
if (pData->engine->isOscControlRegistered()) | |||
pData->engine->osc_send_control_set_program(fId, event.value1); | |||
pData->engine->oscSend_control_set_program(fId, event.value1); | |||
// Update Host | |||
pData->engine->callback(CALLBACK_PROGRAM_CHANGED, fId, event.value1, 0, 0.0f, nullptr); | |||
@@ -2017,8 +2002,8 @@ void CarlaPlugin::postRtEventsRun() | |||
if (sendOsc) | |||
{ | |||
pData->engine->osc_send_control_set_parameter_value(fId, j, value); | |||
pData->engine->osc_send_control_set_default_value(fId, j, pData->param.ranges[j].def); | |||
pData->engine->oscSend_control_set_parameter_value(fId, j, value); | |||
pData->engine->oscSend_control_set_default_value(fId, j, pData->param.ranges[j].def); | |||
} | |||
pData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, j, 0, value, nullptr); | |||
@@ -2036,7 +2021,7 @@ void CarlaPlugin::postRtEventsRun() | |||
#ifndef BUILD_BRIDGE | |||
// Update OSC control client | |||
if (pData->engine->isOscControlRegistered()) | |||
pData->engine->osc_send_control_set_midi_program(fId, event.value1); | |||
pData->engine->oscSend_control_set_midi_program(fId, event.value1); | |||
// Update Host | |||
pData->engine->callback(CALLBACK_MIDI_PROGRAM_CHANGED, fId, event.value1, 0, 0.0f, nullptr); | |||
@@ -2051,8 +2036,8 @@ void CarlaPlugin::postRtEventsRun() | |||
if (sendOsc) | |||
{ | |||
pData->engine->osc_send_control_set_parameter_value(fId, j, value); | |||
pData->engine->osc_send_control_set_default_value(fId, j, pData->param.ranges[j].def); | |||
pData->engine->oscSend_control_set_parameter_value(fId, j, value); | |||
pData->engine->oscSend_control_set_default_value(fId, j, pData->param.ranges[j].def); | |||
} | |||
pData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, j, 0, value, nullptr); | |||
@@ -2069,7 +2054,7 @@ void CarlaPlugin::postRtEventsRun() | |||
#ifndef BUILD_BRIDGE | |||
// Update OSC control client | |||
if (pData->engine->isOscControlRegistered()) | |||
pData->engine->osc_send_control_note_on(fId, event.value1, event.value2, int(event.value3)); | |||
pData->engine->oscSend_control_note_on(fId, event.value1, event.value2, int(event.value3)); | |||
// Update Host | |||
pData->engine->callback(CALLBACK_NOTE_ON, fId, event.value1, event.value2, int(event.value3), nullptr); | |||
@@ -2083,7 +2068,7 @@ void CarlaPlugin::postRtEventsRun() | |||
#ifndef BUILD_BRIDGE | |||
// Update OSC control client | |||
if (pData->engine->isOscControlRegistered()) | |||
pData->engine->osc_send_control_note_off(fId, event.value1, event.value2); | |||
pData->engine->oscSend_control_note_off(fId, event.value1, event.value2); | |||
// Update Host | |||
pData->engine->callback(CALLBACK_NOTE_OFF, fId, event.value1, event.value2, 0.0f, nullptr); | |||
@@ -2098,7 +2083,7 @@ void CarlaPlugin::postRtEventsRun() | |||
void CarlaPlugin::uiParameterChange(const uint32_t index, const float value) | |||
{ | |||
CARLA_ASSERT(index < parameterCount()); | |||
CARLA_ASSERT(index < getParameterCount()); | |||
return; | |||
// unused | |||
@@ -2108,7 +2093,7 @@ void CarlaPlugin::uiParameterChange(const uint32_t index, const float value) | |||
void CarlaPlugin::uiProgramChange(const uint32_t index) | |||
{ | |||
CARLA_ASSERT(index < programCount()); | |||
CARLA_ASSERT(index < getProgramCount()); | |||
return; | |||
// unused | |||
@@ -2117,7 +2102,7 @@ void CarlaPlugin::uiProgramChange(const uint32_t index) | |||
void CarlaPlugin::uiMidiProgramChange(const uint32_t index) | |||
{ | |||
CARLA_ASSERT(index < midiProgramCount()); | |||
CARLA_ASSERT(index < getMidiProgramCount()); | |||
return; | |||
// unused | |||
@@ -2156,7 +2141,7 @@ CarlaPlugin::ScopedDisabler::ScopedDisabler(CarlaPlugin* const plugin) | |||
{ | |||
carla_debug("CarlaPlugin::ScopedDisabler(%p)", plugin); | |||
CARLA_ASSERT(plugin != nullptr); | |||
CARLA_ASSERT(plugin->kData != nullptr); | |||
CARLA_ASSERT(plugin->pData != nullptr); | |||
CARLA_ASSERT(plugin->pData->client != nullptr); | |||
if (plugin == nullptr) | |||
@@ -327,10 +327,10 @@ struct PluginParameterData { | |||
count = 0; | |||
} | |||
float fixValue(const uint32_t parameterId, const float& value) | |||
float getFixedValue(const uint32_t parameterId, const float& value) const | |||
{ | |||
CARLA_ASSERT_INT2(parameterId < count, parameterId, count); | |||
return ranges[parameterId].fixValue(value); | |||
CARLA_SAFE_ASSERT_RETURN(parameterId < count, 0.0f); | |||
return ranges[parameterId].getFixedValue(value); | |||
} | |||
CARLA_DECLARE_NON_COPY_STRUCT(PluginParameterData) | |||
@@ -472,8 +472,6 @@ struct ExternalMidiNote { | |||
: channel(-1), | |||
note(0), | |||
velo(0) {} | |||
CARLA_DECLARE_NON_COPY_STRUCT(ExternalMidiNote) | |||
}; | |||
// ----------------------------------------------------------------------- | |||
@@ -535,7 +533,7 @@ struct CarlaPluginProtectedData { | |||
mutex.unlock(); | |||
} | |||
CARLA_DECLARE_NON_COPY_STRUCT_WITH_LEAK_DETECTOR(ExternalNotes) | |||
CARLA_DECLARE_NON_COPY_STRUCT(ExternalNotes) | |||
} extNotes; | |||
@@ -577,7 +575,7 @@ struct CarlaPluginProtectedData { | |||
mutex.unlock(); | |||
} | |||
CARLA_DECLARE_NON_COPY_STRUCT_WITH_LEAK_DETECTOR(PostRtEvents) | |||
CARLA_DECLARE_NON_COPY_STRUCT(PostRtEvents) | |||
} postRtEvents; | |||
@@ -596,7 +594,7 @@ struct CarlaPluginProtectedData { | |||
balanceRight(1.0f), | |||
panning(0.0f) {} | |||
CARLA_DECLARE_NON_COPY_STRUCT_WITH_LEAK_DETECTOR(PostProc) | |||
CARLA_DECLARE_NON_COPY_STRUCT(PostProc) | |||
} postProc; | |||
#endif | |||
@@ -47,16 +47,16 @@ public: | |||
{ | |||
carla_debug("LadspaPlugin::~LadspaPlugin()"); | |||
kData->singleMutex.lock(); | |||
kData->masterMutex.lock(); | |||
pData->singleMutex.lock(); | |||
pData->masterMutex.lock(); | |||
if (kData->client != nullptr && kData->client->isActive()) | |||
kData->client->deactivate(); | |||
if (pData->client != nullptr && pData->client->isActive()) | |||
pData->client->deactivate(); | |||
if (kData->active) | |||
if (pData->active) | |||
{ | |||
deactivate(); | |||
kData->active = false; | |||
pData->active = false; | |||
} | |||
if (fDescriptor != nullptr) | |||
@@ -141,9 +141,9 @@ public: | |||
uint32_t parameterScalePointCount(const uint32_t parameterId) const override | |||
{ | |||
CARLA_ASSERT(parameterId < kData->param.count); | |||
CARLA_ASSERT(parameterId < pData->param.count); | |||
const int32_t rindex(kData->param.data[parameterId].rindex); | |||
const int32_t rindex(pData->param.data[parameterId].rindex); | |||
if (fRdfDescriptor != nullptr && rindex < static_cast<int32_t>(fRdfDescriptor->PortCount)) | |||
{ | |||
@@ -175,11 +175,11 @@ public: | |||
if (! isDssiVst) | |||
options |= PLUGIN_OPTION_FIXED_BUFFER; | |||
if (kData->engine->getProccessMode() != PROCESS_MODE_CONTINUOUS_RACK) | |||
if (pData->engine->getProccessMode() != PROCESS_MODE_CONTINUOUS_RACK) | |||
{ | |||
if (fOptions & PLUGIN_OPTION_FORCE_STEREO) | |||
options |= PLUGIN_OPTION_FORCE_STEREO; | |||
else if (kData->audioIn.count <= 1 && kData->audioOut.count <= 1 && (kData->audioIn.count != 0 || kData->audioOut.count != 0)) | |||
else if (pData->audioIn.count <= 1 && pData->audioOut.count <= 1 && (pData->audioIn.count != 0 || pData->audioOut.count != 0)) | |||
options |= PLUGIN_OPTION_FORCE_STEREO; | |||
} | |||
@@ -189,7 +189,7 @@ public: | |||
float getParameterValue(const uint32_t parameterId) override | |||
{ | |||
CARLA_ASSERT(fParamBuffers != nullptr); | |||
CARLA_ASSERT(parameterId < kData->param.count); | |||
CARLA_ASSERT(parameterId < pData->param.count); | |||
return fParamBuffers[parameterId]; | |||
} | |||
@@ -197,10 +197,10 @@ public: | |||
float getParameterScalePointValue(const uint32_t parameterId, const uint32_t scalePointId) override | |||
{ | |||
CARLA_ASSERT(fRdfDescriptor != nullptr); | |||
CARLA_ASSERT(parameterId < kData->param.count); | |||
CARLA_ASSERT(parameterId < pData->param.count); | |||
CARLA_ASSERT(scalePointId < parameterScalePointCount(parameterId)); | |||
const int32_t rindex(kData->param.data[parameterId].rindex); | |||
const int32_t rindex(pData->param.data[parameterId].rindex); | |||
if (fRdfDescriptor != nullptr && rindex < static_cast<int32_t>(fRdfDescriptor->PortCount)) | |||
{ | |||
@@ -263,9 +263,9 @@ public: | |||
void getParameterName(const uint32_t parameterId, char* const strBuf) override | |||
{ | |||
CARLA_ASSERT(fDescriptor != nullptr); | |||
CARLA_ASSERT(parameterId < kData->param.count); | |||
CARLA_ASSERT(parameterId < pData->param.count); | |||
const int32_t rindex(kData->param.data[parameterId].rindex); | |||
const int32_t rindex(pData->param.data[parameterId].rindex); | |||
if (rindex < static_cast<int32_t>(fDescriptor->PortCount)) | |||
std::strncpy(strBuf, fDescriptor->PortNames[rindex], STR_MAX); | |||
@@ -275,9 +275,9 @@ public: | |||
void getParameterSymbol(const uint32_t parameterId, char* const strBuf) override | |||
{ | |||
CARLA_ASSERT(parameterId < kData->param.count); | |||
CARLA_ASSERT(parameterId < pData->param.count); | |||
const int32_t rindex(kData->param.data[parameterId].rindex); | |||
const int32_t rindex(pData->param.data[parameterId].rindex); | |||
if (fRdfDescriptor != nullptr && rindex < static_cast<int32_t>(fRdfDescriptor->PortCount)) | |||
{ | |||
@@ -295,9 +295,9 @@ public: | |||
void getParameterUnit(const uint32_t parameterId, char* const strBuf) override | |||
{ | |||
CARLA_ASSERT(parameterId < kData->param.count); | |||
CARLA_ASSERT(parameterId < pData->param.count); | |||
const int32_t rindex(kData->param.data[parameterId].rindex); | |||
const int32_t rindex(pData->param.data[parameterId].rindex); | |||
if (fRdfDescriptor != nullptr && rindex < static_cast<int32_t>(fRdfDescriptor->PortCount)) | |||
{ | |||
@@ -335,10 +335,10 @@ public: | |||
void getParameterScalePointLabel(const uint32_t parameterId, const uint32_t scalePointId, char* const strBuf) override | |||
{ | |||
CARLA_ASSERT(fRdfDescriptor != nullptr); | |||
CARLA_ASSERT(parameterId < kData->param.count); | |||
CARLA_ASSERT(parameterId < pData->param.count); | |||
CARLA_ASSERT(scalePointId < parameterScalePointCount(parameterId)); | |||
const int32_t rindex(kData->param.data[parameterId].rindex); | |||
const int32_t rindex(pData->param.data[parameterId].rindex); | |||
if (fRdfDescriptor != nullptr && rindex < static_cast<int32_t>(fRdfDescriptor->PortCount)) | |||
{ | |||
@@ -374,9 +374,9 @@ public: | |||
void setParameterValue(const uint32_t parameterId, const float value, const bool sendGui, const bool sendOsc, const bool sendCallback) override | |||
{ | |||
CARLA_ASSERT(parameterId < kData->param.count); | |||
CARLA_ASSERT(parameterId < pData->param.count); | |||
const float fixedValue(kData->param.fixValue(parameterId, value)); | |||
const float fixedValue(pData->param.fixValue(parameterId, value)); | |||
fParamBuffers[parameterId] = fixedValue; | |||
CarlaPlugin::setParameterValue(parameterId, fixedValue, sendGui, sendOsc, sendCallback); | |||
@@ -393,28 +393,28 @@ public: | |||
void reload() override | |||
{ | |||
carla_debug("LadspaPlugin::reload() - start"); | |||
CARLA_ASSERT(kData->engine != nullptr); | |||
CARLA_ASSERT(pData->engine != nullptr); | |||
CARLA_ASSERT(fDescriptor != nullptr); | |||
CARLA_ASSERT(fHandle != nullptr); | |||
if (kData->engine == nullptr) | |||
if (pData->engine == nullptr) | |||
return; | |||
if (fDescriptor == nullptr) | |||
return; | |||
if (fHandle == nullptr) | |||
return; | |||
const ProcessMode processMode(kData->engine->getProccessMode()); | |||
const ProcessMode processMode(pData->engine->getProccessMode()); | |||
// Safely disable plugin for reload | |||
const ScopedDisabler sd(this); | |||
if (kData->active) | |||
if (pData->active) | |||
deactivate(); | |||
clearBuffers(); | |||
const float sampleRate(static_cast<float>(kData->engine->getSampleRate())); | |||
const float sampleRate(static_cast<float>(pData->engine->getSampleRate())); | |||
const uint32_t portCount(static_cast<uint32_t>(fDescriptor->PortCount)); | |||
uint32_t aIns, aOuts, params, j; | |||
@@ -471,7 +471,7 @@ public: | |||
if (aIns > 0) | |||
{ | |||
kData->audioIn.createNew(aIns); | |||
pData->audioIn.createNew(aIns); | |||
fAudioInBuffers = new float*[aIns]; | |||
for (uint32_t i=0; i < aIns; ++i) | |||
@@ -480,7 +480,7 @@ public: | |||
if (aOuts > 0) | |||
{ | |||
kData->audioOut.createNew(aOuts); | |||
pData->audioOut.createNew(aOuts); | |||
fAudioOutBuffers = new float*[aOuts]; | |||
needsCtrlIn = true; | |||
@@ -490,13 +490,13 @@ public: | |||
if (params > 0) | |||
{ | |||
kData->param.createNew(params); | |||
pData->param.createNew(params); | |||
fParamBuffers = new float[params]; | |||
carla_zeroFloat(fParamBuffers, params); | |||
} | |||
const uint portNameSize(kData->engine->maxPortNameSize()); | |||
const uint portNameSize(pData->engine->maxPortNameSize()); | |||
CarlaString portName; | |||
for (uint32_t i=0, iAudioIn=0, iAudioOut=0, iCtrl=0; i < portCount; ++i) | |||
@@ -523,27 +523,27 @@ public: | |||
if (LADSPA_IS_PORT_INPUT(portType)) | |||
{ | |||
j = iAudioIn++; | |||
kData->audioIn.ports[j].port = (CarlaEngineAudioPort*)kData->client->addPort(kEnginePortTypeAudio, portName, true); | |||
kData->audioIn.ports[j].rindex = i; | |||
pData->audioIn.ports[j].port = (CarlaEngineAudioPort*)pData->client->addPort(kEnginePortTypeAudio, portName, true); | |||
pData->audioIn.ports[j].rindex = i; | |||
if (forcedStereoIn) | |||
{ | |||
portName += "_2"; | |||
kData->audioIn.ports[1].port = (CarlaEngineAudioPort*)kData->client->addPort(kEnginePortTypeAudio, portName, true); | |||
kData->audioIn.ports[1].rindex = i; | |||
pData->audioIn.ports[1].port = (CarlaEngineAudioPort*)pData->client->addPort(kEnginePortTypeAudio, portName, true); | |||
pData->audioIn.ports[1].rindex = i; | |||
} | |||
} | |||
else if (LADSPA_IS_PORT_OUTPUT(portType)) | |||
{ | |||
j = iAudioOut++; | |||
kData->audioOut.ports[j].port = (CarlaEngineAudioPort*)kData->client->addPort(kEnginePortTypeAudio, portName, false); | |||
kData->audioOut.ports[j].rindex = i; | |||
pData->audioOut.ports[j].port = (CarlaEngineAudioPort*)pData->client->addPort(kEnginePortTypeAudio, portName, false); | |||
pData->audioOut.ports[j].rindex = i; | |||
if (forcedStereoOut) | |||
{ | |||
portName += "_2"; | |||
kData->audioOut.ports[1].port = (CarlaEngineAudioPort*)kData->client->addPort(kEnginePortTypeAudio, portName, false); | |||
kData->audioOut.ports[1].rindex = i; | |||
pData->audioOut.ports[1].port = (CarlaEngineAudioPort*)pData->client->addPort(kEnginePortTypeAudio, portName, false); | |||
pData->audioOut.ports[1].rindex = i; | |||
} | |||
} | |||
else | |||
@@ -552,11 +552,11 @@ public: | |||
else if (LADSPA_IS_PORT_CONTROL(portType)) | |||
{ | |||
j = iCtrl++; | |||
kData->param.data[j].index = j; | |||
kData->param.data[j].rindex = i; | |||
kData->param.data[j].hints = 0x0; | |||
kData->param.data[j].midiChannel = 0; | |||
kData->param.data[j].midiCC = -1; | |||
pData->param.data[j].index = j; | |||
pData->param.data[j].rindex = i; | |||
pData->param.data[j].hints = 0x0; | |||
pData->param.data[j].midiChannel = 0; | |||
pData->param.data[j].midiCC = -1; | |||
float min, max, def, step, stepSmall, stepLarge; | |||
@@ -599,7 +599,7 @@ public: | |||
min *= sampleRate; | |||
max *= sampleRate; | |||
def *= sampleRate; | |||
kData->param.data[j].hints |= PARAMETER_USES_SAMPLERATE; | |||
pData->param.data[j].hints |= PARAMETER_USES_SAMPLERATE; | |||
} | |||
if (LADSPA_IS_HINT_TOGGLED(portRangeHints.HintDescriptor)) | |||
@@ -607,14 +607,14 @@ public: | |||
step = max - min; | |||
stepSmall = step; | |||
stepLarge = step; | |||
kData->param.data[j].hints |= PARAMETER_IS_BOOLEAN; | |||
pData->param.data[j].hints |= PARAMETER_IS_BOOLEAN; | |||
} | |||
else if (LADSPA_IS_HINT_INTEGER(portRangeHints.HintDescriptor)) | |||
{ | |||
step = 1.0f; | |||
stepSmall = 1.0f; | |||
stepLarge = 10.0f; | |||
kData->param.data[j].hints |= PARAMETER_IS_INTEGER; | |||
pData->param.data[j].hints |= PARAMETER_IS_INTEGER; | |||
} | |||
else | |||
{ | |||
@@ -626,9 +626,9 @@ public: | |||
if (LADSPA_IS_PORT_INPUT(portType)) | |||
{ | |||
kData->param.data[j].type = PARAMETER_INPUT; | |||
kData->param.data[j].hints |= PARAMETER_IS_ENABLED; | |||
kData->param.data[j].hints |= PARAMETER_IS_AUTOMABLE; | |||
pData->param.data[j].type = PARAMETER_INPUT; | |||
pData->param.data[j].hints |= PARAMETER_IS_ENABLED; | |||
pData->param.data[j].hints |= PARAMETER_IS_AUTOMABLE; | |||
needsCtrlIn = true; | |||
} | |||
else if (LADSPA_IS_PORT_OUTPUT(portType)) | |||
@@ -642,8 +642,8 @@ public: | |||
stepSmall = 1.0f; | |||
stepLarge = 1.0f; | |||
kData->param.data[j].type = PARAMETER_LATENCY; | |||
kData->param.data[j].hints = 0; | |||
pData->param.data[j].type = PARAMETER_LATENCY; | |||
pData->param.data[j].hints = 0; | |||
} | |||
else if (std::strcmp(fDescriptor->PortNames[i], "_sample-rate") == 0) | |||
{ | |||
@@ -652,37 +652,37 @@ public: | |||
stepSmall = 1.0f; | |||
stepLarge = 1.0f; | |||
kData->param.data[j].type = PARAMETER_SAMPLE_RATE; | |||
kData->param.data[j].hints = 0; | |||
pData->param.data[j].type = PARAMETER_SAMPLE_RATE; | |||
pData->param.data[j].hints = 0; | |||
} | |||
else | |||
{ | |||
kData->param.data[j].type = PARAMETER_OUTPUT; | |||
kData->param.data[j].hints |= PARAMETER_IS_ENABLED; | |||
kData->param.data[j].hints |= PARAMETER_IS_AUTOMABLE; | |||
pData->param.data[j].type = PARAMETER_OUTPUT; | |||
pData->param.data[j].hints |= PARAMETER_IS_ENABLED; | |||
pData->param.data[j].hints |= PARAMETER_IS_AUTOMABLE; | |||
needsCtrlOut = true; | |||
} | |||
} | |||
else | |||
{ | |||
kData->param.data[j].type = PARAMETER_UNKNOWN; | |||
pData->param.data[j].type = PARAMETER_UNKNOWN; | |||
carla_stderr2("WARNING - Got a broken Port (Control, but not input or output)"); | |||
} | |||
// extra parameter hints | |||
if (LADSPA_IS_HINT_LOGARITHMIC(portRangeHints.HintDescriptor)) | |||
kData->param.data[j].hints |= PARAMETER_IS_LOGARITHMIC; | |||
pData->param.data[j].hints |= PARAMETER_IS_LOGARITHMIC; | |||
// check for scalepoints, require at least 2 to make it useful | |||
if (hasPortRDF && fRdfDescriptor->Ports[i].ScalePointCount > 1) | |||
kData->param.data[j].hints |= PARAMETER_USES_SCALEPOINTS; | |||
pData->param.data[j].hints |= PARAMETER_USES_SCALEPOINTS; | |||
kData->param.ranges[j].min = min; | |||
kData->param.ranges[j].max = max; | |||
kData->param.ranges[j].def = def; | |||
kData->param.ranges[j].step = step; | |||
kData->param.ranges[j].stepSmall = stepSmall; | |||
kData->param.ranges[j].stepLarge = stepLarge; | |||
pData->param.ranges[j].min = min; | |||
pData->param.ranges[j].max = max; | |||
pData->param.ranges[j].def = def; | |||
pData->param.ranges[j].step = step; | |||
pData->param.ranges[j].stepSmall = stepSmall; | |||
pData->param.ranges[j].stepLarge = stepLarge; | |||
// Start parameters in their default values | |||
fParamBuffers[j] = def; | |||
@@ -717,7 +717,7 @@ public: | |||
portName += "events-in"; | |||
portName.truncate(portNameSize); | |||
kData->event.portIn = (CarlaEngineEventPort*)kData->client->addPort(kEnginePortTypeEvent, portName, true); | |||
pData->event.portIn = (CarlaEngineEventPort*)pData->client->addPort(kEnginePortTypeEvent, portName, true); | |||
} | |||
if (needsCtrlOut) | |||
@@ -733,7 +733,7 @@ public: | |||
portName += "events-out"; | |||
portName.truncate(portNameSize); | |||
kData->event.portOut = (CarlaEngineEventPort*)kData->client->addPort(kEnginePortTypeEvent, portName, false); | |||
pData->event.portOut = (CarlaEngineEventPort*)pData->client->addPort(kEnginePortTypeEvent, portName, false); | |||
} | |||
if (forcedStereoIn || forcedStereoOut) | |||
@@ -757,17 +757,17 @@ public: | |||
fHints |= PLUGIN_CAN_BALANCE; | |||
// extra plugin hints | |||
kData->extraHints = 0x0; | |||
pData->extraHints = 0x0; | |||
if (aIns <= 2 && aOuts <= 2 && (aIns == aOuts || aIns == 0 || aOuts == 0)) | |||
kData->extraHints |= PLUGIN_HINT_CAN_RUN_RACK; | |||
pData->extraHints |= PLUGIN_HINT_CAN_RUN_RACK; | |||
// check latency | |||
if (fHints & PLUGIN_CAN_DRYWET) | |||
{ | |||
for (uint32_t i=0; i < kData->param.count; ++i) | |||
for (uint32_t i=0; i < pData->param.count; ++i) | |||
{ | |||
if (kData->param.data[i].type != PARAMETER_LATENCY) | |||
if (pData->param.data[i].type != PARAMETER_LATENCY) | |||
continue; | |||
// we need to pre-run the plugin so it can update its latency control-port | |||
@@ -780,7 +780,7 @@ public: | |||
tmpIn[j][0] = 0.0f; | |||
tmpIn[j][1] = 0.0f; | |||
fDescriptor->connect_port(fHandle, kData->audioIn.ports[j].rindex, tmpIn[j]); | |||
fDescriptor->connect_port(fHandle, pData->audioIn.ports[j].rindex, tmpIn[j]); | |||
} | |||
for (j=0; j < aOuts; ++j) | |||
@@ -788,7 +788,7 @@ public: | |||
tmpOut[j][0] = 0.0f; | |||
tmpOut[j][1] = 0.0f; | |||
fDescriptor->connect_port(fHandle, kData->audioOut.ports[j].rindex, tmpOut[j]); | |||
fDescriptor->connect_port(fHandle, pData->audioOut.ports[j].rindex, tmpOut[j]); | |||
} | |||
if (fDescriptor->activate != nullptr) | |||
@@ -801,20 +801,20 @@ public: | |||
const uint32_t latency = (uint32_t)fParamBuffers[i]; | |||
if (kData->latency != latency) | |||
if (pData->latency != latency) | |||
{ | |||
kData->latency = latency; | |||
kData->client->setLatency(latency); | |||
kData->recreateLatencyBuffers(); | |||
pData->latency = latency; | |||
pData->client->setLatency(latency); | |||
pData->recreateLatencyBuffers(); | |||
} | |||
break; | |||
} | |||
} | |||
bufferSizeChanged(kData->engine->getBufferSize()); | |||
bufferSizeChanged(pData->engine->getBufferSize()); | |||
if (kData->active) | |||
if (pData->active) | |||
activate(); | |||
carla_debug("LadspaPlugin::reload() - end"); | |||
@@ -858,10 +858,10 @@ public: | |||
// -------------------------------------------------------------------------------------------------------- | |||
// Check if active | |||
if (! kData->active) | |||
if (! pData->active) | |||
{ | |||
// disable any output sound | |||
for (i=0; i < kData->audioOut.count; ++i) | |||
for (i=0; i < pData->audioOut.count; ++i) | |||
carla_zeroFloat(outBuffer[i], frames); | |||
return; | |||
@@ -870,33 +870,33 @@ public: | |||
// -------------------------------------------------------------------------------------------------------- | |||
// Check if needs reset | |||
if (kData->needsReset) | |||
if (pData->needsReset) | |||
{ | |||
if (kData->latency > 0) | |||
if (pData->latency > 0) | |||
{ | |||
for (i=0; i < kData->audioIn.count; ++i) | |||
carla_zeroFloat(kData->latencyBuffers[i], kData->latency); | |||
for (i=0; i < pData->audioIn.count; ++i) | |||
carla_zeroFloat(pData->latencyBuffers[i], pData->latency); | |||
} | |||
kData->needsReset = false; | |||
pData->needsReset = false; | |||
} | |||
// -------------------------------------------------------------------------------------------------------- | |||
// Event Input and Processing | |||
if (kData->event.portIn != nullptr) | |||
if (pData->event.portIn != nullptr) | |||
{ | |||
// ---------------------------------------------------------------------------------------------------- | |||
// Event Input (System) | |||
bool sampleAccurate = (fOptions & PLUGIN_OPTION_FIXED_BUFFER) == 0; | |||
uint32_t time, nEvents = kData->event.portIn->getEventCount(); | |||
uint32_t time, nEvents = pData->event.portIn->getEventCount(); | |||
uint32_t timeOffset = 0; | |||
for (i=0; i < nEvents; ++i) | |||
{ | |||
const EngineEvent& event(kData->event.portIn->getEvent(i)); | |||
const EngineEvent& event(pData->event.portIn->getEvent(i)); | |||
time = event.time; | |||
@@ -930,7 +930,7 @@ public: | |||
{ | |||
#ifndef BUILD_BRIDGE | |||
// Control backend stuff | |||
if (event.channel == kData->ctrlChannel) | |||
if (event.channel == pData->ctrlChannel) | |||
{ | |||
float value; | |||
@@ -978,28 +978,28 @@ public: | |||
#endif | |||
// Control plugin parameters | |||
for (k=0; k < kData->param.count; ++k) | |||
for (k=0; k < pData->param.count; ++k) | |||
{ | |||
if (kData->param.data[k].midiChannel != event.channel) | |||
if (pData->param.data[k].midiChannel != event.channel) | |||
continue; | |||
if (kData->param.data[k].midiCC != ctrlEvent.param) | |||
if (pData->param.data[k].midiCC != ctrlEvent.param) | |||
continue; | |||
if (kData->param.data[k].type != PARAMETER_INPUT) | |||
if (pData->param.data[k].type != PARAMETER_INPUT) | |||
continue; | |||
if ((kData->param.data[k].hints & PARAMETER_IS_AUTOMABLE) == 0) | |||
if ((pData->param.data[k].hints & PARAMETER_IS_AUTOMABLE) == 0) | |||
continue; | |||
float value; | |||
if (kData->param.data[k].hints & PARAMETER_IS_BOOLEAN) | |||
if (pData->param.data[k].hints & PARAMETER_IS_BOOLEAN) | |||
{ | |||
value = (ctrlEvent.value < 0.5f) ? kData->param.ranges[k].min : kData->param.ranges[k].max; | |||
value = (ctrlEvent.value < 0.5f) ? pData->param.ranges[k].min : pData->param.ranges[k].max; | |||
} | |||
else | |||
{ | |||
value = kData->param.ranges[k].unnormalizeValue(ctrlEvent.value); | |||
value = pData->param.ranges[k].unnormalizeValue(ctrlEvent.value); | |||
if (kData->param.data[k].hints & PARAMETER_IS_INTEGER) | |||
if (pData->param.data[k].hints & PARAMETER_IS_INTEGER) | |||
value = std::rint(value); | |||
} | |||
@@ -1026,7 +1026,7 @@ public: | |||
} | |||
} | |||
kData->postRtEvents.trySplice(); | |||
pData->postRtEvents.trySplice(); | |||
if (frames > timeOffset) | |||
processSingle(inBuffer, outBuffer, frames - timeOffset, timeOffset); | |||
@@ -1047,25 +1047,25 @@ public: | |||
// -------------------------------------------------------------------------------------------------------- | |||
// Control Output | |||
if (kData->event.portOut != nullptr) | |||
if (pData->event.portOut != nullptr) | |||
{ | |||
uint8_t channel; | |||
uint16_t param; | |||
float value; | |||
for (k=0; k < kData->param.count; ++k) | |||
for (k=0; k < pData->param.count; ++k) | |||
{ | |||
if (kData->param.data[k].type != PARAMETER_OUTPUT) | |||
if (pData->param.data[k].type != PARAMETER_OUTPUT) | |||
continue; | |||
kData->param.ranges[k].fixValue(fParamBuffers[k]); | |||
pData->param.ranges[k].fixValue(fParamBuffers[k]); | |||
if (kData->param.data[k].midiCC > 0) | |||
if (pData->param.data[k].midiCC > 0) | |||
{ | |||
channel = kData->param.data[k].midiChannel; | |||
param = static_cast<uint16_t>(kData->param.data[k].midiCC); | |||
value = kData->param.ranges[k].normalizeValue(fParamBuffers[k]); | |||
kData->event.portOut->writeControlEvent(0, channel, kEngineControlEventTypeParameter, param, value); | |||
channel = pData->param.data[k].midiChannel; | |||
param = static_cast<uint16_t>(pData->param.data[k].midiCC); | |||
value = pData->param.ranges[k].normalizeValue(fParamBuffers[k]); | |||
pData->event.portOut->writeControlEvent(0, channel, kEngineControlEventTypeParameter, param, value); | |||
} | |||
} | |||
@@ -1079,13 +1079,13 @@ public: | |||
if (frames == 0) | |||
return false; | |||
if (kData->audioIn.count > 0) | |||
if (pData->audioIn.count > 0) | |||
{ | |||
CARLA_ASSERT(inBuffer != nullptr); | |||
if (inBuffer == nullptr) | |||
return false; | |||
} | |||
if (kData->audioOut.count > 0) | |||
if (pData->audioOut.count > 0) | |||
{ | |||
CARLA_ASSERT(outBuffer != nullptr); | |||
if (outBuffer == nullptr) | |||
@@ -1097,13 +1097,13 @@ public: | |||
// -------------------------------------------------------------------------------------------------------- | |||
// Try lock, silence otherwise | |||
if (kData->engine->isOffline()) | |||
if (pData->engine->isOffline()) | |||
{ | |||
kData->singleMutex.lock(); | |||
pData->singleMutex.lock(); | |||
} | |||
else if (! kData->singleMutex.tryLock()) | |||
else if (! pData->singleMutex.tryLock()) | |||
{ | |||
for (i=0; i < kData->audioOut.count; ++i) | |||
for (i=0; i < pData->audioOut.count; ++i) | |||
{ | |||
for (k=0; k < frames; ++k) | |||
outBuffer[i][k+timeOffset] = 0.0f; | |||
@@ -1115,9 +1115,9 @@ public: | |||
// -------------------------------------------------------------------------------------------------------- | |||
// Reset audio buffers | |||
for (i=0; i < kData->audioIn.count; ++i) | |||
for (i=0; i < pData->audioIn.count; ++i) | |||
carla_copyFloat(fAudioInBuffers[i], inBuffer[i]+timeOffset, frames); | |||
for (i=0; i < kData->audioOut.count; ++i) | |||
for (i=0; i < pData->audioOut.count; ++i) | |||
carla_zeroFloat(fAudioOutBuffers[i], frames); | |||
// -------------------------------------------------------------------------------------------------------- | |||
@@ -1133,13 +1133,13 @@ public: | |||
// Post-processing (dry/wet, volume and balance) | |||
{ | |||
const bool doDryWet = (fHints & PLUGIN_CAN_DRYWET) != 0 && kData->postProc.dryWet != 1.0f; | |||
const bool doBalance = (fHints & PLUGIN_CAN_BALANCE) != 0 && (kData->postProc.balanceLeft != -1.0f || kData->postProc.balanceRight != 1.0f); | |||
const bool doDryWet = (fHints & PLUGIN_CAN_DRYWET) != 0 && pData->postProc.dryWet != 1.0f; | |||
const bool doBalance = (fHints & PLUGIN_CAN_BALANCE) != 0 && (pData->postProc.balanceLeft != -1.0f || pData->postProc.balanceRight != 1.0f); | |||
bool isPair; | |||
float bufValue, oldBufLeft[doBalance ? frames : 1]; | |||
for (i=0; i < kData->audioOut.count; ++i) | |||
for (i=0; i < pData->audioOut.count; ++i) | |||
{ | |||
// Dry/Wet | |||
if (doDryWet) | |||
@@ -1147,13 +1147,13 @@ public: | |||
for (k=0; k < frames; ++k) | |||
{ | |||
// TODO | |||
//if (k < kData->latency && kData->latency < frames) | |||
// bufValue = (kData->audioIn.count == 1) ? kData->latencyBuffers[0][k] : kData->latencyBuffers[i][k]; | |||
//if (k < pData->latency && pData->latency < frames) | |||
// bufValue = (pData->audioIn.count == 1) ? pData->latencyBuffers[0][k] : pData->latencyBuffers[i][k]; | |||
//else | |||
// bufValue = (kData->audioIn.count == 1) ? inBuffer[0][k-m_latency] : inBuffer[i][k-m_latency]; | |||
// bufValue = (pData->audioIn.count == 1) ? inBuffer[0][k-m_latency] : inBuffer[i][k-m_latency]; | |||
bufValue = fAudioInBuffers[(kData->audioIn.count == 1) ? 0 : i][k]; | |||
fAudioOutBuffers[i][k] = (fAudioOutBuffers[i][k] * kData->postProc.dryWet) + (bufValue * (1.0f - kData->postProc.dryWet)); | |||
bufValue = fAudioInBuffers[(pData->audioIn.count == 1) ? 0 : i][k]; | |||
fAudioOutBuffers[i][k] = (fAudioOutBuffers[i][k] * pData->postProc.dryWet) + (bufValue * (1.0f - pData->postProc.dryWet)); | |||
} | |||
} | |||
@@ -1164,12 +1164,12 @@ public: | |||
if (isPair) | |||
{ | |||
CARLA_ASSERT(i+1 < kData->audioOut.count); | |||
CARLA_ASSERT(i+1 < pData->audioOut.count); | |||
carla_copyFloat(oldBufLeft, fAudioOutBuffers[i], frames); | |||
} | |||
float balRangeL = (kData->postProc.balanceLeft + 1.0f)/2.0f; | |||
float balRangeR = (kData->postProc.balanceRight + 1.0f)/2.0f; | |||
float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f; | |||
float balRangeR = (pData->postProc.balanceRight + 1.0f)/2.0f; | |||
for (k=0; k < frames; ++k) | |||
{ | |||
@@ -1191,21 +1191,21 @@ public: | |||
// Volume (and buffer copy) | |||
{ | |||
for (k=0; k < frames; ++k) | |||
outBuffer[i][k+timeOffset] = fAudioOutBuffers[i][k] * kData->postProc.volume; | |||
outBuffer[i][k+timeOffset] = fAudioOutBuffers[i][k] * pData->postProc.volume; | |||
} | |||
} | |||
#if 0 | |||
// Latency, save values for next callback, TODO | |||
if (kData->latency > 0 && kData->latency < frames) | |||
if (pData->latency > 0 && pData->latency < frames) | |||
{ | |||
for (i=0; i < kData->audioIn.count; ++i) | |||
carla_copyFloat(kData->latencyBuffers[i], inBuffer[i] + (frames - kData->latency), kData->latency); | |||
for (i=0; i < pData->audioIn.count; ++i) | |||
carla_copyFloat(pData->latencyBuffers[i], inBuffer[i] + (frames - pData->latency), pData->latency); | |||
} | |||
#endif | |||
} // End of Post-processing | |||
#else | |||
for (i=0; i < kData->audioOut.count; ++i) | |||
for (i=0; i < pData->audioOut.count; ++i) | |||
{ | |||
for (k=0; k < frames; ++k) | |||
outBuffer[i][k+timeOffset] = fAudioOutBuffers[i][k]; | |||
@@ -1214,7 +1214,7 @@ public: | |||
// -------------------------------------------------------------------------------------------------------- | |||
kData->singleMutex.unlock(); | |||
pData->singleMutex.unlock(); | |||
return true; | |||
} | |||
@@ -1223,14 +1223,14 @@ public: | |||
CARLA_ASSERT_INT(newBufferSize > 0, newBufferSize); | |||
carla_debug("LadspaPlugin::bufferSizeChanged(%i) - start", newBufferSize); | |||
for (uint32_t i=0; i < kData->audioIn.count; ++i) | |||
for (uint32_t i=0; i < pData->audioIn.count; ++i) | |||
{ | |||
if (fAudioInBuffers[i] != nullptr) | |||
delete[] fAudioInBuffers[i]; | |||
fAudioInBuffers[i] = new float[newBufferSize]; | |||
} | |||
for (uint32_t i=0; i < kData->audioOut.count; ++i) | |||
for (uint32_t i=0; i < pData->audioOut.count; ++i) | |||
{ | |||
if (fAudioOutBuffers[i] != nullptr) | |||
delete[] fAudioOutBuffers[i]; | |||
@@ -1239,38 +1239,38 @@ public: | |||
if (fHandle2 == nullptr) | |||
{ | |||
for (uint32_t i=0; i < kData->audioIn.count; ++i) | |||
for (uint32_t i=0; i < pData->audioIn.count; ++i) | |||
{ | |||
CARLA_ASSERT(fAudioInBuffers[i] != nullptr); | |||
fDescriptor->connect_port(fHandle, kData->audioIn.ports[i].rindex, fAudioInBuffers[i]); | |||
fDescriptor->connect_port(fHandle, pData->audioIn.ports[i].rindex, fAudioInBuffers[i]); | |||
} | |||
for (uint32_t i=0; i < kData->audioOut.count; ++i) | |||
for (uint32_t i=0; i < pData->audioOut.count; ++i) | |||
{ | |||
CARLA_ASSERT(fAudioOutBuffers[i] != nullptr); | |||
fDescriptor->connect_port(fHandle, kData->audioOut.ports[i].rindex, fAudioOutBuffers[i]); | |||
fDescriptor->connect_port(fHandle, pData->audioOut.ports[i].rindex, fAudioOutBuffers[i]); | |||
} | |||
} | |||
else | |||
{ | |||
if (kData->audioIn.count > 0) | |||
if (pData->audioIn.count > 0) | |||
{ | |||
CARLA_ASSERT(kData->audioIn.count == 2); | |||
CARLA_ASSERT(pData->audioIn.count == 2); | |||
CARLA_ASSERT(fAudioInBuffers[0] != nullptr); | |||
CARLA_ASSERT(fAudioInBuffers[1] != nullptr); | |||
fDescriptor->connect_port(fHandle, kData->audioIn.ports[0].rindex, fAudioInBuffers[0]); | |||
fDescriptor->connect_port(fHandle2, kData->audioIn.ports[1].rindex, fAudioInBuffers[1]); | |||
fDescriptor->connect_port(fHandle, pData->audioIn.ports[0].rindex, fAudioInBuffers[0]); | |||
fDescriptor->connect_port(fHandle2, pData->audioIn.ports[1].rindex, fAudioInBuffers[1]); | |||
} | |||
if (kData->audioOut.count > 0) | |||
if (pData->audioOut.count > 0) | |||
{ | |||
CARLA_ASSERT(kData->audioOut.count == 2); | |||
CARLA_ASSERT(pData->audioOut.count == 2); | |||
CARLA_ASSERT(fAudioOutBuffers[0] != nullptr); | |||
CARLA_ASSERT(fAudioOutBuffers[1] != nullptr); | |||
fDescriptor->connect_port(fHandle, kData->audioOut.ports[0].rindex, fAudioOutBuffers[0]); | |||
fDescriptor->connect_port(fHandle2, kData->audioOut.ports[1].rindex, fAudioOutBuffers[1]); | |||
fDescriptor->connect_port(fHandle, pData->audioOut.ports[0].rindex, fAudioOutBuffers[0]); | |||
fDescriptor->connect_port(fHandle2, pData->audioOut.ports[1].rindex, fAudioOutBuffers[1]); | |||
} | |||
} | |||
@@ -1297,7 +1297,7 @@ public: | |||
if (fAudioInBuffers != nullptr) | |||
{ | |||
for (uint32_t i=0; i < kData->audioIn.count; ++i) | |||
for (uint32_t i=0; i < pData->audioIn.count; ++i) | |||
{ | |||
if (fAudioInBuffers[i] != nullptr) | |||
{ | |||
@@ -1312,7 +1312,7 @@ public: | |||
if (fAudioOutBuffers != nullptr) | |||
{ | |||
for (uint32_t i=0; i < kData->audioOut.count; ++i) | |||
for (uint32_t i=0; i < pData->audioOut.count; ++i) | |||
{ | |||
if (fAudioOutBuffers[i] != nullptr) | |||
{ | |||
@@ -1345,54 +1345,54 @@ public: | |||
bool init(const char* const filename, const char* const name, const char* const label, const LADSPA_RDF_Descriptor* const rdfDescriptor) | |||
{ | |||
CARLA_ASSERT(kData->engine != nullptr); | |||
CARLA_ASSERT(kData->client == nullptr); | |||
CARLA_ASSERT(pData->engine != nullptr); | |||
CARLA_ASSERT(pData->client == nullptr); | |||
CARLA_ASSERT(filename != nullptr); | |||
CARLA_ASSERT(label != nullptr); | |||
// --------------------------------------------------------------- | |||
// first checks | |||
if (kData->engine == nullptr) | |||
if (pData->engine == nullptr) | |||
{ | |||
return false; | |||
} | |||
if (kData->client != nullptr) | |||
if (pData->client != nullptr) | |||
{ | |||
kData->engine->setLastError("Plugin client is already registered"); | |||
pData->engine->setLastError("Plugin client is already registered"); | |||
return false; | |||
} | |||
if (filename == nullptr) | |||
{ | |||
kData->engine->setLastError("null filename"); | |||
pData->engine->setLastError("null filename"); | |||
return false; | |||
} | |||
if (label == nullptr) | |||
{ | |||
kData->engine->setLastError("null label"); | |||
pData->engine->setLastError("null label"); | |||
return false; | |||
} | |||
// --------------------------------------------------------------- | |||
// open DLL | |||
if (! kData->libOpen(filename)) | |||
if (! pData->libOpen(filename)) | |||
{ | |||
kData->engine->setLastError(kData->libError(filename)); | |||
pData->engine->setLastError(pData->libError(filename)); | |||
return false; | |||
} | |||
// --------------------------------------------------------------- | |||
// get DLL main entry | |||
const LADSPA_Descriptor_Function descFn = (LADSPA_Descriptor_Function)kData->libSymbol("ladspa_descriptor"); | |||
const LADSPA_Descriptor_Function descFn = (LADSPA_Descriptor_Function)pData->libSymbol("ladspa_descriptor"); | |||
if (descFn == nullptr) | |||
{ | |||
kData->engine->setLastError("Could not find the LASDPA Descriptor in the plugin library"); | |||
pData->engine->setLastError("Could not find the LASDPA Descriptor in the plugin library"); | |||
return false; | |||
} | |||
@@ -1408,7 +1408,7 @@ public: | |||
if (fDescriptor == nullptr) | |||
{ | |||
kData->engine->setLastError("Could not find the requested plugin label in the plugin library"); | |||
pData->engine->setLastError("Could not find the requested plugin label in the plugin library"); | |||
return false; | |||
} | |||
@@ -1419,35 +1419,35 @@ public: | |||
fRdfDescriptor = ladspa_rdf_dup(rdfDescriptor); | |||
if (name != nullptr) | |||
fName = kData->engine->getUniquePluginName(name); | |||
fName = pData->engine->getUniquePluginName(name); | |||
else if (fRdfDescriptor != nullptr && fRdfDescriptor->Title != nullptr) | |||
fName = kData->engine->getUniquePluginName(fRdfDescriptor->Title); | |||
fName = pData->engine->getUniquePluginName(fRdfDescriptor->Title); | |||
else if (fDescriptor->Name != nullptr) | |||
fName = kData->engine->getUniquePluginName(fDescriptor->Name); | |||
fName = pData->engine->getUniquePluginName(fDescriptor->Name); | |||
else | |||
fName = kData->engine->getUniquePluginName(fDescriptor->Label); | |||
fName = pData->engine->getUniquePluginName(fDescriptor->Label); | |||
fFilename = filename; | |||
// --------------------------------------------------------------- | |||
// register client | |||
kData->client = kData->engine->addClient(this); | |||
pData->client = pData->engine->addClient(this); | |||
if (kData->client == nullptr || ! kData->client->isOk()) | |||
if (pData->client == nullptr || ! pData->client->isOk()) | |||
{ | |||
kData->engine->setLastError("Failed to register plugin client"); | |||
pData->engine->setLastError("Failed to register plugin client"); | |||
return false; | |||
} | |||
// --------------------------------------------------------------- | |||
// initialize plugin | |||
fHandle = fDescriptor->instantiate(fDescriptor, (unsigned long)kData->engine->getSampleRate()); | |||
fHandle = fDescriptor->instantiate(fDescriptor, (unsigned long)pData->engine->getSampleRate()); | |||
if (fHandle == nullptr) | |||
{ | |||
kData->engine->setLastError("Plugin failed to initialize"); | |||
pData->engine->setLastError("Plugin failed to initialize"); | |||
return false; | |||
} | |||
@@ -1467,17 +1467,17 @@ public: | |||
if (isDssiVst) | |||
fOptions |= PLUGIN_OPTION_FIXED_BUFFER; | |||
if (kData->engine->getOptions().forceStereo) | |||
if (pData->engine->getOptions().forceStereo) | |||
fOptions |= PLUGIN_OPTION_FORCE_STEREO; | |||
// load settings | |||
kData->idStr = "LADSPA/"; | |||
kData->idStr += std::strrchr(filename, OS_SEP)+1; | |||
kData->idStr += "/"; | |||
kData->idStr += CarlaString(uniqueId()); | |||
kData->idStr += "/"; | |||
kData->idStr += label; | |||
fOptions = kData->loadSettings(fOptions, availableOptions()); | |||
pData->idStr = "LADSPA/"; | |||
pData->idStr += std::strrchr(filename, OS_SEP)+1; | |||
pData->idStr += "/"; | |||
pData->idStr += CarlaString(uniqueId()); | |||
pData->idStr += "/"; | |||
pData->idStr += label; | |||
fOptions = pData->loadSettings(fOptions, availableOptions()); | |||
// ignore settings, we need this anyway | |||
if (isDssiVst) | |||
@@ -182,16 +182,16 @@ public: | |||
{ | |||
carla_debug("LinuxSamplerPlugin::~LinuxSamplerPlugin()"); | |||
kData->singleMutex.lock(); | |||
kData->masterMutex.lock(); | |||
pData->singleMutex.lock(); | |||
pData->masterMutex.lock(); | |||
if (kData->client != nullptr && kData->client->isActive()) | |||
kData->client->deactivate(); | |||
if (pData->client != nullptr && pData->client->isActive()) | |||
pData->client->deactivate(); | |||
if (kData->active) | |||
if (pData->active) | |||
{ | |||
deactivate(); | |||
kData->active = false; | |||
pData->active = false; | |||
} | |||
if (fEngine != nullptr) | |||
@@ -291,25 +291,25 @@ public: | |||
void setMidiProgram(int32_t index, const bool sendGui, const bool sendOsc, const bool sendCallback) override | |||
{ | |||
CARLA_ASSERT(index >= -1 && index < static_cast<int32_t>(kData->midiprog.count)); | |||
CARLA_ASSERT(index >= -1 && index < static_cast<int32_t>(pData->midiprog.count)); | |||
if (index < -1) | |||
index = -1; | |||
else if (index > static_cast<int32_t>(kData->midiprog.count)) | |||
else if (index > static_cast<int32_t>(pData->midiprog.count)) | |||
return; | |||
if (kData->ctrlChannel < 0 || kData->ctrlChannel >= 16) | |||
if (pData->ctrlChannel < 0 || pData->ctrlChannel >= 16) | |||
return; | |||
if (index >= 0) | |||
{ | |||
const uint32_t bank = kData->midiprog.data[index].bank; | |||
const uint32_t program = kData->midiprog.data[index].program; | |||
const uint32_t bank = pData->midiprog.data[index].bank; | |||
const uint32_t program = pData->midiprog.data[index].program; | |||
const uint32_t rIndex = bank*128 + program; | |||
const ScopedSingleProcessLocker spl(this, (sendGui || sendOsc || sendCallback)); | |||
if (kData->engine->isOffline()) | |||
if (pData->engine->isOffline()) | |||
{ | |||
fEngineChannel->PrepareLoadInstrument((const char*)fFilename, rIndex); | |||
fEngineChannel->LoadInstrument(); | |||
@@ -329,20 +329,20 @@ public: | |||
void reload() override | |||
{ | |||
carla_debug("LinuxSamplerPlugin::reload() - start"); | |||
CARLA_ASSERT(kData->engine != nullptr); | |||
CARLA_ASSERT(pData->engine != nullptr); | |||
CARLA_ASSERT(fInstrument != nullptr); | |||
if (kData->engine == nullptr) | |||
if (pData->engine == nullptr) | |||
return; | |||
if (fInstrument == nullptr) | |||
return; | |||
const ProcessMode processMode(kData->engine->getProccessMode()); | |||
const ProcessMode processMode(pData->engine->getProccessMode()); | |||
// Safely disable plugin for reload | |||
const ScopedDisabler sd(this); | |||
if (kData->active) | |||
if (pData->active) | |||
deactivate(); | |||
clearBuffers(); | |||
@@ -350,9 +350,9 @@ public: | |||
uint32_t aOuts; | |||
aOuts = 2; | |||
kData->audioOut.createNew(aOuts); | |||
pData->audioOut.createNew(aOuts); | |||
const int portNameSize = kData->engine->maxPortNameSize(); | |||
const int portNameSize = pData->engine->maxPortNameSize(); | |||
CarlaString portName; | |||
// --------------------------------------- | |||
@@ -371,8 +371,8 @@ public: | |||
portName += "out-left"; | |||
portName.truncate(portNameSize); | |||
kData->audioOut.ports[0].port = (CarlaEngineAudioPort*)kData->client->addPort(kEnginePortTypeAudio, portName, false); | |||
kData->audioOut.ports[0].rindex = 0; | |||
pData->audioOut.ports[0].port = (CarlaEngineAudioPort*)pData->client->addPort(kEnginePortTypeAudio, portName, false); | |||
pData->audioOut.ports[0].rindex = 0; | |||
// out-right | |||
portName.clear(); | |||
@@ -386,8 +386,8 @@ public: | |||
portName += "out-right"; | |||
portName.truncate(portNameSize); | |||
kData->audioOut.ports[1].port = (CarlaEngineAudioPort*)kData->client->addPort(kEnginePortTypeAudio, portName, false); | |||
kData->audioOut.ports[1].rindex = 1; | |||
pData->audioOut.ports[1].port = (CarlaEngineAudioPort*)pData->client->addPort(kEnginePortTypeAudio, portName, false); | |||
pData->audioOut.ports[1].rindex = 1; | |||
} | |||
// --------------------------------------- | |||
@@ -405,7 +405,7 @@ public: | |||
portName += "event-in"; | |||
portName.truncate(portNameSize); | |||
kData->event.portIn = (CarlaEngineEventPort*)kData->client->addPort(kEnginePortTypeEvent, portName, true); | |||
pData->event.portIn = (CarlaEngineEventPort*)pData->client->addPort(kEnginePortTypeEvent, portName, true); | |||
} | |||
// --------------------------------------- | |||
@@ -417,14 +417,14 @@ public: | |||
fHints |= PLUGIN_CAN_BALANCE; | |||
// extra plugin hints | |||
kData->extraHints = 0x0; | |||
kData->extraHints |= PLUGIN_HINT_HAS_MIDI_IN; | |||
kData->extraHints |= PLUGIN_HINT_CAN_RUN_RACK; | |||
pData->extraHints = 0x0; | |||
pData->extraHints |= PLUGIN_HINT_HAS_MIDI_IN; | |||
pData->extraHints |= PLUGIN_HINT_CAN_RUN_RACK; | |||
bufferSizeChanged(kData->engine->getBufferSize()); | |||
bufferSizeChanged(pData->engine->getBufferSize()); | |||
reloadPrograms(true); | |||
if (kData->active) | |||
if (pData->active) | |||
activate(); | |||
carla_debug("LinuxSamplerPlugin::reload() - end"); | |||
@@ -435,7 +435,7 @@ public: | |||
carla_debug("LinuxSamplerPlugin::reloadPrograms(%s)", bool2str(init)); | |||
// Delete old programs | |||
kData->midiprog.clear(); | |||
pData->midiprog.clear(); | |||
// Query new programs | |||
uint32_t i, count = fInstrumentIds.size(); | |||
@@ -446,14 +446,14 @@ public: | |||
if (count == 0) | |||
return; | |||
kData->midiprog.createNew(count); | |||
pData->midiprog.createNew(count); | |||
LinuxSampler::InstrumentManager::instrument_info_t info; | |||
for (i=0; i < kData->midiprog.count; ++i) | |||
for (i=0; i < pData->midiprog.count; ++i) | |||
{ | |||
kData->midiprog.data[i].bank = i / 128; | |||
kData->midiprog.data[i].program = i % 128; | |||
pData->midiprog.data[i].bank = i / 128; | |||
pData->midiprog.data[i].program = i % 128; | |||
try { | |||
info = fInstrument->GetInstrumentInfo(fInstrumentIds[i]); | |||
@@ -463,17 +463,17 @@ public: | |||
continue; | |||
} | |||
kData->midiprog.data[i].name = carla_strdup(info.InstrumentName.c_str()); | |||
pData->midiprog.data[i].name = carla_strdup(info.InstrumentName.c_str()); | |||
} | |||
#ifndef BUILD_BRIDGE | |||
// Update OSC Names | |||
if (kData->engine->isOscControlRegistered()) | |||
if (pData->engine->isOscControlRegistered()) | |||
{ | |||
kData->engine->osc_send_control_set_midi_program_count(fId, count); | |||
pData->engine->osc_send_control_set_midi_program_count(fId, count); | |||
for (i=0; i < count; ++i) | |||
kData->engine->osc_send_control_set_midi_program_data(fId, i, kData->midiprog.data[i].bank, kData->midiprog.data[i].program, kData->midiprog.data[i].name); | |||
pData->engine->osc_send_control_set_midi_program_data(fId, i, pData->midiprog.data[i].bank, pData->midiprog.data[i].program, pData->midiprog.data[i].name); | |||
} | |||
#endif | |||
@@ -483,7 +483,7 @@ public: | |||
} | |||
else | |||
{ | |||
kData->engine->callback(CALLBACK_RELOAD_PROGRAMS, fId, 0, 0, 0.0f, nullptr); | |||
pData->engine->callback(CALLBACK_RELOAD_PROGRAMS, fId, 0, 0, 0.0f, nullptr); | |||
} | |||
} | |||
@@ -511,10 +511,10 @@ public: | |||
// -------------------------------------------------------------------------------------------------------- | |||
// Check if active | |||
if (! kData->active) | |||
if (! pData->active) | |||
{ | |||
// disable any output sound | |||
for (i=0; i < kData->audioOut.count; ++i) | |||
for (i=0; i < pData->audioOut.count; ++i) | |||
carla_zeroFloat(outBuffer[i], frames); | |||
return; | |||
@@ -523,7 +523,7 @@ public: | |||
// -------------------------------------------------------------------------------------------------------- | |||
// Check if needs reset | |||
if (kData->needsReset) | |||
if (pData->needsReset) | |||
{ | |||
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF) | |||
{ | |||
@@ -533,13 +533,13 @@ public: | |||
fMidiInputPort->DispatchControlChange(MIDI_CONTROL_ALL_SOUND_OFF, 0, k); | |||
} | |||
} | |||
else if (kData->ctrlChannel >= 0 && kData->ctrlChannel < MAX_MIDI_CHANNELS) | |||
else if (pData->ctrlChannel >= 0 && pData->ctrlChannel < MAX_MIDI_CHANNELS) | |||
{ | |||
for (k=0; k < MAX_MIDI_NOTE; ++k) | |||
fMidiInputPort->DispatchNoteOff(k, 0, kData->ctrlChannel); | |||
fMidiInputPort->DispatchNoteOff(k, 0, pData->ctrlChannel); | |||
} | |||
kData->needsReset = false; | |||
pData->needsReset = false; | |||
} | |||
// -------------------------------------------------------------------------------------------------------- | |||
@@ -549,11 +549,11 @@ public: | |||
// ---------------------------------------------------------------------------------------------------- | |||
// MIDI Input (External) | |||
if (kData->extNotes.mutex.tryLock()) | |||
if (pData->extNotes.mutex.tryLock()) | |||
{ | |||
while (! kData->extNotes.data.isEmpty()) | |||
while (! pData->extNotes.data.isEmpty()) | |||
{ | |||
const ExternalMidiNote& note(kData->extNotes.data.getFirst(true)); | |||
const ExternalMidiNote& note(pData->extNotes.data.getFirst(true)); | |||
CARLA_ASSERT(note.channel >= 0 && note.channel < MAX_MIDI_CHANNELS); | |||
@@ -563,7 +563,7 @@ public: | |||
fMidiInputPort->DispatchNoteOff(note.note, note.velo, note.channel, 0); | |||
} | |||
kData->extNotes.mutex.unlock(); | |||
pData->extNotes.mutex.unlock(); | |||
} // End of MIDI Input (External) | |||
@@ -573,17 +573,17 @@ public: | |||
bool allNotesOffSent = false; | |||
bool sampleAccurate = (fOptions & PLUGIN_OPTION_FIXED_BUFFER) == 0; | |||
uint32_t time, nEvents = kData->event.portIn->getEventCount(); | |||
uint32_t time, nEvents = pData->event.portIn->getEventCount(); | |||
uint32_t startTime = 0; | |||
uint32_t timeOffset = 0; | |||
uint32_t nextBankId = 0; | |||
if (kData->midiprog.current >= 0 && kData->midiprog.count > 0) | |||
nextBankId = kData->midiprog.data[kData->midiprog.current].bank; | |||
if (pData->midiprog.current >= 0 && pData->midiprog.count > 0) | |||
nextBankId = pData->midiprog.data[pData->midiprog.current].bank; | |||
for (i=0; i < nEvents; ++i) | |||
{ | |||
const EngineEvent& event(kData->event.portIn->getEvent(i)); | |||
const EngineEvent& event(pData->event.portIn->getEvent(i)); | |||
time = event.time; | |||
@@ -599,8 +599,8 @@ public: | |||
startTime = 0; | |||
timeOffset = time; | |||
if (kData->midiprog.current >= 0 && kData->midiprog.count > 0) | |||
nextBankId = kData->midiprog.data[kData->midiprog.current].bank; | |||
if (pData->midiprog.current >= 0 && pData->midiprog.count > 0) | |||
nextBankId = pData->midiprog.data[pData->midiprog.current].bank; | |||
else | |||
nextBankId = 0; | |||
} | |||
@@ -627,7 +627,7 @@ public: | |||
{ | |||
#ifndef BUILD_BRIDGE | |||
// Control backend stuff | |||
if (event.channel == kData->ctrlChannel) | |||
if (event.channel == pData->ctrlChannel) | |||
{ | |||
float value; | |||
@@ -675,28 +675,28 @@ public: | |||
#endif | |||
// Control plugin parameters | |||
for (k=0; k < kData->param.count; ++k) | |||
for (k=0; k < pData->param.count; ++k) | |||
{ | |||
if (kData->param.data[k].midiChannel != event.channel) | |||
if (pData->param.data[k].midiChannel != event.channel) | |||
continue; | |||
if (kData->param.data[k].midiCC != ctrlEvent.param) | |||
if (pData->param.data[k].midiCC != ctrlEvent.param) | |||
continue; | |||
if (kData->param.data[k].type != PARAMETER_INPUT) | |||
if (pData->param.data[k].type != PARAMETER_INPUT) | |||
continue; | |||
if ((kData->param.data[k].hints & PARAMETER_IS_AUTOMABLE) == 0) | |||
if ((pData->param.data[k].hints & PARAMETER_IS_AUTOMABLE) == 0) | |||
continue; | |||
double value; | |||
if (kData->param.data[k].hints & PARAMETER_IS_BOOLEAN) | |||
if (pData->param.data[k].hints & PARAMETER_IS_BOOLEAN) | |||
{ | |||
value = (ctrlEvent.value < 0.5f) ? kData->param.ranges[k].min : kData->param.ranges[k].max; | |||
value = (ctrlEvent.value < 0.5f) ? pData->param.ranges[k].min : pData->param.ranges[k].max; | |||
} | |||
else | |||
{ | |||
value = kData->param.ranges[k].unnormalizeValue(ctrlEvent.value); | |||
value = pData->param.ranges[k].unnormalizeValue(ctrlEvent.value); | |||
if (kData->param.data[k].hints & PARAMETER_IS_INTEGER) | |||
if (pData->param.data[k].hints & PARAMETER_IS_INTEGER) | |||
value = std::rint(value); | |||
} | |||
@@ -713,18 +713,18 @@ public: | |||
} | |||
case kEngineControlEventTypeMidiBank: | |||
if (event.channel == kData->ctrlChannel && (fOptions & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0) | |||
if (event.channel == pData->ctrlChannel && (fOptions & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0) | |||
nextBankId = ctrlEvent.param; | |||
break; | |||
case kEngineControlEventTypeMidiProgram: | |||
if (event.channel == kData->ctrlChannel && (fOptions & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0) | |||
if (event.channel == pData->ctrlChannel && (fOptions & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0) | |||
{ | |||
const uint32_t nextProgramId = ctrlEvent.param; | |||
for (k=0; k < kData->midiprog.count; ++k) | |||
for (k=0; k < pData->midiprog.count; ++k) | |||
{ | |||
if (kData->midiprog.data[k].bank == nextBankId && kData->midiprog.data[k].program == nextProgramId) | |||
if (pData->midiprog.data[k].bank == nextBankId && pData->midiprog.data[k].program == nextProgramId) | |||
{ | |||
setMidiProgram(k, false, false, false); | |||
postponeRtEvent(kPluginPostRtEventMidiProgramChange, k, 0, 0.0f); | |||
@@ -744,7 +744,7 @@ public: | |||
case kEngineControlEventTypeAllNotesOff: | |||
if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF) | |||
{ | |||
if (event.channel == kData->ctrlChannel && ! allNotesOffSent) | |||
if (event.channel == pData->ctrlChannel && ! allNotesOffSent) | |||
{ | |||
allNotesOffSent = true; | |||
sendMidiAllNotesOffToCallback(); | |||
@@ -821,7 +821,7 @@ public: | |||
} | |||
} | |||
kData->postRtEvents.trySplice(); | |||
pData->postRtEvents.trySplice(); | |||
if (frames > timeOffset) | |||
processSingle(outBuffer, frames - timeOffset, timeOffset); | |||
@@ -844,13 +844,13 @@ public: | |||
// -------------------------------------------------------------------------------------------------------- | |||
// Try lock, silence otherwise | |||
if (kData->engine->isOffline()) | |||
if (pData->engine->isOffline()) | |||
{ | |||
kData->singleMutex.lock(); | |||
pData->singleMutex.lock(); | |||
} | |||
else if (! kData->singleMutex.tryLock()) | |||
else if (! pData->singleMutex.tryLock()) | |||
{ | |||
for (i=0; i < kData->audioOut.count; ++i) | |||
for (i=0; i < pData->audioOut.count; ++i) | |||
{ | |||
for (k=0; k < frames; ++k) | |||
outBuffer[i][k+timeOffset] = 0.0f; | |||
@@ -872,12 +872,12 @@ public: | |||
// Post-processing (dry/wet, volume and balance) | |||
{ | |||
const bool doVolume = (fHints & PLUGIN_CAN_VOLUME) > 0 && kData->postProc.volume != 1.0f; | |||
const bool doBalance = (fHints & PLUGIN_CAN_BALANCE) > 0 && (kData->postProc.balanceLeft != -1.0f || kData->postProc.balanceRight != 1.0f); | |||
const bool doVolume = (fHints & PLUGIN_CAN_VOLUME) > 0 && pData->postProc.volume != 1.0f; | |||
const bool doBalance = (fHints & PLUGIN_CAN_BALANCE) > 0 && (pData->postProc.balanceLeft != -1.0f || pData->postProc.balanceRight != 1.0f); | |||
float oldBufLeft[doBalance ? frames : 1]; | |||
for (i=0; i < kData->audioOut.count; ++i) | |||
for (i=0; i < pData->audioOut.count; ++i) | |||
{ | |||
// Balance | |||
if (doBalance) | |||
@@ -885,8 +885,8 @@ public: | |||
if (i % 2 == 0) | |||
carla_copyFloat(oldBufLeft, outBuffer[i], frames); | |||
float balRangeL = (kData->postProc.balanceLeft + 1.0f)/2.0f; | |||
float balRangeR = (kData->postProc.balanceRight + 1.0f)/2.0f; | |||
float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f; | |||
float balRangeR = (pData->postProc.balanceRight + 1.0f)/2.0f; | |||
for (k=0; k < frames; ++k) | |||
{ | |||
@@ -909,7 +909,7 @@ public: | |||
if (doVolume) | |||
{ | |||
for (k=0; k < frames; ++k) | |||
outBuffer[i][k+timeOffset] *= kData->postProc.volume; | |||
outBuffer[i][k+timeOffset] *= pData->postProc.volume; | |||
} | |||
} | |||
@@ -918,7 +918,7 @@ public: | |||
// -------------------------------------------------------------------------------------------------------- | |||
kData->singleMutex.unlock(); | |||
pData->singleMutex.unlock(); | |||
return true; | |||
} | |||
@@ -936,34 +936,34 @@ public: | |||
bool init(const char* filename, const char* const name, const char* label) | |||
{ | |||
CARLA_ASSERT(kData->engine != nullptr); | |||
CARLA_ASSERT(kData->client == nullptr); | |||
CARLA_ASSERT(pData->engine != nullptr); | |||
CARLA_ASSERT(pData->client == nullptr); | |||
CARLA_ASSERT(filename != nullptr); | |||
CARLA_ASSERT(label != nullptr); | |||
// --------------------------------------------------------------- | |||
// first checks | |||
if (kData->engine == nullptr) | |||
if (pData->engine == nullptr) | |||
{ | |||
return false; | |||
} | |||
if (kData->client != nullptr) | |||
if (pData->client != nullptr) | |||
{ | |||
kData->engine->setLastError("Plugin client is already registered"); | |||
pData->engine->setLastError("Plugin client is already registered"); | |||
return false; | |||
} | |||
if (filename == nullptr) | |||
{ | |||
kData->engine->setLastError("null filename"); | |||
pData->engine->setLastError("null filename"); | |||
return false; | |||
} | |||
if (label == nullptr) | |||
{ | |||
kData->engine->setLastError("null label"); | |||
pData->engine->setLastError("null label"); | |||
return false; | |||
} | |||
@@ -974,7 +974,7 @@ public: | |||
if (! (file.exists() && file.isFile() && file.isReadable())) | |||
{ | |||
kData->engine->setLastError("Requested file is not valid or does not exist"); | |||
pData->engine->setLastError("Requested file is not valid or does not exist"); | |||
return false; | |||
} | |||
} | |||
@@ -989,7 +989,7 @@ public: | |||
} | |||
catch (LinuxSampler::Exception& e) | |||
{ | |||
kData->engine->setLastError(e.what()); | |||
pData->engine->setLastError(e.what()); | |||
return false; | |||
} | |||
@@ -1000,7 +1000,7 @@ public: | |||
if (fInstrument == nullptr) | |||
{ | |||
kData->engine->setLastError("Failed to get LinuxSampler instrument manager"); | |||
pData->engine->setLastError("Failed to get LinuxSampler instrument manager"); | |||
LinuxSampler::EngineFactory::Destroy(fEngine); | |||
fEngine = nullptr; | |||
return false; | |||
@@ -1014,7 +1014,7 @@ public: | |||
} | |||
catch (const LinuxSampler::InstrumentManagerException& e) | |||
{ | |||
kData->engine->setLastError(e.what()); | |||
pData->engine->setLastError(e.what()); | |||
LinuxSampler::EngineFactory::Destroy(fEngine); | |||
fEngine = nullptr; | |||
return false; | |||
@@ -1025,7 +1025,7 @@ public: | |||
if (fInstrumentIds.size() == 0) | |||
{ | |||
kData->engine->setLastError("Failed to find any instruments"); | |||
pData->engine->setLastError("Failed to find any instruments"); | |||
LinuxSampler::EngineFactory::Destroy(fEngine); | |||
fEngine = nullptr; | |||
return false; | |||
@@ -1038,7 +1038,7 @@ public: | |||
} | |||
catch (const LinuxSampler::InstrumentManagerException& e) | |||
{ | |||
kData->engine->setLastError(e.what()); | |||
pData->engine->setLastError(e.what()); | |||
LinuxSampler::EngineFactory::Destroy(fEngine); | |||
fEngine = nullptr; | |||
return false; | |||
@@ -1053,18 +1053,18 @@ public: | |||
fLabel += " (16 outs)"; | |||
if (name != nullptr) | |||
fName = kData->engine->getUniquePluginName(name); | |||
fName = pData->engine->getUniquePluginName(name); | |||
else | |||
fName = kData->engine->getUniquePluginName((const char*)fRealName); | |||
fName = pData->engine->getUniquePluginName((const char*)fRealName); | |||
// --------------------------------------------------------------- | |||
// Register client | |||
kData->client = kData->engine->addClient(this); | |||
pData->client = pData->engine->addClient(this); | |||
if (kData->client == nullptr || ! kData->client->isOk()) | |||
if (pData->client == nullptr || ! pData->client->isOk()) | |||
{ | |||
kData->engine->setLastError("Failed to register plugin client"); | |||
pData->engine->setLastError("Failed to register plugin client"); | |||
LinuxSampler::EngineFactory::Destroy(fEngine); | |||
fEngine = nullptr; | |||
return false; | |||
@@ -1095,10 +1095,10 @@ public: | |||
fOptions |= PLUGIN_OPTION_SEND_ALL_SOUND_OFF; | |||
// load settings | |||
kData->idStr = kIsGIG ? "GIG" : "SFZ"; | |||
kData->idStr += "/"; | |||
kData->idStr += label; | |||
fOptions = kData->loadSettings(fOptions, availableOptions()); | |||
pData->idStr = kIsGIG ? "GIG" : "SFZ"; | |||
pData->idStr += "/"; | |||
pData->idStr += label; | |||
fOptions = pData->loadSettings(fOptions, availableOptions()); | |||
} | |||
return true; | |||
@@ -36,11 +36,11 @@ public: | |||
{ | |||
carla_debug("Vst3Plugin::~Vst3Plugin()"); | |||
kData->singleMutex.lock(); | |||
kData->masterMutex.lock(); | |||
pData->singleMutex.lock(); | |||
pData->masterMutex.lock(); | |||
if (kData->client != nullptr && kData->client->isActive()) | |||
kData->client->deactivate(); | |||
if (pData->client != nullptr && pData->client->isActive()) | |||
pData->client->deactivate(); | |||
} | |||
// ------------------------------------------------------------------- | |||
@@ -575,14 +575,14 @@ void carla_set_engine_option(CarlaOptionsType option, int value, const char* val | |||
#endif | |||
case CB::OPTION_MAX_PARAMETERS: | |||
if (value <= 0) | |||
if (value < 1) | |||
return carla_stderr2("carla_set_engine_option(OPTION_MAX_PARAMETERS, %i, \"%s\") - invalid value", value, valueStr); | |||
gStandalone.options.maxParameters = static_cast<unsigned int>(value); | |||
break; | |||
case CB::OPTION_UI_BRIDGES_TIMEOUT: | |||
if (value <= 0) | |||
if (value < 1) | |||
return carla_stderr2("carla_set_engine_option(OPTION_UI_BRIDGES_TIMEOUT, %i, \"%s\") - invalid value", value, valueStr); | |||
gStandalone.options.uiBridgesTimeout = static_cast<unsigned int>(value); | |||
@@ -590,21 +590,21 @@ void carla_set_engine_option(CarlaOptionsType option, int value, const char* val | |||
#ifdef WANT_RTAUDIO | |||
case CB::OPTION_RTAUDIO_NUMBER_PERIODS: | |||
if (value <= 0 || value > 3) | |||
if (value < 2 || value > 3) | |||
return carla_stderr2("carla_set_engine_option(OPTION_RTAUDIO_NUMBER_PERIODS, %i, \"%s\") - invalid value", value, valueStr); | |||
gStandalone.options.rtaudioNumPeriods = static_cast<unsigned int>(value); | |||
break; | |||
case CB::OPTION_RTAUDIO_BUFFER_SIZE: | |||
if (value <= 0) | |||
if (value < 8) | |||
return carla_stderr2("carla_set_engine_option(OPTION_RTAUDIO_BUFFER_SIZE, %i, \"%s\") - invalid value", value, valueStr); | |||
gStandalone.options.rtaudioBufferSize = static_cast<unsigned int>(value); | |||
break; | |||
case CB::OPTION_RTAUDIO_SAMPLE_RATE: | |||
if (value <= 0) | |||
if (value < 22050) | |||
return carla_stderr2("carla_set_engine_option(OPTION_RTAUDIO_SAMPLE_RATE, %i, \"%s\") - invalid value", value, valueStr); | |||
gStandalone.options.rtaudioSampleRate = static_cast<unsigned int>(value); | |||
@@ -267,9 +267,9 @@ public: | |||
{ | |||
data = list_entry(entry, Data, siblings); | |||
CARLA_ASSERT(data != nullptr); | |||
CARLA_SAFE_ASSERT_CONTINUE(data != nullptr) | |||
if (data != nullptr && data->value == value) | |||
if (data->value == value) | |||
{ | |||
--fCount; | |||
list_del(entry); | |||
@@ -283,6 +283,29 @@ public: | |||
return (data != nullptr); | |||
} | |||
void removeAll(const T& value) | |||
{ | |||
Data* data; | |||
k_list_head* entry; | |||
k_list_head* entry2; | |||
list_for_each_safe(entry, entry2, &fQueue) | |||
{ | |||
data = list_entry(entry, Data, siblings); | |||
CARLA_SAFE_ASSERT_CONTINUE(data != nullptr) | |||
if (data->value == value) | |||
{ | |||
--fCount; | |||
list_del(entry); | |||
data->~Data(); | |||
_deallocate(data); | |||
} | |||
} | |||
} | |||
void spliceAppend(List& list, const bool init = true) | |||
{ | |||
if (init) | |||