diff --git a/source/backend/engine/CarlaEngine.cpp b/source/backend/engine/CarlaEngine.cpp index cc2df299b..e9bae8d9a 100644 --- a/source/backend/engine/CarlaEngine.cpp +++ b/source/backend/engine/CarlaEngine.cpp @@ -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(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(value); -#endif - break; - - case OPTION_MAX_PARAMETERS: - CARLA_ENGINE_SET_OPTION_RUNNING_CHECK - - if (value < 0) - return; // TODO error here - - fOptions.maxParameters = static_cast(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(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(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(value); break; #ifdef WANT_RTAUDIO case OPTION_RTAUDIO_NUMBER_PERIODS: - CARLA_ENGINE_SET_OPTION_RUNNING_CHECK - fOptions.rtaudioNumberPeriods = static_cast(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(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(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(value); break; case OPTION_RTAUDIO_DEVICE: - CARLA_ENGINE_SET_OPTION_RUNNING_CHECK fOptions.rtaudioDevice = valueStr; break; #endif diff --git a/source/backend/engine/CarlaEngineJack.cpp b/source/backend/engine/CarlaEngineJack.cpp index d969308ff..0ad5e2b66 100644 --- a/source/backend/engine/CarlaEngineJack.cpp +++ b/source/backend/engine/CarlaEngineJack.cpp @@ -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(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(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(kData->bufEvents.in, INTERNAL_EVENT_COUNT); + carla_zeroStruct(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); diff --git a/source/backend/engine/CarlaEngineNative.cpp b/source/backend/engine/CarlaEngineNative.cpp index c33541155..eb419f280 100644 --- a/source/backend/engine/CarlaEngineNative.cpp +++ b/source/backend/engine/CarlaEngineNative.cpp @@ -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(kData->bufEvents.in, INTERNAL_EVENT_COUNT); + carla_zeroStruct(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(" \n").arg(xmlSafeString(strBuf, true)); + QString content; + fillXmlStringFromSaveState(content, plugin->getSaveState()); + out << " \n"; - out << getXMLFromSaveState(plugin->getSaveState()); + out << content; out << " \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); } diff --git a/source/backend/engine/CarlaEngineOsc.cpp b/source/backend/engine/CarlaEngineOsc.cpp index d3783f138..716be49f4 100644 --- a/source/backend/engine/CarlaEngineOsc.cpp +++ b/source/backend/engine/CarlaEngineOsc.cpp @@ -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(plugin->programCount())) + if (program < static_cast(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; } diff --git a/source/backend/engine/CarlaEngineRtAudio.cpp b/source/backend/engine/CarlaEngineRtAudio.cpp index 07d4b1fcd..b3ead8845 100644 --- a/source/backend/engine/CarlaEngineRtAudio.cpp +++ b/source/backend/engine/CarlaEngineRtAudio.cpp @@ -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 diff --git a/source/backend/engine/CarlaEngineThread.cpp b/source/backend/engine/CarlaEngineThread.cpp index 4b2f72e80..9180e9ac0 100644 --- a/source/backend/engine/CarlaEngineThread.cpp +++ b/source/backend/engine/CarlaEngineThread.cpp @@ -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); } } diff --git a/source/backend/plugin/BridgePlugin.cpp b/source/backend/plugin/BridgePlugin.cpp index 9d1c6be95..bc29e0bf8 100644 --- a/source/backend/plugin/BridgePlugin.cpp +++ b/source/backend/plugin/BridgePlugin.cpp @@ -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(kData->prog.count)); + CARLA_ASSERT(index >= -1 && index < static_cast(pData->prog.count)); if (index < -1) index = -1; - else if (index > static_cast(kData->prog.count)) + else if (index > static_cast(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(kData->midiprog.count)); + CARLA_ASSERT(index >= -1 && index < static_cast(pData->midiprog.count)); if (index < -1) index = -1; - else if (index > static_cast(kData->midiprog.count)) + else if (index > static_cast(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(kData->engine->getOptions().maxParameters), pTotal, kData->engine->getOptions().maxParameters); + CARLA_SAFE_ASSERT_INT2(pTotal < static_cast(pData->engine->getOptions().maxParameters), pTotal, pData->engine->getOptions().maxParameters); - const int32_t count(carla_min(pTotal, kData->engine->getOptions().maxParameters, 0)); + const int32_t count(carla_min(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(kData->param.count), index, kData->param.count); + CARLA_ASSERT_INT2(index >= 0 && index < static_cast(pData->param.count), index, pData->param.count); CARLA_ASSERT(name != nullptr); CARLA_ASSERT(unit != nullptr); - if (index >= 0 && static_cast(kData->param.count)) + if (index >= 0 && static_cast(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(kData->param.count), index, kData->param.count); + CARLA_ASSERT_INT2(index >= 0 && index < static_cast(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(kData->param.count)) + if (index >= 0 && static_cast(pData->param.count)) { - kData->param.data[index].type = static_cast(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(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(kData->param.count), index, kData->param.count); + CARLA_ASSERT_INT2(index >= 0 && index < static_cast(pData->param.count), index, pData->param.count); CARLA_ASSERT(min < max); CARLA_ASSERT(def >= min); CARLA_ASSERT(def <= max); - if (index >= 0 && static_cast(kData->param.count)) + if (index >= 0 && static_cast(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(kData->prog.count), index, kData->prog.count); + CARLA_ASSERT_INT2(index >= 0 && index < static_cast(pData->prog.count), index, pData->prog.count); CARLA_ASSERT(name != nullptr); - if (index >= 0 && index < static_cast(kData->prog.count)) + if (index >= 0 && index < static_cast(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(kData->midiprog.count), index, kData->midiprog.count); + CARLA_ASSERT_INT2(index < static_cast(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(kData->midiprog.count)) + if (index >= 0 && index < static_cast(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(kData->param.count), index, kData->param.count); + CARLA_ASSERT_INT2(index >= 0 && index < static_cast(pData->param.count), index, pData->param.count); - if (index >= 0 && static_cast(kData->param.count)) + if (index >= 0 && static_cast(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(kData->param.count), index, kData->param.count); + CARLA_ASSERT_INT2(index >= 0 && index < static_cast(pData->param.count), index, pData->param.count); - if (index >= 0 && static_cast(kData->param.count)) - kData->param.ranges[index].def = value; + if (index >= 0 && static_cast(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(kData->prog.count), index, kData->prog.count); + CARLA_ASSERT_INT2(index >= 0 && index < static_cast(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(kData->midiprog.count), index, kData->midiprog.count); + CARLA_ASSERT_INT2(index < static_cast(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; } diff --git a/source/backend/plugin/CarlaPlugin.cpp b/source/backend/plugin/CarlaPlugin.cpp index 50d85ae52..5c5a9e3a8 100644 --- a/source/backend/plugin/CarlaPlugin.cpp +++ b/source/backend/plugin/CarlaPlugin.cpp @@ -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 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 << "\n"; out << "\n"; out << "\n"; - out << getXMLFromSaveState(getSaveState()); + out << content; out << "\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::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) diff --git a/source/backend/plugin/CarlaPluginInternal.hpp b/source/backend/plugin/CarlaPluginInternal.hpp index be9401621..435c3291f 100644 --- a/source/backend/plugin/CarlaPluginInternal.hpp +++ b/source/backend/plugin/CarlaPluginInternal.hpp @@ -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 diff --git a/source/backend/plugin/DssiPlugin.cpp b/source/backend/plugin/DssiPlugin.cpp index b98810e52..529824652 100644 --- a/source/backend/plugin/DssiPlugin.cpp +++ b/source/backend/plugin/DssiPlugin.cpp @@ -45,7 +45,7 @@ public: carla_zeroStruct(fMidiEvents, MAX_MIDI_EVENTS); - kData->osc.thread.setMode(CarlaPluginThread::PLUGIN_THREAD_DSSI_GUI); + pData->osc.thread.setMode(CarlaPluginThread::PLUGIN_THREAD_DSSI_GUI); } ~DssiPlugin() override @@ -58,23 +58,23 @@ public: showGui(false); // 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("DSSI GUI thread still running, forcing termination now"); - kData->osc.thread.terminate(); + pData->osc.thread.terminate(); } } - 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) @@ -171,16 +171,16 @@ public: if (isDssiVst) { - if (kData->engine->getOptions().useDssiVstChunks && fDssiDescriptor->get_custom_data != nullptr && fDssiDescriptor->set_custom_data != nullptr) + if (pData->engine->getOptions().useDssiVstChunks && fDssiDescriptor->get_custom_data != nullptr && fDssiDescriptor->set_custom_data != nullptr) options |= PLUGIN_OPTION_USE_CHUNKS; } else { - 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; } @@ -202,7 +202,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]; } @@ -250,9 +250,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(fDescriptor->PortCount)) std::strncpy(strBuf, fDescriptor->PortNames[rindex], STR_MAX); @@ -275,9 +275,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); @@ -312,8 +312,8 @@ public: fDssiDescriptor->configure(fHandle2, key, value); } - if (sendGui && kData->osc.data.target != nullptr) - osc_send_configure(&kData->osc.data, key, value); + if (sendGui && pData->osc.data.target != nullptr) + osc_send_configure(&pData->osc.data, key, value); if (std::strcmp(key, "reloadprograms") == 0 || std::strcmp(key, "load") == 0 || std::strncmp(key, "patches", 7) == 0) { @@ -351,17 +351,17 @@ public: { CARLA_ASSERT(fDssiDescriptor != nullptr); CARLA_ASSERT(fHandle != nullptr); - CARLA_ASSERT(index >= -1 && index < static_cast(kData->midiprog.count)); + CARLA_ASSERT(index >= -1 && index < static_cast(pData->midiprog.count)); if (index < -1) index = -1; - else if (index > static_cast(kData->midiprog.count)) + else if (index > static_cast(pData->midiprog.count)) return; if (index >= 0 && fDssiDescriptor != nullptr && fDssiDescriptor->select_program != nullptr) { - 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 ScopedSingleProcessLocker spl(this, (sendGui || sendOsc || sendCallback)); @@ -381,19 +381,19 @@ public: { if (yesNo) { - kData->osc.thread.start(); + pData->osc.thread.start(); } else { - if (kData->osc.data.target != nullptr) + if (pData->osc.data.target != nullptr) { - osc_send_hide(&kData->osc.data); - osc_send_quit(&kData->osc.data); - kData->osc.data.free(); + osc_send_hide(&pData->osc.data); + osc_send_quit(&pData->osc.data); + pData->osc.data.free(); } - if (kData->osc.thread.isRunning() && ! kData->osc.thread.wait(kData->engine->getOptions().oscUiTimeout)) - kData->osc.thread.terminate(); + if (pData->osc.thread.isRunning() && ! pData->osc.thread.wait(pData->engine->getOptions().oscUiTimeout)) + pData->osc.thread.terminate(); } } @@ -403,12 +403,12 @@ public: void reload() override { carla_debug("DssiPlugin::reload() - start"); - CARLA_ASSERT(kData->engine != nullptr); + CARLA_ASSERT(pData->engine != nullptr); CARLA_ASSERT(fDescriptor != nullptr); CARLA_ASSERT(fDssiDescriptor != nullptr); CARLA_ASSERT(fHandle != nullptr); - if (kData->engine == nullptr) + if (pData->engine == nullptr) return; if (fDescriptor == nullptr) return; @@ -417,17 +417,17 @@ public: 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(kData->engine->getSampleRate())); + const float sampleRate(static_cast(pData->engine->getSampleRate())); const uint32_t portCount(static_cast(fDescriptor->PortCount)); uint32_t aIns, aOuts, mIns, params, j; @@ -490,7 +490,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) @@ -499,7 +499,7 @@ public: if (aOuts > 0) { - kData->audioOut.createNew(aOuts); + pData->audioOut.createNew(aOuts); fAudioOutBuffers = new float*[aOuts]; needsCtrlIn = true; @@ -509,13 +509,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) @@ -541,27 +541,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 @@ -570,11 +570,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; @@ -614,7 +614,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)) @@ -622,14 +622,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 { @@ -641,9 +641,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; // MIDI CC value @@ -654,7 +654,7 @@ public: { int16_t cc = DSSI_CC_NUMBER(controller); if (! MIDI_IS_CONTROL_BANK_SELECT(cc)) - kData->param.data[j].midiCC = cc; + pData->param.data[j].midiCC = cc; } } } @@ -669,8 +669,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) { @@ -679,33 +679,33 @@ 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; - 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; @@ -740,7 +740,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) @@ -756,7 +756,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) @@ -786,20 +786,20 @@ public: fHints |= PLUGIN_CAN_BALANCE; // extra plugin hints - kData->extraHints = 0x0; + pData->extraHints = 0x0; if (mIns > 0) - kData->extraHints |= PLUGIN_HINT_HAS_MIDI_IN; + pData->extraHints |= PLUGIN_HINT_HAS_MIDI_IN; 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 @@ -812,7 +812,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) @@ -820,7 +820,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) @@ -833,21 +833,21 @@ 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()); reloadPrograms(true); - if (kData->active) + if (pData->active) activate(); carla_debug("DssiPlugin::reload() - end"); @@ -856,11 +856,11 @@ public: void reloadPrograms(const bool init) override { carla_debug("DssiPlugin::reloadPrograms(%s)", bool2str(init)); - uint32_t i, oldCount = kData->midiprog.count; - const int32_t current = kData->midiprog.current; + uint32_t i, oldCount = pData->midiprog.count; + const int32_t current = pData->midiprog.current; // Delete old programs - kData->midiprog.clear(); + pData->midiprog.clear(); // Query new programs uint32_t count = 0; @@ -872,7 +872,7 @@ public: if (count > 0) { - kData->midiprog.createNew(count); + pData->midiprog.createNew(count); // Update data for (i=0; i < count; ++i) @@ -881,20 +881,20 @@ public: CARLA_ASSERT(pdesc != nullptr); CARLA_ASSERT(pdesc->Name != nullptr); - kData->midiprog.data[i].bank = static_cast(pdesc->Bank); - kData->midiprog.data[i].program = static_cast(pdesc->Program); - kData->midiprog.data[i].name = carla_strdup(pdesc->Name); + pData->midiprog.data[i].bank = static_cast(pdesc->Bank); + pData->midiprog.data[i].program = static_cast(pdesc->Program); + pData->midiprog.data[i].name = carla_strdup(pdesc->Name); } } #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 @@ -911,37 +911,37 @@ public: if (count == oldCount+1) { // one midi program added, probably created by user - kData->midiprog.current = oldCount; + pData->midiprog.current = oldCount; programChanged = true; } else if (current < 0 && count > 0) { // programs exist now, but not before - kData->midiprog.current = 0; + pData->midiprog.current = 0; programChanged = true; } else if (current >= 0 && count == 0) { // programs existed before, but not anymore - kData->midiprog.current = -1; + pData->midiprog.current = -1; programChanged = true; } else if (current >= static_cast(count)) { // current midi program > count - kData->midiprog.current = 0; + pData->midiprog.current = 0; programChanged = true; } else { // no change - kData->midiprog.current = current; + pData->midiprog.current = current; } if (programChanged) - setMidiProgram(kData->midiprog.current, true, true, true); + setMidiProgram(pData->midiprog.current, true, true, true); - kData->engine->callback(CALLBACK_RELOAD_PROGRAMS, fId, 0, 0, 0.0f, nullptr); + pData->engine->callback(CALLBACK_RELOAD_PROGRAMS, fId, 0, 0, 0.0f, nullptr); } } @@ -983,10 +983,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; @@ -997,7 +997,7 @@ public: // -------------------------------------------------------------------------------------------------------- // Check if needs reset - if (kData->needsReset) + if (pData->needsReset) { if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF) { @@ -1017,42 +1017,42 @@ public: midiEventCount = MAX_MIDI_CHANNELS*2; } - else if (kData->ctrlChannel >= 0 && kData->ctrlChannel < MAX_MIDI_CHANNELS) + else if (pData->ctrlChannel >= 0 && pData->ctrlChannel < MAX_MIDI_CHANNELS) { for (unsigned char j=0; j < MAX_MIDI_NOTE; ++j) { carla_zeroStruct(fMidiEvents[j]); fMidiEvents[j].type = SND_SEQ_EVENT_NOTEOFF; - fMidiEvents[j].data.note.channel = kData->ctrlChannel; + fMidiEvents[j].data.note.channel = pData->ctrlChannel; fMidiEvents[j].data.note.note = j; } midiEventCount = MAX_MIDI_NOTE; } - 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) { // ---------------------------------------------------------------------------------------------------- // MIDI Input (External) - if (kData->extNotes.mutex.tryLock()) + if (pData->extNotes.mutex.tryLock()) { - while (midiEventCount < MAX_MIDI_EVENTS && ! kData->extNotes.data.isEmpty()) + while (midiEventCount < MAX_MIDI_EVENTS && ! 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); @@ -1064,7 +1064,7 @@ public: midiEventCount += 1; } - kData->extNotes.mutex.unlock(); + pData->extNotes.mutex.unlock(); } // End of MIDI Input (External) @@ -1074,17 +1074,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; @@ -1101,8 +1101,8 @@ public: timeOffset = time; midiEventCount = 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; else nextBankId = 0; } @@ -1129,7 +1129,7 @@ public: { #ifndef BUILD_BRIDGE // Control backend stuff - if (event.channel == kData->ctrlChannel) + if (event.channel == pData->ctrlChannel) { float value; @@ -1177,28 +1177,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); } @@ -1227,18 +1227,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); @@ -1269,7 +1269,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(); @@ -1381,7 +1381,7 @@ public: } } - kData->postRtEvents.trySplice(); + pData->postRtEvents.trySplice(); if (frames > timeOffset) processSingle(inBuffer, outBuffer, frames - timeOffset, timeOffset, midiEventCount); @@ -1402,25 +1402,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(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(pData->param.data[k].midiCC); + value = pData->param.ranges[k].normalizeValue(fParamBuffers[k]); + pData->event.portOut->writeControlEvent(0, channel, kEngineControlEventTypeParameter, param, value); } } @@ -1434,13 +1434,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) @@ -1452,13 +1452,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; @@ -1470,9 +1470,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); // -------------------------------------------------------------------------------------------------------- @@ -1506,13 +1506,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) @@ -1520,13 +1520,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)); } } @@ -1537,12 +1537,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) { @@ -1564,21 +1564,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]; @@ -1587,7 +1587,7 @@ public: // -------------------------------------------------------------------------------------------------------- - kData->singleMutex.unlock(); + pData->singleMutex.unlock(); return true; } @@ -1596,14 +1596,14 @@ public: CARLA_ASSERT_INT(newBufferSize > 0, newBufferSize); carla_debug("DssiPlugin::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]; @@ -1612,38 +1612,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]); } } @@ -1670,7 +1670,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) { @@ -1685,7 +1685,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) { @@ -1714,26 +1714,26 @@ public: void uiParameterChange(const uint32_t index, const float value) override { - CARLA_ASSERT(index < kData->param.count); + CARLA_ASSERT(index < pData->param.count); - if (index >= kData->param.count) + if (index >= pData->param.count) return; - if (kData->osc.data.target == nullptr) + if (pData->osc.data.target == nullptr) return; - osc_send_control(&kData->osc.data, kData->param.data[index].rindex, value); + osc_send_control(&pData->osc.data, pData->param.data[index].rindex, value); } void uiMidiProgramChange(const uint32_t index) override { - CARLA_ASSERT(index < kData->midiprog.count); + CARLA_ASSERT(index < pData->midiprog.count); - if (index >= kData->midiprog.count) + if (index >= pData->midiprog.count) return; - if (kData->osc.data.target == nullptr) + if (pData->osc.data.target == nullptr) return; - osc_send_program(&kData->osc.data, kData->midiprog.data[index].bank, kData->midiprog.data[index].program); + osc_send_program(&pData->osc.data, pData->midiprog.data[index].bank, pData->midiprog.data[index].program); } void uiNoteOn(const uint8_t channel, const uint8_t note, const uint8_t velo) override @@ -1748,7 +1748,7 @@ public: return; if (velo >= MAX_MIDI_VALUE) return; - if (kData->osc.data.target == nullptr) + if (pData->osc.data.target == nullptr) return; #if 0 @@ -1757,7 +1757,7 @@ public: midiData[2] = note; midiData[3] = velo; - osc_send_midi(&kData->osc.data, midiData); + osc_send_midi(&pData->osc.data, midiData); #endif } @@ -1770,7 +1770,7 @@ public: return; if (note >= MAX_MIDI_NOTE) return; - if (kData->osc.data.target == nullptr) + if (pData->osc.data.target == nullptr) return; #if 0 @@ -1778,7 +1778,7 @@ public: midiData[1] = MIDI_STATUS_NOTE_OFF + channel; midiData[2] = note; - osc_send_midi(&kData->osc.data, midiData); + osc_send_midi(&pData->osc.data, midiData); #endif } @@ -1791,54 +1791,54 @@ public: bool init(const char* const filename, const char* const name, const char* const label, const char* const guiFilename) { - 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 DSSI_Descriptor_Function descFn = (DSSI_Descriptor_Function)kData->libSymbol("dssi_descriptor"); + const DSSI_Descriptor_Function descFn = (DSSI_Descriptor_Function)pData->libSymbol("dssi_descriptor"); if (descFn == nullptr) { - kData->engine->setLastError("Could not find the DSSI Descriptor in the plugin library"); + pData->engine->setLastError("Could not find the DSSI Descriptor in the plugin library"); return false; } @@ -1855,7 +1855,7 @@ public: if (fDescriptor == nullptr || fDssiDescriptor == 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; } @@ -1866,7 +1866,7 @@ public: { if (! addUniqueMultiSynth(fDescriptor->Label)) { - kData->engine->setLastError("This plugin uses a global instance and can't be used more than once safely"); + pData->engine->setLastError("This plugin uses a global instance and can't be used more than once safely"); return false; } } @@ -1875,33 +1875,33 @@ public: // get info if (name != nullptr) - fName = kData->engine->getUniquePluginName(name); + fName = pData->engine->getUniquePluginName(name); 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; } @@ -1911,7 +1911,7 @@ public: if (guiFilename != nullptr) { fGuiFilename = guiFilename; - kData->osc.thread.setOscData(guiFilename, fDescriptor->Label); + pData->osc.thread.setOscData(guiFilename, fDescriptor->Label); } // --------------------------------------------------------------- @@ -1929,14 +1929,14 @@ public: fOptions |= PLUGIN_OPTION_MAP_PROGRAM_CHANGES; - if (kData->engine->getOptions().forceStereo) + if (pData->engine->getOptions().forceStereo) fOptions |= PLUGIN_OPTION_FORCE_STEREO; if (isDssiVst) { fOptions |= PLUGIN_OPTION_FIXED_BUFFER; - if (kData->engine->getOptions().useDssiVstChunks && fDssiDescriptor->get_custom_data != nullptr && fDssiDescriptor->set_custom_data != nullptr) + if (pData->engine->getOptions().useDssiVstChunks && fDssiDescriptor->get_custom_data != nullptr && fDssiDescriptor->set_custom_data != nullptr) fOptions |= PLUGIN_OPTION_USE_CHUNKS; } @@ -1952,11 +1952,11 @@ public: } // load settings - kData->idStr = "DSSI/"; - kData->idStr += std::strrchr(filename, OS_SEP)+1; - kData->idStr += "/"; - kData->idStr += label; - fOptions = kData->loadSettings(fOptions, availableOptions()); + pData->idStr = "DSSI/"; + pData->idStr += std::strrchr(filename, OS_SEP)+1; + pData->idStr += "/"; + pData->idStr += label; + fOptions = pData->loadSettings(fOptions, availableOptions()); // ignore settings, we need this anyway if (isDssiVst) diff --git a/source/backend/plugin/FluidSynthPlugin.cpp b/source/backend/plugin/FluidSynthPlugin.cpp index 6328594d8..4e947e852 100644 --- a/source/backend/plugin/FluidSynthPlugin.cpp +++ b/source/backend/plugin/FluidSynthPlugin.cpp @@ -64,7 +64,7 @@ public: // define settings fluid_settings_setint(fSettings, "synth.audio-channels", use16Outs ? 16 : 1); fluid_settings_setint(fSettings, "synth.audio-groups", use16Outs ? 16 : 1); - fluid_settings_setnum(fSettings, "synth.sample-rate", kData->engine->getSampleRate()); + fluid_settings_setnum(fSettings, "synth.sample-rate", pData->engine->getSampleRate()); fluid_settings_setint(fSettings, "synth.threadsafe-api ", 0); // create synth @@ -72,7 +72,7 @@ public: CARLA_ASSERT(fSynth != nullptr); #ifdef FLUIDSYNTH_VERSION_NEW_API - fluid_synth_set_sample_rate(fSynth, kData->engine->getSampleRate()); + fluid_synth_set_sample_rate(fSynth, pData->engine->getSampleRate()); #endif // set default values @@ -93,16 +93,16 @@ public: { carla_debug("FluidSynthPlugin::~FluidSynthPlugin()"); - 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; } delete_fluid_synth(fSynth); @@ -129,7 +129,7 @@ public: uint32_t parameterScalePointCount(const uint32_t parameterId) const override { - CARLA_ASSERT(parameterId < kData->param.count); + CARLA_ASSERT(parameterId < pData->param.count); switch (parameterId) { @@ -165,14 +165,14 @@ public: float getParameterValue(const uint32_t parameterId) override { - CARLA_ASSERT(parameterId < kData->param.count); + CARLA_ASSERT(parameterId < pData->param.count); return fParamBuffers[parameterId]; } float getParameterScalePointValue(const uint32_t parameterId, const uint32_t scalePointId) override { - CARLA_ASSERT(parameterId < kData->param.count); + CARLA_ASSERT(parameterId < pData->param.count); CARLA_ASSERT(scalePointId < parameterScalePointCount(parameterId)); switch (parameterId) @@ -231,7 +231,7 @@ public: void getParameterName(const uint32_t parameterId, char* const strBuf) override { - CARLA_ASSERT(parameterId < kData->param.count); + CARLA_ASSERT(parameterId < pData->param.count); switch (parameterId) { @@ -285,7 +285,7 @@ public: void getParameterUnit(const uint32_t parameterId, char* const strBuf) override { - CARLA_ASSERT(parameterId < kData->param.count); + CARLA_ASSERT(parameterId < pData->param.count); switch (parameterId) { @@ -303,7 +303,7 @@ public: void getParameterScalePointLabel(const uint32_t parameterId, const uint32_t scalePointId, char* const strBuf) override { - CARLA_ASSERT(parameterId < kData->param.count); + CARLA_ASSERT(parameterId < pData->param.count); CARLA_ASSERT(scalePointId < parameterScalePointCount(parameterId)); switch (parameterId) @@ -361,7 +361,7 @@ public: void setCtrlChannel(const int8_t channel, const bool sendOsc, const bool sendCallback) override { if (channel < MAX_MIDI_CHANNELS) - kData->midiprog.current = fCurMidiProgs[channel]; + pData->midiprog.current = fCurMidiProgs[channel]; CarlaPlugin::setCtrlChannel(channel, sendOsc, sendCallback); } @@ -371,9 +371,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; { @@ -454,18 +454,18 @@ public: bool ok; uint index = midiProg.toUInt(&ok); - if (ok && index < kData->midiprog.count) + if (ok && index < pData->midiprog.count) { - 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; fluid_synth_program_select(fSynth, i, fSynthId, bank, program); fCurMidiProgs[i] = index; - if (kData->ctrlChannel == static_cast(i)) + if (pData->ctrlChannel == static_cast(i)) { - kData->midiprog.current = index; - kData->engine->callback(CALLBACK_MIDI_PROGRAM_CHANGED, fId, index, 0, 0.0f, nullptr); + pData->midiprog.current = index; + pData->engine->callback(CALLBACK_MIDI_PROGRAM_CHANGED, fId, index, 0, 0.0f, nullptr); } } @@ -479,24 +479,24 @@ public: void setMidiProgram(int32_t index, const bool sendGui, const bool sendOsc, const bool sendCallback) override { CARLA_ASSERT(fSynth != nullptr); - CARLA_ASSERT(index >= -1 && index < static_cast(kData->midiprog.count)); + CARLA_ASSERT(index >= -1 && index < static_cast(pData->midiprog.count)); if (index < -1) index = -1; - else if (index > static_cast(kData->midiprog.count)) + else if (index > static_cast(pData->midiprog.count)) return; - if (kData->ctrlChannel < 0 || kData->ctrlChannel >= MAX_MIDI_CHANNELS) + if (pData->ctrlChannel < 0 || pData->ctrlChannel >= MAX_MIDI_CHANNELS) 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 ScopedSingleProcessLocker spl(this, (sendGui || sendOsc || sendCallback)); - fluid_synth_program_select(fSynth, kData->ctrlChannel, fSynthId, bank, program); - fCurMidiProgs[kData->ctrlChannel] = index; + fluid_synth_program_select(fSynth, pData->ctrlChannel, fSynthId, bank, program); + fCurMidiProgs[pData->ctrlChannel] = index; } CarlaPlugin::setMidiProgram(index, sendGui, sendOsc, sendCallback); @@ -513,20 +513,20 @@ public: void reload() override { carla_debug("FluidSynthPlugin::reload() - start"); - CARLA_ASSERT(kData->engine != nullptr); + CARLA_ASSERT(pData->engine != nullptr); CARLA_ASSERT(fSynth != nullptr); - if (kData->engine == nullptr) + if (pData->engine == nullptr) return; if (fSynth == 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(); @@ -535,10 +535,10 @@ public: aOuts = kUses16Outs ? 32 : 2; params = FluidSynthParametersMax; - kData->audioOut.createNew(aOuts); - kData->param.createNew(params); + pData->audioOut.createNew(aOuts); + pData->param.createNew(params); - const int portNameSize = kData->engine->maxPortNameSize(); + const int portNameSize = pData->engine->maxPortNameSize(); CarlaString portName; // --------------------------------------- @@ -570,8 +570,8 @@ public: 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; } fAudio16Buffers = new float*[aOuts]; @@ -593,8 +593,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(); @@ -608,8 +608,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; } // --------------------------------------- @@ -627,7 +627,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); } // --------------------------------------- @@ -645,232 +645,232 @@ 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); } // ---------------------- j = FluidSynthReverbOnOff; - kData->param.data[j].index = j; - kData->param.data[j].rindex = j; - kData->param.data[j].type = PARAMETER_INPUT; - kData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_AUTOMABLE | PARAMETER_IS_BOOLEAN; - kData->param.data[j].midiChannel = 0; - kData->param.data[j].midiCC = -1; - kData->param.ranges[j].min = 0.0f; - kData->param.ranges[j].max = 1.0f; - kData->param.ranges[j].def = 0.0f; // off - kData->param.ranges[j].step = 1.0f; - kData->param.ranges[j].stepSmall = 1.0f; - kData->param.ranges[j].stepLarge = 1.0f; - fParamBuffers[j] = kData->param.ranges[j].def; + pData->param.data[j].index = j; + pData->param.data[j].rindex = j; + pData->param.data[j].type = PARAMETER_INPUT; + pData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_AUTOMABLE | PARAMETER_IS_BOOLEAN; + pData->param.data[j].midiChannel = 0; + pData->param.data[j].midiCC = -1; + pData->param.ranges[j].min = 0.0f; + pData->param.ranges[j].max = 1.0f; + pData->param.ranges[j].def = 0.0f; // off + pData->param.ranges[j].step = 1.0f; + pData->param.ranges[j].stepSmall = 1.0f; + pData->param.ranges[j].stepLarge = 1.0f; + fParamBuffers[j] = pData->param.ranges[j].def; // ---------------------- j = FluidSynthReverbRoomSize; - kData->param.data[j].index = j; - kData->param.data[j].rindex = j; - kData->param.data[j].type = PARAMETER_INPUT; - kData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_AUTOMABLE; - kData->param.data[j].midiChannel = 0; - kData->param.data[j].midiCC = -1; - kData->param.ranges[j].min = 0.0f; - kData->param.ranges[j].max = 1.2f; - kData->param.ranges[j].def = FLUID_REVERB_DEFAULT_ROOMSIZE; - kData->param.ranges[j].step = 0.01f; - kData->param.ranges[j].stepSmall = 0.0001f; - kData->param.ranges[j].stepLarge = 0.1f; - fParamBuffers[j] = kData->param.ranges[j].def; + pData->param.data[j].index = j; + pData->param.data[j].rindex = j; + pData->param.data[j].type = PARAMETER_INPUT; + pData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_AUTOMABLE; + pData->param.data[j].midiChannel = 0; + pData->param.data[j].midiCC = -1; + pData->param.ranges[j].min = 0.0f; + pData->param.ranges[j].max = 1.2f; + pData->param.ranges[j].def = FLUID_REVERB_DEFAULT_ROOMSIZE; + pData->param.ranges[j].step = 0.01f; + pData->param.ranges[j].stepSmall = 0.0001f; + pData->param.ranges[j].stepLarge = 0.1f; + fParamBuffers[j] = pData->param.ranges[j].def; // ---------------------- j = FluidSynthReverbDamp; - kData->param.data[j].index = j; - kData->param.data[j].rindex = j; - kData->param.data[j].type = PARAMETER_INPUT; - kData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_AUTOMABLE; - kData->param.data[j].midiChannel = 0; - kData->param.data[j].midiCC = -1; - kData->param.ranges[j].min = 0.0f; - kData->param.ranges[j].max = 1.0f; - kData->param.ranges[j].def = FLUID_REVERB_DEFAULT_DAMP; - kData->param.ranges[j].step = 0.01f; - kData->param.ranges[j].stepSmall = 0.0001f; - kData->param.ranges[j].stepLarge = 0.1f; - fParamBuffers[j] = kData->param.ranges[j].def; + pData->param.data[j].index = j; + pData->param.data[j].rindex = j; + pData->param.data[j].type = PARAMETER_INPUT; + pData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_AUTOMABLE; + pData->param.data[j].midiChannel = 0; + pData->param.data[j].midiCC = -1; + pData->param.ranges[j].min = 0.0f; + pData->param.ranges[j].max = 1.0f; + pData->param.ranges[j].def = FLUID_REVERB_DEFAULT_DAMP; + pData->param.ranges[j].step = 0.01f; + pData->param.ranges[j].stepSmall = 0.0001f; + pData->param.ranges[j].stepLarge = 0.1f; + fParamBuffers[j] = pData->param.ranges[j].def; // ---------------------- j = FluidSynthReverbLevel; - kData->param.data[j].index = j; - kData->param.data[j].rindex = j; - kData->param.data[j].type = PARAMETER_INPUT; - kData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_AUTOMABLE; - kData->param.data[j].midiChannel = 0; - kData->param.data[j].midiCC = MIDI_CONTROL_REVERB_SEND_LEVEL; - kData->param.ranges[j].min = 0.0f; - kData->param.ranges[j].max = 1.0f; - kData->param.ranges[j].def = FLUID_REVERB_DEFAULT_LEVEL; - kData->param.ranges[j].step = 0.01f; - kData->param.ranges[j].stepSmall = 0.0001f; - kData->param.ranges[j].stepLarge = 0.1f; - fParamBuffers[j] = kData->param.ranges[j].def; + pData->param.data[j].index = j; + pData->param.data[j].rindex = j; + pData->param.data[j].type = PARAMETER_INPUT; + pData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_AUTOMABLE; + pData->param.data[j].midiChannel = 0; + pData->param.data[j].midiCC = MIDI_CONTROL_REVERB_SEND_LEVEL; + pData->param.ranges[j].min = 0.0f; + pData->param.ranges[j].max = 1.0f; + pData->param.ranges[j].def = FLUID_REVERB_DEFAULT_LEVEL; + pData->param.ranges[j].step = 0.01f; + pData->param.ranges[j].stepSmall = 0.0001f; + pData->param.ranges[j].stepLarge = 0.1f; + fParamBuffers[j] = pData->param.ranges[j].def; // ---------------------- j = FluidSynthReverbWidth; - kData->param.data[j].index = j; - kData->param.data[j].rindex = j; - kData->param.data[j].type = PARAMETER_INPUT; - kData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_AUTOMABLE; - kData->param.data[j].midiChannel = 0; - kData->param.data[j].midiCC = -1; - kData->param.ranges[j].min = 0.0f; - kData->param.ranges[j].max = 10.0f; // should be 100, but that sounds too much - kData->param.ranges[j].def = FLUID_REVERB_DEFAULT_WIDTH; - kData->param.ranges[j].step = 0.01f; - kData->param.ranges[j].stepSmall = 0.0001f; - kData->param.ranges[j].stepLarge = 0.1f; - fParamBuffers[j] = kData->param.ranges[j].def; + pData->param.data[j].index = j; + pData->param.data[j].rindex = j; + pData->param.data[j].type = PARAMETER_INPUT; + pData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_AUTOMABLE; + pData->param.data[j].midiChannel = 0; + pData->param.data[j].midiCC = -1; + pData->param.ranges[j].min = 0.0f; + pData->param.ranges[j].max = 10.0f; // should be 100, but that sounds too much + pData->param.ranges[j].def = FLUID_REVERB_DEFAULT_WIDTH; + pData->param.ranges[j].step = 0.01f; + pData->param.ranges[j].stepSmall = 0.0001f; + pData->param.ranges[j].stepLarge = 0.1f; + fParamBuffers[j] = pData->param.ranges[j].def; // ---------------------- j = FluidSynthChorusOnOff; - kData->param.data[j].index = j; - kData->param.data[j].rindex = j; - kData->param.data[j].type = PARAMETER_INPUT; - kData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_BOOLEAN; - kData->param.data[j].midiChannel = 0; - kData->param.data[j].midiCC = -1; - kData->param.ranges[j].min = 0.0f; - kData->param.ranges[j].max = 1.0f; - kData->param.ranges[j].def = 0.0f; // off - kData->param.ranges[j].step = 1.0f; - kData->param.ranges[j].stepSmall = 1.0f; - kData->param.ranges[j].stepLarge = 1.0f; - fParamBuffers[j] = kData->param.ranges[j].def; + pData->param.data[j].index = j; + pData->param.data[j].rindex = j; + pData->param.data[j].type = PARAMETER_INPUT; + pData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_BOOLEAN; + pData->param.data[j].midiChannel = 0; + pData->param.data[j].midiCC = -1; + pData->param.ranges[j].min = 0.0f; + pData->param.ranges[j].max = 1.0f; + pData->param.ranges[j].def = 0.0f; // off + pData->param.ranges[j].step = 1.0f; + pData->param.ranges[j].stepSmall = 1.0f; + pData->param.ranges[j].stepLarge = 1.0f; + fParamBuffers[j] = pData->param.ranges[j].def; // ---------------------- j = FluidSynthChorusNr; - kData->param.data[j].index = j; - kData->param.data[j].rindex = j; - kData->param.data[j].type = PARAMETER_INPUT; - kData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_INTEGER; - kData->param.data[j].midiChannel = 0; - kData->param.data[j].midiCC = -1; - kData->param.ranges[j].min = 0.0f; - kData->param.ranges[j].max = 99.0f; - kData->param.ranges[j].def = FLUID_CHORUS_DEFAULT_N; - kData->param.ranges[j].step = 1.0f; - kData->param.ranges[j].stepSmall = 1.0f; - kData->param.ranges[j].stepLarge = 10.0f; - fParamBuffers[j] = kData->param.ranges[j].def; + pData->param.data[j].index = j; + pData->param.data[j].rindex = j; + pData->param.data[j].type = PARAMETER_INPUT; + pData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_INTEGER; + pData->param.data[j].midiChannel = 0; + pData->param.data[j].midiCC = -1; + pData->param.ranges[j].min = 0.0f; + pData->param.ranges[j].max = 99.0f; + pData->param.ranges[j].def = FLUID_CHORUS_DEFAULT_N; + pData->param.ranges[j].step = 1.0f; + pData->param.ranges[j].stepSmall = 1.0f; + pData->param.ranges[j].stepLarge = 10.0f; + fParamBuffers[j] = pData->param.ranges[j].def; // ---------------------- j = FluidSynthChorusLevel; - kData->param.data[j].index = j; - kData->param.data[j].rindex = j; - kData->param.data[j].type = PARAMETER_INPUT; - kData->param.data[j].hints = PARAMETER_IS_ENABLED; - kData->param.data[j].midiChannel = 0; - kData->param.data[j].midiCC = 0; //MIDI_CONTROL_CHORUS_SEND_LEVEL; - kData->param.ranges[j].min = 0.0f; - kData->param.ranges[j].max = 10.0f; - kData->param.ranges[j].def = FLUID_CHORUS_DEFAULT_LEVEL; - kData->param.ranges[j].step = 0.01f; - kData->param.ranges[j].stepSmall = 0.0001f; - kData->param.ranges[j].stepLarge = 0.1f; - fParamBuffers[j] = kData->param.ranges[j].def; + pData->param.data[j].index = j; + pData->param.data[j].rindex = j; + pData->param.data[j].type = PARAMETER_INPUT; + pData->param.data[j].hints = PARAMETER_IS_ENABLED; + pData->param.data[j].midiChannel = 0; + pData->param.data[j].midiCC = 0; //MIDI_CONTROL_CHORUS_SEND_LEVEL; + pData->param.ranges[j].min = 0.0f; + pData->param.ranges[j].max = 10.0f; + pData->param.ranges[j].def = FLUID_CHORUS_DEFAULT_LEVEL; + pData->param.ranges[j].step = 0.01f; + pData->param.ranges[j].stepSmall = 0.0001f; + pData->param.ranges[j].stepLarge = 0.1f; + fParamBuffers[j] = pData->param.ranges[j].def; // ---------------------- j = FluidSynthChorusSpeedHz; - kData->param.data[j].index = j; - kData->param.data[j].rindex = j; - kData->param.data[j].type = PARAMETER_INPUT; - kData->param.data[j].hints = PARAMETER_IS_ENABLED; - kData->param.data[j].midiChannel = 0; - kData->param.data[j].midiCC = -1; - kData->param.ranges[j].min = 0.29f; - kData->param.ranges[j].max = 5.0f; - kData->param.ranges[j].def = FLUID_CHORUS_DEFAULT_SPEED; - kData->param.ranges[j].step = 0.01f; - kData->param.ranges[j].stepSmall = 0.0001f; - kData->param.ranges[j].stepLarge = 0.1f; - fParamBuffers[j] = kData->param.ranges[j].def; + pData->param.data[j].index = j; + pData->param.data[j].rindex = j; + pData->param.data[j].type = PARAMETER_INPUT; + pData->param.data[j].hints = PARAMETER_IS_ENABLED; + pData->param.data[j].midiChannel = 0; + pData->param.data[j].midiCC = -1; + pData->param.ranges[j].min = 0.29f; + pData->param.ranges[j].max = 5.0f; + pData->param.ranges[j].def = FLUID_CHORUS_DEFAULT_SPEED; + pData->param.ranges[j].step = 0.01f; + pData->param.ranges[j].stepSmall = 0.0001f; + pData->param.ranges[j].stepLarge = 0.1f; + fParamBuffers[j] = pData->param.ranges[j].def; // ---------------------- j = FluidSynthChorusDepthMs; - kData->param.data[j].index = j; - kData->param.data[j].rindex = j; - kData->param.data[j].type = PARAMETER_INPUT; - kData->param.data[j].hints = PARAMETER_IS_ENABLED; - kData->param.data[j].midiChannel = 0; - kData->param.data[j].midiCC = -1; - kData->param.ranges[j].min = 0.0f; - kData->param.ranges[j].max = 2048000.0 / kData->engine->getSampleRate(); - kData->param.ranges[j].def = FLUID_CHORUS_DEFAULT_DEPTH; - kData->param.ranges[j].step = 0.01f; - kData->param.ranges[j].stepSmall = 0.0001f; - kData->param.ranges[j].stepLarge = 0.1f; - fParamBuffers[j] = kData->param.ranges[j].def; + pData->param.data[j].index = j; + pData->param.data[j].rindex = j; + pData->param.data[j].type = PARAMETER_INPUT; + pData->param.data[j].hints = PARAMETER_IS_ENABLED; + pData->param.data[j].midiChannel = 0; + pData->param.data[j].midiCC = -1; + pData->param.ranges[j].min = 0.0f; + pData->param.ranges[j].max = 2048000.0 / pData->engine->getSampleRate(); + pData->param.ranges[j].def = FLUID_CHORUS_DEFAULT_DEPTH; + pData->param.ranges[j].step = 0.01f; + pData->param.ranges[j].stepSmall = 0.0001f; + pData->param.ranges[j].stepLarge = 0.1f; + fParamBuffers[j] = pData->param.ranges[j].def; // ---------------------- j = FluidSynthChorusType; - kData->param.data[j].index = j; - kData->param.data[j].rindex = j; - kData->param.data[j].type = PARAMETER_INPUT; - kData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_INTEGER | PARAMETER_USES_SCALEPOINTS; - kData->param.data[j].midiChannel = 0; - kData->param.data[j].midiCC = -1; - kData->param.ranges[j].min = FLUID_CHORUS_MOD_SINE; - kData->param.ranges[j].max = FLUID_CHORUS_MOD_TRIANGLE; - kData->param.ranges[j].def = FLUID_CHORUS_DEFAULT_TYPE; - kData->param.ranges[j].step = 1.0f; - kData->param.ranges[j].stepSmall = 1.0f; - kData->param.ranges[j].stepLarge = 1.0f; - fParamBuffers[j] = kData->param.ranges[j].def; + pData->param.data[j].index = j; + pData->param.data[j].rindex = j; + pData->param.data[j].type = PARAMETER_INPUT; + pData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_INTEGER | PARAMETER_USES_SCALEPOINTS; + pData->param.data[j].midiChannel = 0; + pData->param.data[j].midiCC = -1; + pData->param.ranges[j].min = FLUID_CHORUS_MOD_SINE; + pData->param.ranges[j].max = FLUID_CHORUS_MOD_TRIANGLE; + pData->param.ranges[j].def = FLUID_CHORUS_DEFAULT_TYPE; + pData->param.ranges[j].step = 1.0f; + pData->param.ranges[j].stepSmall = 1.0f; + pData->param.ranges[j].stepLarge = 1.0f; + fParamBuffers[j] = pData->param.ranges[j].def; // ---------------------- j = FluidSynthPolyphony; - kData->param.data[j].index = j; - kData->param.data[j].rindex = j; - kData->param.data[j].type = PARAMETER_INPUT; - kData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_INTEGER; - kData->param.data[j].midiChannel = 0; - kData->param.data[j].midiCC = -1; - kData->param.ranges[j].min = 1.0f; - kData->param.ranges[j].max = 512.0f; // max theoric is 65535 - kData->param.ranges[j].def = fluid_synth_get_polyphony(fSynth); - kData->param.ranges[j].step = 1.0f; - kData->param.ranges[j].stepSmall = 1.0f; - kData->param.ranges[j].stepLarge = 10.0f; - fParamBuffers[j] = kData->param.ranges[j].def; + pData->param.data[j].index = j; + pData->param.data[j].rindex = j; + pData->param.data[j].type = PARAMETER_INPUT; + pData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_INTEGER; + pData->param.data[j].midiChannel = 0; + pData->param.data[j].midiCC = -1; + pData->param.ranges[j].min = 1.0f; + pData->param.ranges[j].max = 512.0f; // max theoric is 65535 + pData->param.ranges[j].def = fluid_synth_get_polyphony(fSynth); + pData->param.ranges[j].step = 1.0f; + pData->param.ranges[j].stepSmall = 1.0f; + pData->param.ranges[j].stepLarge = 10.0f; + fParamBuffers[j] = pData->param.ranges[j].def; // ---------------------- j = FluidSynthInterpolation; - kData->param.data[j].index = j; - kData->param.data[j].rindex = j; - kData->param.data[j].type = PARAMETER_INPUT; - kData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_INTEGER | PARAMETER_USES_SCALEPOINTS; - kData->param.data[j].midiChannel = 0; - kData->param.data[j].midiCC = -1; - kData->param.ranges[j].min = FLUID_INTERP_NONE; - kData->param.ranges[j].max = FLUID_INTERP_HIGHEST; - kData->param.ranges[j].def = FLUID_INTERP_DEFAULT; - kData->param.ranges[j].step = 1.0f; - kData->param.ranges[j].stepSmall = 1.0f; - kData->param.ranges[j].stepLarge = 1.0f; - fParamBuffers[j] = kData->param.ranges[j].def; + pData->param.data[j].index = j; + pData->param.data[j].rindex = j; + pData->param.data[j].type = PARAMETER_INPUT; + pData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_INTEGER | PARAMETER_USES_SCALEPOINTS; + pData->param.data[j].midiChannel = 0; + pData->param.data[j].midiCC = -1; + pData->param.ranges[j].min = FLUID_INTERP_NONE; + pData->param.ranges[j].max = FLUID_INTERP_HIGHEST; + pData->param.ranges[j].def = FLUID_INTERP_DEFAULT; + pData->param.ranges[j].step = 1.0f; + pData->param.ranges[j].stepSmall = 1.0f; + pData->param.ranges[j].stepLarge = 1.0f; + fParamBuffers[j] = pData->param.ranges[j].def; // ---------------------- j = FluidSynthVoiceCount; - kData->param.data[j].index = j; - kData->param.data[j].rindex = j; - kData->param.data[j].type = PARAMETER_OUTPUT; - kData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_AUTOMABLE | PARAMETER_IS_INTEGER; - kData->param.data[j].midiChannel = 0; - kData->param.data[j].midiCC = -1; - kData->param.ranges[j].min = 0.0f; - kData->param.ranges[j].max = 65535.0f; - kData->param.ranges[j].def = 0.0f; - kData->param.ranges[j].step = 1.0f; - kData->param.ranges[j].stepSmall = 1.0f; - kData->param.ranges[j].stepLarge = 1.0f; - fParamBuffers[j] = kData->param.ranges[j].def; + pData->param.data[j].index = j; + pData->param.data[j].rindex = j; + pData->param.data[j].type = PARAMETER_OUTPUT; + pData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_AUTOMABLE | PARAMETER_IS_INTEGER; + pData->param.data[j].midiChannel = 0; + pData->param.data[j].midiCC = -1; + pData->param.ranges[j].min = 0.0f; + pData->param.ranges[j].max = 65535.0f; + pData->param.ranges[j].def = 0.0f; + pData->param.ranges[j].step = 1.0f; + pData->param.ranges[j].stepSmall = 1.0f; + pData->param.ranges[j].stepLarge = 1.0f; + fParamBuffers[j] = pData->param.ranges[j].def; // --------------------------------------- @@ -881,14 +881,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("FluidSynthPlugin::reload() - end"); @@ -899,7 +899,7 @@ public: carla_debug("FluidSynthPlugin::reloadPrograms(%s)", bool2str(init)); // Delete old programs - kData->midiprog.clear(); + pData->midiprog.clear(); // Query new programs uint32_t count = 0; @@ -922,7 +922,7 @@ public: if (count == 0) return; - kData->midiprog.createNew(count); + pData->midiprog.createNew(count); // Update data uint32_t i = 0; @@ -930,16 +930,16 @@ public: while (f_sfont->iteration_next(f_sfont, &f_preset)) { - CARLA_ASSERT(i < kData->midiprog.count); - kData->midiprog.data[i].bank = f_preset.get_banknum(&f_preset); - kData->midiprog.data[i].program = f_preset.get_num(&f_preset); - kData->midiprog.data[i].name = carla_strdup(f_preset.get_name(&f_preset)); + CARLA_ASSERT(i < pData->midiprog.count); + pData->midiprog.data[i].bank = f_preset.get_banknum(&f_preset); + pData->midiprog.data[i].program = f_preset.get_num(&f_preset); + pData->midiprog.data[i].name = carla_strdup(f_preset.get_name(&f_preset)); - if (kData->midiprog.data[i].bank == 128 && ! hasDrums) + if (pData->midiprog.data[i].bank == 128 && ! hasDrums) { hasDrums = true; drumIndex = i; - drumProg = kData->midiprog.data[i].program; + drumProg = pData->midiprog.data[i].program; } ++i; @@ -949,12 +949,12 @@ public: #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 @@ -968,7 +968,7 @@ public: #ifdef FLUIDSYNTH_VERSION_NEW_API fluid_synth_set_channel_type(fSynth, i, CHANNEL_TYPE_MELODIC); #endif - fluid_synth_program_select(fSynth, i, fSynthId, kData->midiprog.data[0].bank, kData->midiprog.data[0].program); + fluid_synth_program_select(fSynth, i, fSynthId, pData->midiprog.data[0].bank, pData->midiprog.data[0].program); fCurMidiProgs[i] = 0; } @@ -987,16 +987,16 @@ public: #ifdef FLUIDSYNTH_VERSION_NEW_API fluid_synth_set_channel_type(fSynth, 9, CHANNEL_TYPE_MELODIC); #endif - fluid_synth_program_select(fSynth, 9, fSynthId, kData->midiprog.data[0].bank, kData->midiprog.data[0].program); + fluid_synth_program_select(fSynth, 9, fSynthId, pData->midiprog.data[0].bank, pData->midiprog.data[0].program); fCurMidiProgs[9] = 0; } - kData->midiprog.current = 0; + pData->midiprog.current = 0; } 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); } } @@ -1010,10 +1010,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; @@ -1022,7 +1022,7 @@ public: // -------------------------------------------------------------------------------------------------------- // Check if needs reset - if (kData->needsReset) + if (pData->needsReset) { if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF) { @@ -1037,13 +1037,13 @@ public: #endif } } - 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) - fluid_synth_noteoff(fSynth, kData->ctrlChannel, k); + fluid_synth_noteoff(fSynth, pData->ctrlChannel, k); } - kData->needsReset = false; + pData->needsReset = false; } // -------------------------------------------------------------------------------------------------------- @@ -1053,11 +1053,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); @@ -1067,7 +1067,7 @@ public: fluid_synth_noteoff(fSynth,note.channel, note.note); } - kData->extNotes.mutex.unlock(); + pData->extNotes.mutex.unlock(); } // End of MIDI Input (External) @@ -1076,17 +1076,17 @@ public: bool allNotesOffSent = false; - uint32_t time, nEvents = kData->event.portIn->getEventCount(); + uint32_t time, nEvents = pData->event.portIn->getEventCount(); uint32_t timeOffset = 0; uint32_t nextBankIds[MAX_MIDI_CHANNELS] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 0, 0, 0, 0, 0 }; - if (kData->midiprog.current >= 0 && kData->midiprog.count > 0 && kData->ctrlChannel >= 0 && kData->ctrlChannel < MAX_MIDI_CHANNELS) - nextBankIds[kData->ctrlChannel] = kData->midiprog.data[kData->midiprog.current].bank; + if (pData->midiprog.current >= 0 && pData->midiprog.count > 0 && pData->ctrlChannel >= 0 && pData->ctrlChannel < MAX_MIDI_CHANNELS) + nextBankIds[pData->ctrlChannel] = 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; @@ -1101,8 +1101,8 @@ public: { timeOffset = time; - if (kData->midiprog.current >= 0 && kData->midiprog.count > 0 && kData->ctrlChannel >= 0 && kData->ctrlChannel < 16) - nextBankIds[kData->ctrlChannel] = kData->midiprog.data[kData->midiprog.current].bank; + if (pData->midiprog.current >= 0 && pData->midiprog.count > 0 && pData->ctrlChannel >= 0 && pData->ctrlChannel < 16) + nextBankIds[pData->ctrlChannel] = pData->midiprog.data[pData->midiprog.current].bank; } } @@ -1125,7 +1125,7 @@ public: { #ifndef BUILD_BRIDGE // Control backend stuff - if (event.channel == kData->ctrlChannel) + if (event.channel == pData->ctrlChannel) { float value; @@ -1173,28 +1173,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); } @@ -1221,14 +1221,14 @@ public: const uint32_t bankId(nextBankIds[event.channel]); const uint32_t progId(ctrlEvent.param); - for (k=0; k < kData->midiprog.count; ++k) + for (k=0; k < pData->midiprog.count; ++k) { - if (kData->midiprog.data[k].bank == bankId && kData->midiprog.data[k].program == progId) + if (pData->midiprog.data[k].bank == bankId && pData->midiprog.data[k].program == progId) { fluid_synth_program_select(fSynth, event.channel, fSynthId, bankId, progId); fCurMidiProgs[event.channel] = k; - if (event.channel == kData->ctrlChannel) + if (event.channel == pData->ctrlChannel) postponeRtEvent(kPluginPostRtEventMidiProgramChange, k, 0, 0.0f); break; @@ -1251,7 +1251,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(); @@ -1330,7 +1330,7 @@ public: } } - kData->postRtEvents.trySplice(); + pData->postRtEvents.trySplice(); if (frames > timeOffset) processSingle(outBuffer, frames - timeOffset, timeOffset); @@ -1345,12 +1345,12 @@ public: { k = FluidSynthVoiceCount; fParamBuffers[k] = fluid_synth_get_active_voice_count(fSynth); - 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) { - float value(kData->param.ranges[k].normalizeValue(fParamBuffers[k])); - kData->event.portOut->writeControlEvent(0, kData->param.data[k].midiChannel, kEngineControlEventTypeParameter, kData->param.data[k].midiCC, value); + float value(pData->param.ranges[k].normalizeValue(fParamBuffers[k])); + pData->event.portOut->writeControlEvent(0, pData->param.data[k].midiChannel, kEngineControlEventTypeParameter, pData->param.data[k].midiCC, value); } } // End of Control Output @@ -1371,13 +1371,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; @@ -1391,10 +1391,10 @@ public: if (kUses16Outs) { - for (i=0; i < kData->audioOut.count; ++i) + for (i=0; i < pData->audioOut.count; ++i) carla_zeroFloat(fAudio16Buffers[i], frames); - fluid_synth_process(fSynth, frames, 0, nullptr, kData->audioOut.count, fAudio16Buffers); + fluid_synth_process(fSynth, frames, 0, nullptr, pData->audioOut.count, fAudio16Buffers); } else fluid_synth_write_float(fSynth, frames, outBuffer[0] + timeOffset, 0, 1, outBuffer[1] + timeOffset, 0, 1); @@ -1405,12 +1405,12 @@ public: { // note - balance not possible with kUses16Outs, so we can safely skip fAudioOutBuffers - 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) @@ -1418,8 +1418,8 @@ public: if (i % 2 == 0) carla_copyFloat(oldBufLeft, outBuffer[i]+timeOffset, 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) { @@ -1442,12 +1442,12 @@ public: if (kUses16Outs) { for (k=0; k < frames; ++k) - outBuffer[i][k+timeOffset] = fAudio16Buffers[i][k] * kData->postProc.volume; + outBuffer[i][k+timeOffset] = fAudio16Buffers[i][k] * pData->postProc.volume; } else if (doVolume) { for (k=0; k < frames; ++k) - outBuffer[i][k+timeOffset] *= kData->postProc.volume; + outBuffer[i][k+timeOffset] *= pData->postProc.volume; } } @@ -1455,7 +1455,7 @@ public: #else if (kUses16Outs) { - 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] = fAudio16Buffers[i][k]; @@ -1465,7 +1465,7 @@ public: // -------------------------------------------------------------------------------------------------------- - kData->singleMutex.unlock(); + pData->singleMutex.unlock(); return true; } @@ -1474,7 +1474,7 @@ public: if (! kUses16Outs) return; - for (uint32_t i=0; i < kData->audioOut.count; ++i) + for (uint32_t i=0; i < pData->audioOut.count; ++i) { if (fAudio16Buffers[i] != nullptr) delete[] fAudio16Buffers[i]; @@ -1491,7 +1491,7 @@ public: if (fAudio16Buffers != nullptr) { - for (uint32_t i=0; i < kData->audioOut.count; ++i) + for (uint32_t i=0; i < pData->audioOut.count; ++i) { if (fAudio16Buffers[i] != nullptr) { @@ -1525,32 +1525,32 @@ public: // --------------------------------------------------------------- // 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 (fSynth == nullptr) { - kData->engine->setLastError("null synth"); + pData->engine->setLastError("null synth"); 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; } @@ -1561,7 +1561,7 @@ public: if (fSynthId < 0) { - kData->engine->setLastError("Failed to load SoundFont file"); + pData->engine->setLastError("Failed to load SoundFont file"); return false; } @@ -1575,18 +1575,18 @@ public: fLabel += " (16 outs)"; if (name != nullptr) - fName = kData->engine->getUniquePluginName(name); + fName = pData->engine->getUniquePluginName(name); else - fName = kData->engine->getUniquePluginName(label); + fName = pData->engine->getUniquePluginName(label); // --------------------------------------------------------------- // 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; } @@ -1604,9 +1604,9 @@ public: fOptions |= PLUGIN_OPTION_SEND_ALL_SOUND_OFF; // load settings - kData->idStr = "SF2/"; - kData->idStr += label; - fOptions = kData->loadSettings(fOptions, availableOptions()); + pData->idStr = "SF2/"; + pData->idStr += label; + fOptions = pData->loadSettings(fOptions, availableOptions()); } return true; diff --git a/source/backend/plugin/LadspaPlugin.cpp b/source/backend/plugin/LadspaPlugin.cpp index 26fe68d70..5bdbe72fd 100644 --- a/source/backend/plugin/LadspaPlugin.cpp +++ b/source/backend/plugin/LadspaPlugin.cpp @@ -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(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(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(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(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(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(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(kData->engine->getSampleRate())); + const float sampleRate(static_cast(pData->engine->getSampleRate())); const uint32_t portCount(static_cast(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(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(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) diff --git a/source/backend/plugin/LinuxSamplerPlugin.cpp b/source/backend/plugin/LinuxSamplerPlugin.cpp index 3cf2b1910..cdb950dae 100644 --- a/source/backend/plugin/LinuxSamplerPlugin.cpp +++ b/source/backend/plugin/LinuxSamplerPlugin.cpp @@ -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(kData->midiprog.count)); + CARLA_ASSERT(index >= -1 && index < static_cast(pData->midiprog.count)); if (index < -1) index = -1; - else if (index > static_cast(kData->midiprog.count)) + else if (index > static_cast(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; diff --git a/source/backend/plugin/Lv2Plugin.cpp b/source/backend/plugin/Lv2Plugin.cpp index 92c04b37d..0ef492447 100644 --- a/source/backend/plugin/Lv2Plugin.cpp +++ b/source/backend/plugin/Lv2Plugin.cpp @@ -221,7 +221,7 @@ struct Lv2EventData { struct Lv2PluginEventData { uint32_t count; Lv2EventData* data; - Lv2EventData* ctrl; // default port, either this->data[x] or kData->portIn/Out + Lv2EventData* ctrl; // default port, either this->data[x] or pData->portIn/Out uint32_t ctrlIndex; Lv2PluginEventData() @@ -373,7 +373,7 @@ public: carla_fill(fFeatures, kFeatureCount+1, nullptr); #endif - kData->osc.thread.setMode(CarlaPluginThread::PLUGIN_THREAD_LV2_GUI); + pData->osc.thread.setMode(CarlaPluginThread::PLUGIN_THREAD_LV2_GUI); for (uint32_t i=0; i < CARLA_URI_MAP_ID_COUNT; ++i) fCustomURIDs.append(nullptr); @@ -409,10 +409,10 @@ public: if (fUi.type == PLUGIN_UI_OSC) { // 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("LV2 OSC-GUI thread still running, forcing termination now"); - kData->osc.thread.terminate(); + pData->osc.thread.terminate(); } } else @@ -437,22 +437,22 @@ public: } fUi.descriptor = nullptr; - kData->uiLibClose(); + pData->uiLibClose(); } fUi.rdfDescriptor = nullptr; } - 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) @@ -621,9 +621,9 @@ public: uint32_t parameterScalePointCount(const uint32_t parameterId) const override { CARLA_ASSERT(fRdfDescriptor != 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(fRdfDescriptor->PortCount)) { @@ -653,11 +653,11 @@ public: if (! (hasMidiIn || needsFixedBuffer())) 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; } @@ -676,10 +676,10 @@ public: float getParameterValue(const uint32_t parameterId) override { CARLA_ASSERT(fParamBuffers != nullptr); - CARLA_ASSERT(parameterId < kData->param.count); + CARLA_ASSERT(parameterId < pData->param.count); - if (kData->param.data[parameterId].hints & PARAMETER_IS_STRICT_BOUNDS) - kData->param.ranges[parameterId].fixValue(fParamBuffers[parameterId]); + if (pData->param.data[parameterId].hints & PARAMETER_IS_STRICT_BOUNDS) + pData->param.ranges[parameterId].fixValue(fParamBuffers[parameterId]); return fParamBuffers[parameterId]; } @@ -687,10 +687,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 (rindex < static_cast(fRdfDescriptor->PortCount)) { @@ -750,9 +750,9 @@ public: void getParameterName(const uint32_t parameterId, char* const strBuf) override { CARLA_ASSERT(fRdfDescriptor != 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(fRdfDescriptor->PortCount)) std::strncpy(strBuf, fRdfDescriptor->Ports[rindex].Name, STR_MAX); @@ -763,9 +763,9 @@ public: void getParameterSymbol(const uint32_t parameterId, char* const strBuf) override { CARLA_ASSERT(fRdfDescriptor != 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(fRdfDescriptor->PortCount)) std::strncpy(strBuf, fRdfDescriptor->Ports[rindex].Symbol, STR_MAX); @@ -776,9 +776,9 @@ public: void getParameterUnit(const uint32_t parameterId, char* const strBuf) override { CARLA_ASSERT(fRdfDescriptor != 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(fRdfDescriptor->PortCount)) { @@ -875,10 +875,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 (rindex < static_cast(fRdfDescriptor->PortCount)) { @@ -924,8 +924,8 @@ public: QString guiTitle(QString("%1 (GUI)").arg((const char*)fName)); - if (kData->gui != nullptr) - kData->gui->setWindowTitle(guiTitle); + if (pData->gui != nullptr) + pData->gui->setWindowTitle(guiTitle); if (fFeatures[kFeatureIdExternalUi] != nullptr && fFeatures[kFeatureIdExternalUi]->data != nullptr) { @@ -943,9 +943,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); @@ -1050,17 +1050,17 @@ public: { CARLA_ASSERT(fDescriptor != nullptr); CARLA_ASSERT(fHandle != nullptr); - CARLA_ASSERT(index >= -1 && index < static_cast(kData->midiprog.count)); + CARLA_ASSERT(index >= -1 && index < static_cast(pData->midiprog.count)); if (index < -1) index = -1; - else if (index > static_cast(kData->midiprog.count)) + else if (index > static_cast(pData->midiprog.count)) return; if (index >= 0 && fExt.programs != nullptr && fExt.programs->select_program != nullptr) { - 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 ScopedSingleProcessLocker spl(this, (sendGui || sendOsc || sendCallback)); @@ -1085,19 +1085,19 @@ public: { if (yesNo) { - kData->osc.thread.start(); + pData->osc.thread.start(); } else { - if (kData->osc.data.target != nullptr) + if (pData->osc.data.target != nullptr) { - osc_send_hide(&kData->osc.data); - osc_send_quit(&kData->osc.data); - kData->osc.data.free(); + osc_send_hide(&pData->osc.data); + osc_send_quit(&pData->osc.data); + pData->osc.data.free(); } - if (kData->osc.thread.isRunning() && ! kData->osc.thread.wait(kData->engine->getOptions().oscUiTimeout)) - kData->osc.thread.terminate(); + if (pData->osc.thread.isRunning() && ! pData->osc.thread.wait(pData->engine->getOptions().oscUiTimeout)) + pData->osc.thread.terminate(); } return; @@ -1147,8 +1147,8 @@ public: { fUi.handle = nullptr; fUi.widget = nullptr; - kData->engine->callback(CALLBACK_ERROR, fId, 0, 0, 0.0f, "Plugin refused to open its own UI"); - kData->engine->callback(CALLBACK_SHOW_GUI, fId, 0, 0, 0.0f, nullptr); + pData->engine->callback(CALLBACK_ERROR, fId, 0, 0, 0.0f, "Plugin refused to open its own UI"); + pData->engine->callback(CALLBACK_SHOW_GUI, fId, 0, 0, 0.0f, nullptr); return; } @@ -1172,19 +1172,19 @@ public: { if (yesNo) { - if (kData->gui == nullptr) + if (pData->gui == nullptr) { // TODO CarlaPluginGui::Options guiOptions; guiOptions.parented = (fUi.type == PLUGIN_UI_PARENT); guiOptions.resizable = isUiResizable(); - kData->gui = new CarlaPluginGui(kData->engine, this, guiOptions, kData->guiGeometry); + pData->gui = new CarlaPluginGui(pData->engine, this, guiOptions, pData->guiGeometry); } if (fUi.type == PLUGIN_UI_PARENT) { - fFeatures[kFeatureIdUiParent]->data = kData->gui->getContainerWinId(); + fFeatures[kFeatureIdUiParent]->data = pData->gui->getContainerWinId(); fFeatures[kFeatureIdUiParent]->URI = LV2_UI__parent; } @@ -1203,23 +1203,23 @@ public: fUi.handle = nullptr; fUi.widget = nullptr; - kData->guiGeometry = kData->gui->saveGeometry(); - kData->gui->close(); - delete kData->gui; - kData->gui = nullptr; + pData->guiGeometry = pData->gui->saveGeometry(); + pData->gui->close(); + delete pData->gui; + pData->gui = nullptr; - kData->engine->callback(CALLBACK_ERROR, fId, 0, 0, 0.0f, "Plugin refused to open its own UI"); - kData->engine->callback(CALLBACK_SHOW_GUI, fId, -1, 0, 0.0f, nullptr); + pData->engine->callback(CALLBACK_ERROR, fId, 0, 0, 0.0f, "Plugin refused to open its own UI"); + pData->engine->callback(CALLBACK_SHOW_GUI, fId, -1, 0, 0.0f, nullptr); return; } if (fUi.type == PLUGIN_UI_QT) - kData->gui->setWidget((QWidget*)fUi.widget); + pData->gui->setWidget((QWidget*)fUi.widget); updateUi(); - kData->gui->setWindowTitle(QString("%1 (GUI)").arg((const char*)fName)); - kData->gui->show(); + pData->gui->setWindowTitle(QString("%1 (GUI)").arg((const char*)fName)); + pData->gui->show(); } else { @@ -1227,12 +1227,12 @@ public: fUi.handle = nullptr; fUi.widget = nullptr; - if (kData->gui != nullptr) + if (pData->gui != nullptr) { - kData->guiGeometry = kData->gui->saveGeometry(); - kData->gui->close(); - delete kData->gui; - kData->gui = nullptr; + pData->guiGeometry = pData->gui->saveGeometry(); + pData->gui->close(); + delete pData->gui; + pData->gui = nullptr; } } } @@ -1258,10 +1258,10 @@ public: if (fUi.type == PLUGIN_UI_OSC) { - if (kData->osc.data.target != nullptr) + if (pData->osc.data.target != nullptr) { QByteArray chunk((const char*)atom, lv2_atom_total_size(atom)); - osc_send_lv2_atom_transfer(&kData->osc.data, portIndex, chunk.toBase64().constData()); + osc_send_lv2_atom_transfer(&pData->osc.data, portIndex, chunk.toBase64().constData()); } } else if (fUi.type != PLUGIN_UI_NULL) @@ -1280,7 +1280,7 @@ public: if (fExt.uiidle != nullptr && fExt.uiidle->idle(fUi.handle) != 0) { showGui(false); - kData->engine->callback(CALLBACK_SHOW_GUI, fId, 0, 0, 0.0f, nullptr); + pData->engine->callback(CALLBACK_SHOW_GUI, fId, 0, 0, 0.0f, nullptr); } } @@ -1293,12 +1293,12 @@ public: void reload() override { carla_debug("Lv2Plugin::reload() - start"); - CARLA_ASSERT(kData->engine != nullptr); + CARLA_ASSERT(pData->engine != nullptr); CARLA_ASSERT(fHandle != nullptr); CARLA_ASSERT(fDescriptor != nullptr); CARLA_ASSERT(fRdfDescriptor != nullptr); - if (kData->engine == nullptr) + if (pData->engine == nullptr) return; if (fHandle == nullptr) return; @@ -1307,17 +1307,17 @@ public: if (fRdfDescriptor == 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(kData->engine->getSampleRate())); + const float sampleRate(static_cast(pData->engine->getSampleRate())); const uint32_t portCount(static_cast(fRdfDescriptor->PortCount)); uint32_t aIns, aOuts, cvIns, cvOuts, params, j; @@ -1381,16 +1381,16 @@ public: if (fDescriptor->extension_data != nullptr) { - if (kData->extraHints & PLUGIN_HAS_EXTENSION_OPTIONS) + if (pData->extraHints & PLUGIN_HAS_EXTENSION_OPTIONS) fExt.options = (const LV2_Options_Interface*)fDescriptor->extension_data(LV2_OPTIONS__interface); - if (kData->extraHints & PLUGIN_HAS_EXTENSION_PROGRAMS) + if (pData->extraHints & PLUGIN_HAS_EXTENSION_PROGRAMS) fExt.programs = (const LV2_Programs_Interface*)fDescriptor->extension_data(LV2_PROGRAMS__Interface); - if (kData->extraHints & PLUGIN_HAS_EXTENSION_STATE) + if (pData->extraHints & PLUGIN_HAS_EXTENSION_STATE) fExt.state = (const LV2_State_Interface*)fDescriptor->extension_data(LV2_STATE__interface); - if (kData->extraHints & PLUGIN_HAS_EXTENSION_WORKER) + if (pData->extraHints & PLUGIN_HAS_EXTENSION_WORKER) fExt.worker = (const LV2_Worker_Interface*)fDescriptor->extension_data(LV2_WORKER__interface); } @@ -1417,7 +1417,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) @@ -1426,7 +1426,7 @@ public: if (aOuts > 0) { - kData->audioOut.createNew(aOuts); + pData->audioOut.createNew(aOuts); fAudioOutBuffers = new float*[aOuts]; needsCtrlIn = true; @@ -1448,7 +1448,7 @@ public: if (params > 0) { - kData->param.createNew(params+cvIns+cvOuts); + pData->param.createNew(params+cvIns+cvOuts); fParamBuffers = new float[params+cvIns+cvOuts]; carla_zeroFloat(fParamBuffers, params+cvIns+cvOuts); @@ -1518,7 +1518,7 @@ public: } } - const uint portNameSize(kData->engine->maxPortNameSize()); + const uint portNameSize(pData->engine->maxPortNameSize()); CarlaString portName; for (uint32_t i=0, iAudioIn=0, iAudioOut=0, iCvIn=0, iCvOut=0, iEvIn=0, iEvOut=0, iCtrl=0; i < portCount; ++i) @@ -1544,27 +1544,27 @@ public: if (LV2_IS_PORT_INPUT(portTypes)) { 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 (LV2_IS_PORT_OUTPUT(portTypes)) { 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 @@ -1575,7 +1575,7 @@ public: if (LV2_IS_PORT_INPUT(portTypes)) { j = iCvIn++; - fCvIn.ports[j].port = (CarlaEngineCVPort*)kData->client->addPort(kEnginePortTypeCV, portName, true); + fCvIn.ports[j].port = (CarlaEngineCVPort*)pData->client->addPort(kEnginePortTypeCV, portName, true); fCvIn.ports[j].rindex = i; fCvIn.ports[j].param = params + j; @@ -1585,25 +1585,25 @@ public: fDescriptor->connect_port(fHandle2, i, fCvIn.ports[j].port->getBuffer()); j = fCvIn.ports[j].param; - kData->param.data[j].type = PARAMETER_INPUT; - kData->param.data[j].index = j; - kData->param.data[j].rindex = i; - kData->param.data[j].hints = PARAMETER_IS_ENABLED|PARAMETER_IS_READ_ONLY; - kData->param.data[j].midiChannel = 0; - kData->param.data[j].midiCC = -1; - kData->param.ranges[j].min = -1.0f; - kData->param.ranges[j].max = 1.0f; - kData->param.ranges[j].def = 0.0f; - kData->param.ranges[j].step = 0.01f; - kData->param.ranges[j].stepSmall = 0.001f; - kData->param.ranges[j].stepLarge = 0.1f; + pData->param.data[j].type = PARAMETER_INPUT; + pData->param.data[j].index = j; + pData->param.data[j].rindex = i; + pData->param.data[j].hints = PARAMETER_IS_ENABLED|PARAMETER_IS_READ_ONLY; + pData->param.data[j].midiChannel = 0; + pData->param.data[j].midiCC = -1; + pData->param.ranges[j].min = -1.0f; + pData->param.ranges[j].max = 1.0f; + pData->param.ranges[j].def = 0.0f; + pData->param.ranges[j].step = 0.01f; + pData->param.ranges[j].stepSmall = 0.001f; + pData->param.ranges[j].stepLarge = 0.1f; fParamBuffers[j] = 0.0f; } else if (LV2_IS_PORT_OUTPUT(portTypes)) { j = iCvOut++; - fCvOut.ports[j].port = (CarlaEngineCVPort*)kData->client->addPort(kEnginePortTypeCV, portName, false); + fCvOut.ports[j].port = (CarlaEngineCVPort*)pData->client->addPort(kEnginePortTypeCV, portName, false); fCvOut.ports[j].rindex = i; fCvOut.ports[j].param = params + cvIns + j; @@ -1613,18 +1613,18 @@ public: fDescriptor->connect_port(fHandle2, i, fCvOut.ports[j].port->getBuffer()); j = fCvOut.ports[j].param; - kData->param.data[j].type = PARAMETER_OUTPUT; - kData->param.data[j].index = j; - kData->param.data[j].rindex = i; - kData->param.data[j].hints = PARAMETER_IS_ENABLED|PARAMETER_IS_AUTOMABLE; - kData->param.data[j].midiChannel = 0; - kData->param.data[j].midiCC = -1; - kData->param.ranges[j].min = -1.0f; - kData->param.ranges[j].max = 1.0f; - kData->param.ranges[j].def = 0.0f; - kData->param.ranges[j].step = 0.01f; - kData->param.ranges[j].stepSmall = 0.001f; - kData->param.ranges[j].stepLarge = 0.1f; + pData->param.data[j].type = PARAMETER_OUTPUT; + pData->param.data[j].index = j; + pData->param.data[j].rindex = i; + pData->param.data[j].hints = PARAMETER_IS_ENABLED|PARAMETER_IS_AUTOMABLE; + pData->param.data[j].midiChannel = 0; + pData->param.data[j].midiCC = -1; + pData->param.ranges[j].min = -1.0f; + pData->param.ranges[j].max = 1.0f; + pData->param.ranges[j].def = 0.0f; + pData->param.ranges[j].step = 0.01f; + pData->param.ranges[j].stepSmall = 0.001f; + pData->param.ranges[j].stepLarge = 0.1f; fParamBuffers[j] = 0.0f; } else @@ -1661,7 +1661,7 @@ public: else { if (portTypes & LV2_PORT_DATA_MIDI_EVENT) - fEventsIn.data[j].port = (CarlaEngineEventPort*)kData->client->addPort(kEnginePortTypeEvent, portName, true); + fEventsIn.data[j].port = (CarlaEngineEventPort*)pData->client->addPort(kEnginePortTypeEvent, portName, true); if (LV2_IS_PORT_DESIGNATION_CONTROL(fRdfDescriptor->Ports[i].Designation)) { @@ -1699,7 +1699,7 @@ public: else { if (portTypes & LV2_PORT_DATA_MIDI_EVENT) - fEventsOut.data[j].port = (CarlaEngineEventPort*)kData->client->addPort(kEnginePortTypeEvent, portName, false); + fEventsOut.data[j].port = (CarlaEngineEventPort*)pData->client->addPort(kEnginePortTypeEvent, portName, false); if (LV2_IS_PORT_DESIGNATION_CONTROL(fRdfDescriptor->Ports[i].Designation)) { @@ -1742,7 +1742,7 @@ public: else { if (portTypes & LV2_PORT_DATA_MIDI_EVENT) - fEventsIn.data[j].port = (CarlaEngineEventPort*)kData->client->addPort(kEnginePortTypeEvent, portName, true); + fEventsIn.data[j].port = (CarlaEngineEventPort*)pData->client->addPort(kEnginePortTypeEvent, portName, true); if (LV2_IS_PORT_DESIGNATION_CONTROL(fRdfDescriptor->Ports[i].Designation)) { @@ -1780,7 +1780,7 @@ public: else { if (portTypes & LV2_PORT_DATA_MIDI_EVENT) - fEventsOut.data[j].port = (CarlaEngineEventPort*)kData->client->addPort(kEnginePortTypeEvent, portName, false); + fEventsOut.data[j].port = (CarlaEngineEventPort*)pData->client->addPort(kEnginePortTypeEvent, portName, false); if (LV2_IS_PORT_DESIGNATION_CONTROL(fRdfDescriptor->Ports[i].Designation)) { @@ -1814,7 +1814,7 @@ public: } else { - fEventsIn.data[j].port = (CarlaEngineEventPort*)kData->client->addPort(kEnginePortTypeEvent, portName, true); + fEventsIn.data[j].port = (CarlaEngineEventPort*)pData->client->addPort(kEnginePortTypeEvent, portName, true); if (LV2_IS_PORT_DESIGNATION_CONTROL(fRdfDescriptor->Ports[i].Designation)) { @@ -1843,7 +1843,7 @@ public: } else { - fEventsOut.data[j].port = (CarlaEngineEventPort*)kData->client->addPort(kEnginePortTypeEvent, portName, false); + fEventsOut.data[j].port = (CarlaEngineEventPort*)pData->client->addPort(kEnginePortTypeEvent, portName, false); if (LV2_IS_PORT_DESIGNATION_CONTROL(fRdfDescriptor->Ports[i].Designation)) { @@ -1862,11 +1862,11 @@ public: const LV2_RDF_PortPoints portPoints(fRdfDescriptor->Ports[i].Points); 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; @@ -1924,7 +1924,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 (LV2_IS_PORT_TOGGLED(portProps)) @@ -1932,14 +1932,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 (LV2_IS_PORT_INTEGER(portProps)) { 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 { @@ -1962,22 +1962,22 @@ public: stepSmall = 1.0f; stepLarge = 1.0f; - kData->param.data[j].type = PARAMETER_SAMPLE_RATE; - kData->param.data[j].hints = 0x0; + pData->param.data[j].type = PARAMETER_SAMPLE_RATE; + pData->param.data[j].hints = 0x0; } else if (LV2_IS_PORT_DESIGNATION_FREEWHEELING(portDesignation)) { - kData->param.data[j].type = PARAMETER_LV2_FREEWHEEL; + pData->param.data[j].type = PARAMETER_LV2_FREEWHEEL; } else if (LV2_IS_PORT_DESIGNATION_TIME(portDesignation)) { - kData->param.data[j].type = PARAMETER_LV2_TIME; + pData->param.data[j].type = PARAMETER_LV2_TIME; } else { - 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; } @@ -1987,7 +1987,7 @@ public: if (LV2_IS_PORT_MIDI_MAP_CC(portMidiMap.Type)) { if (! MIDI_IS_CONTROL_BANK_SELECT(portMidiMap.Number)) - kData->param.data[j].midiCC = portMidiMap.Number; + pData->param.data[j].midiCC = portMidiMap.Number; } } else if (LV2_IS_PORT_OUTPUT(portTypes)) @@ -2001,8 +2001,8 @@ public: stepSmall = 1.0f; stepLarge = 1.0f; - kData->param.data[j].type = PARAMETER_LATENCY; - kData->param.data[j].hints = 0x0; + pData->param.data[j].type = PARAMETER_LATENCY; + pData->param.data[j].hints = 0x0; } else if (LV2_IS_PORT_DESIGNATION_SAMPLE_RATE(portDesignation)) { @@ -2011,8 +2011,8 @@ public: stepSmall = 1.0f; stepLarge = 1.0f; - kData->param.data[j].type = PARAMETER_SAMPLE_RATE; - kData->param.data[j].hints = 0x0; + pData->param.data[j].type = PARAMETER_SAMPLE_RATE; + pData->param.data[j].hints = 0x0; } else if (LV2_IS_PORT_DESIGNATION_FREEWHEELING(portDesignation)) { @@ -2020,52 +2020,52 @@ public: } else if (LV2_IS_PORT_DESIGNATION_TIME(portDesignation)) { - kData->param.data[j].type = PARAMETER_LV2_TIME; + pData->param.data[j].type = PARAMETER_LV2_TIME; } 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 (LV2_IS_PORT_ENUMERATION(portProps)) - kData->param.data[j].hints |= PARAMETER_USES_SCALEPOINTS; + pData->param.data[j].hints |= PARAMETER_USES_SCALEPOINTS; if (LV2_IS_PORT_LOGARITHMIC(portProps)) - kData->param.data[j].hints |= PARAMETER_IS_LOGARITHMIC; + pData->param.data[j].hints |= PARAMETER_IS_LOGARITHMIC; if (LV2_IS_PORT_TRIGGER(portProps)) - kData->param.data[j].hints |= PARAMETER_IS_TRIGGER; + pData->param.data[j].hints |= PARAMETER_IS_TRIGGER; if (LV2_IS_PORT_STRICT_BOUNDS(portProps)) - kData->param.data[j].hints |= PARAMETER_IS_STRICT_BOUNDS; + pData->param.data[j].hints |= PARAMETER_IS_STRICT_BOUNDS; // check if parameter is not enabled or automable if (LV2_IS_PORT_NOT_ON_GUI(portProps)) { - kData->param.data[j].hints &= ~(PARAMETER_IS_ENABLED|PARAMETER_IS_AUTOMABLE); + pData->param.data[j].hints &= ~(PARAMETER_IS_ENABLED|PARAMETER_IS_AUTOMABLE); } else if (LV2_IS_PORT_CAUSES_ARTIFACTS(portProps) || LV2_IS_PORT_EXPENSIVE(portProps) || LV2_IS_PORT_NOT_AUTOMATIC(portProps)) - kData->param.data[j].hints &= ~PARAMETER_IS_AUTOMABLE; + pData->param.data[j].hints &= ~PARAMETER_IS_AUTOMABLE; - 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 - if (kData->param.data[j].type != PARAMETER_LV2_FREEWHEEL) + if (pData->param.data[j].type != PARAMETER_LV2_FREEWHEEL) fParamBuffers[j] = def; else fParamBuffers[j] = min; @@ -2098,7 +2098,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) @@ -2114,14 +2114,14 @@ 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 (fEventsIn.ctrl != nullptr && fEventsIn.ctrl->port == nullptr) - fEventsIn.ctrl->port = kData->event.portIn; + fEventsIn.ctrl->port = pData->event.portIn; if (fEventsOut.ctrl != nullptr && fEventsOut.ctrl->port == nullptr) - fEventsOut.ctrl->port = kData->event.portOut; + fEventsOut.ctrl->port = pData->event.portOut; if (forcedStereoIn || forcedStereoOut) fOptions |= PLUGIN_OPTION_FORCE_STEREO; @@ -2155,23 +2155,23 @@ public: fHints |= PLUGIN_CAN_BALANCE; // extra plugin hints - kData->extraHints &= ~PLUGIN_HINT_CAN_RUN_RACK; + pData->extraHints &= ~PLUGIN_HINT_CAN_RUN_RACK; if (fExt.state != nullptr || fExt.worker != nullptr) { if ((aIns == 0 || aIns == 2) && (aOuts == 0 || aOuts == 2) && evIns.count() <= 1 && evOuts.count() <= 1) - kData->extraHints |= PLUGIN_HINT_CAN_RUN_RACK; + pData->extraHints |= PLUGIN_HINT_CAN_RUN_RACK; } else { if (aIns <= 2 && aOuts <= 2 && (aIns == aOuts || aIns == 0 || aOuts == 0) && evIns.count() <= 1 && evOuts.count() <= 1) - kData->extraHints |= PLUGIN_HINT_CAN_RUN_RACK; + pData->extraHints |= PLUGIN_HINT_CAN_RUN_RACK; } - bufferSizeChanged(kData->engine->getBufferSize()); + bufferSizeChanged(pData->engine->getBufferSize()); reloadPrograms(true); - if (kData->active) + if (pData->active) activate(); evIns.clear(); @@ -2183,27 +2183,27 @@ public: void reloadPrograms(const bool init) override { carla_debug("Lv2Plugin::reloadPrograms(%s)", bool2str(init)); - uint32_t i, oldCount = kData->midiprog.count; - const int32_t current = kData->midiprog.current; + uint32_t i, oldCount = pData->midiprog.count; + const int32_t current = pData->midiprog.current; // special LV2 programs handling if (init) { - kData->prog.clear(); + pData->prog.clear(); const uint32_t count(fRdfDescriptor->PresetCount); if (count > 0) { - kData->prog.createNew(count); + pData->prog.createNew(count); for (i=0; i < count; ++i) - kData->prog.names[i] = carla_strdup(fRdfDescriptor->Presets[i].Label); + pData->prog.names[i] = carla_strdup(fRdfDescriptor->Presets[i].Label); } } // Delete old programs - kData->midiprog.clear(); + pData->midiprog.clear(); // Query new programs uint32_t count = 0; @@ -2215,7 +2215,7 @@ public: if (count > 0) { - kData->midiprog.createNew(count); + pData->midiprog.createNew(count); // Update data for (i=0; i < count; ++i) @@ -2224,20 +2224,20 @@ public: CARLA_ASSERT(pdesc != nullptr); CARLA_ASSERT(pdesc->name != nullptr); - kData->midiprog.data[i].bank = pdesc->bank; - kData->midiprog.data[i].program = pdesc->program; - kData->midiprog.data[i].name = carla_strdup(pdesc->name); + pData->midiprog.data[i].bank = pdesc->bank; + pData->midiprog.data[i].program = pdesc->program; + pData->midiprog.data[i].name = carla_strdup(pdesc->name); } } #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 @@ -2267,37 +2267,37 @@ public: if (count == oldCount+1) { // one midi program added, probably created by user - kData->midiprog.current = oldCount; + pData->midiprog.current = oldCount; programChanged = true; } else if (current < 0 && count > 0) { // programs exist now, but not before - kData->midiprog.current = 0; + pData->midiprog.current = 0; programChanged = true; } else if (current >= 0 && count == 0) { // programs existed before, but not anymore - kData->midiprog.current = -1; + pData->midiprog.current = -1; programChanged = true; } else if (current >= static_cast(count)) { // current midi program > count - kData->midiprog.current = 0; + pData->midiprog.current = 0; programChanged = true; } else { // no change - kData->midiprog.current = current; + pData->midiprog.current = current; } if (programChanged) - setMidiProgram(kData->midiprog.current, true, true, true); + setMidiProgram(pData->midiprog.current, true, true, true); - kData->engine->callback(CALLBACK_RELOAD_PROGRAMS, fId, 0, 0, 0.0f, nullptr); + pData->engine->callback(CALLBACK_RELOAD_PROGRAMS, fId, 0, 0, 0.0f, nullptr); } } @@ -2341,10 +2341,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; @@ -2400,7 +2400,7 @@ public: // -------------------------------------------------------------------------------------------------------- // Check if needs reset - if (kData->needsReset) + if (pData->needsReset) { uint8_t midiData[3] = { 0 }; @@ -2437,11 +2437,11 @@ public: lv2midi_put_event(&evInMidiStates[k], 0, 3, midiData); } } - 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) { - midiData[0] = MIDI_STATUS_NOTE_OFF + kData->ctrlChannel; + midiData[0] = MIDI_STATUS_NOTE_OFF + pData->ctrlChannel; midiData[1] = k; if (fEventsIn.ctrl->type & CARLA_EVENT_DATA_ATOM) @@ -2456,13 +2456,13 @@ public: } } - //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; CARLA_PROCESS_CONTINUE_CHECK; } @@ -2470,7 +2470,7 @@ public: // -------------------------------------------------------------------------------------------------------- // TimeInfo - const EngineTimeInfo& timeInfo(kData->engine->getTimeInfo()); + const EngineTimeInfo& timeInfo(pData->engine->getTimeInfo()); if (fFirstActive || fLastTimeInfo != timeInfo) { @@ -2478,13 +2478,13 @@ public: int32_t rindex; // update input ports - for (k=0; k < kData->param.count; ++k) + for (k=0; k < pData->param.count; ++k) { - if (kData->param.data[k].type != PARAMETER_LV2_TIME) + if (pData->param.data[k].type != PARAMETER_LV2_TIME) continue; doPostRt = false; - rindex = kData->param.data[k].rindex; + rindex = pData->param.data[k].rindex; CARLA_ASSERT(rindex >= 0 && rindex < static_cast(fRdfDescriptor->PortCount)); @@ -2595,7 +2595,7 @@ public: CARLA_ASSERT(atom->size < 256); } - kData->postRtEvents.trySplice(); + pData->postRtEvents.trySplice(); std::memcpy(&fLastTimeInfo, &timeInfo, sizeof(EngineTimeInfo)); @@ -2640,20 +2640,20 @@ public: // ---------------------------------------------------------------------------------------------------- // MIDI Input (External) - if (kData->extNotes.mutex.tryLock()) + if (pData->extNotes.mutex.tryLock()) { if ((fEventsIn.ctrl->type & CARLA_EVENT_TYPE_MIDI) == 0) { // does not handle MIDI - kData->extNotes.data.clear(); + pData->extNotes.data.clear(); } else { k = fEventsIn.ctrlIndex; - 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); @@ -2674,7 +2674,7 @@ public: } } - kData->extNotes.mutex.unlock(); + pData->extNotes.mutex.unlock(); } // End of MIDI Input (External) @@ -2689,8 +2689,8 @@ public: 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) { @@ -2710,8 +2710,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; @@ -2758,7 +2758,7 @@ public: { #ifndef BUILD_BRIDGE // Control backend stuff - if (event.channel == kData->ctrlChannel) + if (event.channel == pData->ctrlChannel) { float value; @@ -2806,28 +2806,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); } @@ -2856,18 +2856,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); @@ -2901,7 +2901,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(); @@ -2971,7 +2971,7 @@ public: } } - kData->postRtEvents.trySplice(); + pData->postRtEvents.trySplice(); if (frames > timeOffset) processSingle(inBuffer, outBuffer, frames - timeOffset, timeOffset); @@ -3064,26 +3064,26 @@ 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; - if (kData->param.data[k].hints & PARAMETER_IS_STRICT_BOUNDS) - kData->param.ranges[k].fixValue(fParamBuffers[k]); + if (pData->param.data[k].hints & PARAMETER_IS_STRICT_BOUNDS) + 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(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(pData->param.data[k].midiCC); + value = pData->param.ranges[k].normalizeValue(fParamBuffers[k]); + pData->event.portOut->writeControlEvent(0, channel, kEngineControlEventTypeParameter, param, value); } } @@ -3116,13 +3116,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) @@ -3134,13 +3134,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; @@ -3152,9 +3152,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); // -------------------------------------------------------------------------------------------------------- @@ -3183,35 +3183,35 @@ public: // -------------------------------------------------------------------------------------------------------- // Special Parameters - for (k=0; k < kData->param.count; ++k) + for (k=0; k < pData->param.count; ++k) { - 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_TRIGGER) + if (pData->param.data[k].hints & PARAMETER_IS_TRIGGER) { - if (fParamBuffers[k] != kData->param.ranges[k].def) + if (fParamBuffers[k] != pData->param.ranges[k].def) { - fParamBuffers[k] = kData->param.ranges[k].def; + fParamBuffers[k] = pData->param.ranges[k].def; postponeRtEvent(kPluginPostRtEventParameterChange, static_cast(k), 0, fParamBuffers[k]); } } } - kData->postRtEvents.trySplice(); + pData->postRtEvents.trySplice(); #ifndef BUILD_BRIDGE // -------------------------------------------------------------------------------------------------------- // 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) @@ -3219,13 +3219,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)); } } @@ -3236,12 +3236,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) { @@ -3263,21 +3263,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]; @@ -3298,7 +3298,7 @@ public: // -------------------------------------------------------------------------------------------------------- - kData->singleMutex.unlock(); + pData->singleMutex.unlock(); return true; } @@ -3307,14 +3307,14 @@ public: CARLA_ASSERT_INT(newBufferSize > 0, newBufferSize); carla_debug("Lv2Plugin::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]; @@ -3349,38 +3349,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]); } } @@ -3414,9 +3414,9 @@ public: fExt.options->set(fHandle, &fLv2Options.optSampleRate); } - for (uint32_t k=0; k < kData->param.count; ++k) + for (uint32_t k=0; k < pData->param.count; ++k) { - if (kData->param.data[k].type == PARAMETER_SAMPLE_RATE) + if (pData->param.data[k].type == PARAMETER_SAMPLE_RATE) { fParamBuffers[k] = newSampleRate; postponeRtEvent(kPluginPostRtEventParameterChange, static_cast(k), 1, fParamBuffers[k]); @@ -3428,11 +3428,11 @@ public: void offlineModeChanged(const bool isOffline) override { - for (uint32_t k=0; k < kData->param.count; ++k) + for (uint32_t k=0; k < pData->param.count; ++k) { - if (kData->param.data[k].type == PARAMETER_LV2_FREEWHEEL) + if (pData->param.data[k].type == PARAMETER_LV2_FREEWHEEL) { - fParamBuffers[k] = isOffline ? kData->param.ranges[k].max : kData->param.ranges[k].min; + fParamBuffers[k] = isOffline ? pData->param.ranges[k].max : pData->param.ranges[k].min; postponeRtEvent(kPluginPostRtEventParameterChange, static_cast(k), 1, fParamBuffers[k]); } } @@ -3443,10 +3443,10 @@ public: void initBuffers() override { - fEventsIn.initBuffers(kData->engine); - fEventsOut.initBuffers(kData->engine); - fCvIn.initBuffers(kData->engine); - fCvOut.initBuffers(kData->engine); + fEventsIn.initBuffers(pData->engine); + fEventsOut.initBuffers(pData->engine); + fCvIn.initBuffers(pData->engine); + fCvOut.initBuffers(pData->engine); CarlaPlugin::initBuffers(); } @@ -3457,7 +3457,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) { @@ -3472,7 +3472,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) { @@ -3508,41 +3508,41 @@ public: { CARLA_ASSERT(fDescriptor != nullptr); CARLA_ASSERT(fHandle != nullptr); - CARLA_ASSERT(index < kData->param.count); + CARLA_ASSERT(index < pData->param.count); if (fDescriptor == nullptr || fHandle == nullptr) return; - if (index >= kData->param.count) + if (index >= pData->param.count) return; if (fUi.type == PLUGIN_UI_OSC) { - if (kData->osc.data.target != nullptr) - osc_send_control(&kData->osc.data, kData->param.data[index].rindex, value); + if (pData->osc.data.target != nullptr) + osc_send_control(&pData->osc.data, pData->param.data[index].rindex, value); } else { if (fUi.handle != nullptr && fUi.descriptor != nullptr && fUi.descriptor->port_event != nullptr) - fUi.descriptor->port_event(fUi.handle, kData->param.data[index].rindex, sizeof(float), 0, &value); + fUi.descriptor->port_event(fUi.handle, pData->param.data[index].rindex, sizeof(float), 0, &value); } } void uiMidiProgramChange(const uint32_t index) override { - CARLA_ASSERT(index < kData->midiprog.count); + CARLA_ASSERT(index < pData->midiprog.count); - if (index >= kData->midiprog.count) + if (index >= pData->midiprog.count) return; if (fUi.type == PLUGIN_UI_OSC) { - if (kData->osc.data.target != nullptr) - osc_send_midi_program(&kData->osc.data, kData->midiprog.data[index].bank, kData->midiprog.data[index].program); + if (pData->osc.data.target != nullptr) + osc_send_midi_program(&pData->osc.data, pData->midiprog.data[index].bank, pData->midiprog.data[index].program); } else { if (fExt.uiprograms != nullptr && fExt.uiprograms->select_program != nullptr) - fExt.uiprograms->select_program(fUi.handle, kData->midiprog.data[index].bank, kData->midiprog.data[index].program); + fExt.uiprograms->select_program(fUi.handle, pData->midiprog.data[index].bank, pData->midiprog.data[index].program); } } @@ -3561,13 +3561,13 @@ public: if (fUi.type == PLUGIN_UI_OSC) { - if (kData->osc.data.target != nullptr) + if (pData->osc.data.target != nullptr) { uint8_t midiData[4] = { 0 }; midiData[1] = MIDI_STATUS_NOTE_ON + channel; midiData[2] = note; midiData[3] = velo; - osc_send_midi(&kData->osc.data, midiData); + osc_send_midi(&pData->osc.data, midiData); } } else @@ -3599,12 +3599,12 @@ public: if (fUi.type == PLUGIN_UI_OSC) { - if (kData->osc.data.target != nullptr) + if (pData->osc.data.target != nullptr) { uint8_t midiData[4] = { 0 }; midiData[1] = MIDI_STATUS_NOTE_OFF + channel; midiData[2] = note; - osc_send_midi(&kData->osc.data, midiData); + osc_send_midi(&pData->osc.data, midiData); } } else @@ -3630,7 +3630,7 @@ protected: void guiClosedCallback() override { showGui(false); - kData->engine->callback(CALLBACK_SHOW_GUI, fId, 0, 0, 0.0f, nullptr); + pData->engine->callback(CALLBACK_SHOW_GUI, fId, 0, 0, 0.0f, nullptr); } // ------------------------------------------------------------------- @@ -3654,8 +3654,8 @@ protected: const LV2_URID urid(fCustomURIDs.count()-1); - if (fUi.type == PLUGIN_UI_OSC && kData->osc.data.target != nullptr) - osc_send_lv2_urid_map(&kData->osc.data, urid, uri); + if (fUi.type == PLUGIN_UI_OSC && pData->osc.data.target != nullptr) + osc_send_lv2_urid_map(&pData->osc.data, urid, uri); return urid; } @@ -3687,21 +3687,21 @@ protected: return reloadPrograms(false); } - if (index >= 0 && index < static_cast(kData->midiprog.count) && fExt.programs != nullptr && fExt.programs->get_program != nullptr) + if (index >= 0 && index < static_cast(pData->midiprog.count) && fExt.programs != nullptr && fExt.programs->get_program != nullptr) { if (const LV2_Program_Descriptor* progDesc = fExt.programs->get_program(fHandle, index)) { CARLA_ASSERT(progDesc->name != nullptr); - 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].name = carla_strdup(progDesc->name ? progDesc->name : ""); + pData->midiprog.data[index].name = carla_strdup(progDesc->name ? progDesc->name : ""); - if (index == kData->midiprog.current) - kData->engine->callback(CALLBACK_UPDATE, fId, 0, 0, 0.0, nullptr); + if (index == pData->midiprog.current) + pData->engine->callback(CALLBACK_UPDATE, fId, 0, 0, 0.0, nullptr); else - kData->engine->callback(CALLBACK_RELOAD_PROGRAMS, fId, 0, 0, 0.0, nullptr); + pData->engine->callback(CALLBACK_RELOAD_PROGRAMS, fId, 0, 0, 0.0, nullptr); } } } @@ -3751,7 +3751,7 @@ protected: } // Check if we already have this key - for (NonRtList::Itenerator it = kData->custom.begin(); it.valid(); it.next()) + for (NonRtList::Itenerator it = pData->custom.begin(); it.valid(); it.next()) { CustomData& data(*it); @@ -3779,7 +3779,7 @@ protected: else newData.value = carla_strdup(QByteArray((const char*)value, size).toBase64().constData()); - kData->custom.append(newData); + pData->custom.append(newData); return LV2_STATE_SUCCESS; } @@ -3813,7 +3813,7 @@ protected: const char* stype = nullptr; const char* stringData = nullptr; - for (NonRtList::Itenerator it = kData->custom.begin(); it.valid(); it.next()) + for (NonRtList::Itenerator it = pData->custom.begin(); it.valid(); it.next()) { CustomData& data(*it); @@ -3860,7 +3860,7 @@ protected: return LV2_WORKER_ERR_UNKNOWN; } - //if (kData->engine->isOffline()) + //if (pData->engine->isOffline()) fExt.worker->work(fHandle, carla_lv2_worker_respond, this, size, data); //else // postponeEvent(PluginPostEventCustom, size, 0, 0.0, data); @@ -3896,7 +3896,7 @@ protected: fUi.handle = nullptr; fUi.widget = nullptr; - kData->engine->callback(CALLBACK_SHOW_GUI, fId, 0, 0, 0.0f, nullptr); + pData->engine->callback(CALLBACK_SHOW_GUI, fId, 0, 0, 0.0f, nullptr); } uint32_t handleUiPortMap(const char* const symbol) @@ -3917,15 +3917,15 @@ protected: int handleUiResize(const int width, const int height) { - CARLA_ASSERT(kData->gui != nullptr); + CARLA_ASSERT(pData->gui != nullptr); CARLA_ASSERT(width > 0); CARLA_ASSERT(height > 0); if (width <= 0 || height <= 0) return 1; - if (kData->gui != nullptr) - kData->gui->setSize(width, height); + if (pData->gui != nullptr) + pData->gui->setSize(width, height); return 0; } @@ -3942,9 +3942,9 @@ protected: const float value(*(const float*)buffer); - 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].rindex == static_cast(rindex)) + if (pData->param.data[i].rindex == static_cast(rindex)) { if (fParamBuffers[i] != value) setParameterValue(i, value, false, true, true); @@ -3993,9 +3993,9 @@ protected: { const float valuef(*(const float*)value); - 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].rindex == rindex) + if (pData->param.data[i].rindex == rindex) { setParameterValue(i, valuef, true, true, true); break; @@ -4036,7 +4036,7 @@ protected: const char* getUiBridgePath(const LV2_Property type) const { - const EngineOptions& options(kData->engine->getOptions()); + const EngineOptions& options(pData->engine->getOptions()); switch (type) { @@ -4108,19 +4108,19 @@ protected: fExt.uiprograms = nullptr; // update midi program - if (fExt.uiprograms && kData->midiprog.count > 0 && kData->midiprog.current >= 0) - fExt.uiprograms->select_program(fUi.handle, kData->midiprog.data[kData->midiprog.current].bank, - kData->midiprog.data[kData->midiprog.current].program); + if (fExt.uiprograms && pData->midiprog.count > 0 && pData->midiprog.current >= 0) + fExt.uiprograms->select_program(fUi.handle, pData->midiprog.data[pData->midiprog.current].bank, + pData->midiprog.data[pData->midiprog.current].program); } if (fUi.descriptor->port_event != nullptr) { // update control ports float value; - for (uint32_t i=0; i < kData->param.count; ++i) + for (uint32_t i=0; i < pData->param.count; ++i) { value = getParameterValue(i); - fUi.descriptor->port_event(fUi.handle, kData->param.data[i].rindex, sizeof(float), CARLA_URI_MAP_ID_NULL, &value); + fUi.descriptor->port_event(fUi.handle, pData->param.data[i].rindex, sizeof(float), CARLA_URI_MAP_ID_NULL, &value); } } } @@ -4130,27 +4130,27 @@ protected: public: bool init(const char* const name, const char* const uri) { - CARLA_ASSERT(kData->engine != nullptr); - CARLA_ASSERT(kData->client == nullptr); + CARLA_ASSERT(pData->engine != nullptr); + CARLA_ASSERT(pData->client == nullptr); CARLA_ASSERT(uri != 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 (uri == nullptr) { - kData->engine->setLastError("null uri"); + pData->engine->setLastError("null uri"); return false; } @@ -4163,16 +4163,16 @@ public: if (fRdfDescriptor == nullptr) { - kData->engine->setLastError("Failed to find the requested plugin in the LV2 Bundle"); + pData->engine->setLastError("Failed to find the requested plugin in the LV2 Bundle"); return false; } // --------------------------------------------------------------- // open DLL - if (! kData->libOpen(fRdfDescriptor->Binary)) + if (! pData->libOpen(fRdfDescriptor->Binary)) { - kData->engine->setLastError(kData->libError(fRdfDescriptor->Binary)); + pData->engine->setLastError(pData->libError(fRdfDescriptor->Binary)); return false; } @@ -4180,8 +4180,8 @@ public: // initialize options fLv2Options.minBufferSize = 1; - fLv2Options.maxBufferSize = kData->engine->getBufferSize(); - fLv2Options.sampleRate = kData->engine->getSampleRate(); + fLv2Options.maxBufferSize = pData->engine->getBufferSize(); + fLv2Options.sampleRate = pData->engine->getSampleRate(); // --------------------------------------------------------------- // initialize features (part 1) @@ -4296,7 +4296,7 @@ public: // get DLL main entry #if 0 - const LV2_Lib_Descriptor_Function libDescFn = (LV2_Lib_Descriptor_Function)kData->libSymbol("lv2_lib_descriptor"); + const LV2_Lib_Descriptor_Function libDescFn = (LV2_Lib_Descriptor_Function)pData->libSymbol("lv2_lib_descriptor"); if (libDescFn != nullptr) { @@ -4307,7 +4307,7 @@ public: if (libFn == nullptr || libFn->get_plugin == nullptr) { - kData->engine->setLastError("Plugin failed to return library descriptor"); + pData->engine->setLastError("Plugin failed to return library descriptor"); return false; } @@ -4326,11 +4326,11 @@ public: else #endif { - const LV2_Descriptor_Function descFn = (LV2_Descriptor_Function)kData->libSymbol("lv2_descriptor"); + const LV2_Descriptor_Function descFn = (LV2_Descriptor_Function)pData->libSymbol("lv2_descriptor"); if (descFn == nullptr) { - kData->engine->setLastError("Could not find the LV2 Descriptor in the plugin library"); + pData->engine->setLastError("Could not find the LV2 Descriptor in the plugin library"); return false; } @@ -4348,7 +4348,7 @@ public: if (fDescriptor == nullptr) { - kData->engine->setLastError("Could not find the requested plugin URI in the plugin library"); + pData->engine->setLastError("Could not find the requested plugin URI in the plugin library"); return false; } @@ -4366,7 +4366,7 @@ public: { if (! LV2_IS_PORT_OPTIONAL(fRdfDescriptor->Ports[i].Properties)) { - kData->engine->setLastError("Plugin requires a port type that is not currently supported"); + pData->engine->setLastError("Plugin requires a port type that is not currently supported"); canContinue = false; break; } @@ -4379,7 +4379,7 @@ public: if (LV2_IS_FEATURE_REQUIRED(fRdfDescriptor->Features[i].Type) && ! is_lv2_feature_supported(fRdfDescriptor->Features[i].URI)) { QString msg(QString("Plugin requires a feature that is not supported:\n%1").arg(fRdfDescriptor->Features[i].URI)); - kData->engine->setLastError(msg.toUtf8().constData()); + pData->engine->setLastError(msg.toUtf8().constData()); canContinue = false; break; } @@ -4389,13 +4389,13 @@ public: for (uint32_t i=0; i < fRdfDescriptor->ExtensionCount; ++i) { if (std::strcmp(fRdfDescriptor->Extensions[i], LV2_OPTIONS__interface) == 0) - kData->extraHints |= PLUGIN_HAS_EXTENSION_OPTIONS; + pData->extraHints |= PLUGIN_HAS_EXTENSION_OPTIONS; else if (std::strcmp(fRdfDescriptor->Extensions[i], LV2_PROGRAMS__Interface) == 0) - kData->extraHints |= PLUGIN_HAS_EXTENSION_PROGRAMS; + pData->extraHints |= PLUGIN_HAS_EXTENSION_PROGRAMS; else if (std::strcmp(fRdfDescriptor->Extensions[i], LV2_STATE__interface) == 0) - kData->extraHints |= PLUGIN_HAS_EXTENSION_STATE; + pData->extraHints |= PLUGIN_HAS_EXTENSION_STATE; else if (std::strcmp(fRdfDescriptor->Extensions[i], LV2_WORKER__interface) == 0) - kData->extraHints |= PLUGIN_HAS_EXTENSION_WORKER; + pData->extraHints |= PLUGIN_HAS_EXTENSION_WORKER; else carla_stdout("Plugin has non-supported extension: '%s'", fRdfDescriptor->Extensions[i]); } @@ -4410,29 +4410,29 @@ public: // get info if (name != nullptr) - fName = kData->engine->getUniquePluginName(name); + fName = pData->engine->getUniquePluginName(name); else - fName = kData->engine->getUniquePluginName(fRdfDescriptor->Name); + fName = pData->engine->getUniquePluginName(fRdfDescriptor->Name); // --------------------------------------------------------------- // 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, kData->engine->getSampleRate(), fRdfDescriptor->Bundle, fFeatures); + fHandle = fDescriptor->instantiate(fDescriptor, pData->engine->getSampleRate(), fRdfDescriptor->Bundle, fFeatures); if (fHandle == nullptr) { - kData->engine->setLastError("Plugin failed to initialize"); + pData->engine->setLastError("Plugin failed to initialize"); return false; } @@ -4448,7 +4448,7 @@ public: if (midiInCount() > 0 || needsFixedBuffer()) fOptions |= PLUGIN_OPTION_FIXED_BUFFER; - if (kData->engine->getOptions().forceStereo) + if (pData->engine->getOptions().forceStereo) fOptions |= PLUGIN_OPTION_FORCE_STEREO; if (midiInCount() > 0) @@ -4460,9 +4460,9 @@ public: } // load settings - kData->idStr = "LV2/"; - kData->idStr += uri; - fOptions = kData->loadSettings(fOptions, availableOptions()); + pData->idStr = "LV2/"; + pData->idStr += uri; + fOptions = pData->loadSettings(fOptions, availableOptions()); // ignore settings, we need this anyway if (midiInCount() > 0 || needsFixedBuffer()) @@ -4482,9 +4482,9 @@ public: eQt4 = eQt5 = eCocoa = eWindows = eX11 = eGtk2 = eGtk3 = iQt4 = iQt5 = iCocoa = iWindows = iX11 = iExt = iFinal = -1; #ifdef BUILD_BRIDGE - const bool preferUiBridges(kData->engine->getOptions().preferUiBridges); + const bool preferUiBridges(pData->engine->getOptions().preferUiBridges); #else - const bool preferUiBridges(kData->engine->getOptions().preferUiBridges && (fHints & PLUGIN_IS_BRIDGE) == 0); + const bool preferUiBridges(pData->engine->getOptions().preferUiBridges && (fHints & PLUGIN_IS_BRIDGE) == 0); #endif for (uint32_t i=0; i < fRdfDescriptor->UICount; ++i) @@ -4638,7 +4638,7 @@ public: if (const char* const oscBinary = getUiBridgePath(uiType)) { fUi.type = PLUGIN_UI_OSC; - kData->osc.thread.setOscData(oscBinary, fDescriptor->URI, fUi.rdfDescriptor->URI); + pData->osc.thread.setOscData(oscBinary, fDescriptor->URI, fUi.rdfDescriptor->URI); } } else @@ -4646,9 +4646,9 @@ public: // ------------------------------------------------------- // open UI DLL - if (! kData->uiLibOpen(fUi.rdfDescriptor->Binary)) + if (! pData->uiLibOpen(fUi.rdfDescriptor->Binary)) { - carla_stderr2("Could not load UI library, error was:\n%s", kData->libError(fUi.rdfDescriptor->Binary)); + carla_stderr2("Could not load UI library, error was:\n%s", pData->libError(fUi.rdfDescriptor->Binary)); fUi.rdfDescriptor = nullptr; return true; } @@ -4656,12 +4656,12 @@ public: // ------------------------------------------------------- // get UI DLL main entry - LV2UI_DescriptorFunction uiDescFn = (LV2UI_DescriptorFunction)kData->uiLibSymbol("lv2ui_descriptor"); + LV2UI_DescriptorFunction uiDescFn = (LV2UI_DescriptorFunction)pData->uiLibSymbol("lv2ui_descriptor"); if (uiDescFn == nullptr) { carla_stderr2("Could not find the LV2UI Descriptor in the UI library"); - kData->uiLibClose(); + pData->uiLibClose(); fUi.rdfDescriptor = nullptr; return true; } @@ -4679,7 +4679,7 @@ public: if (fUi.descriptor == nullptr) { carla_stderr2("Could not find the requested GUI in the plugin UI library"); - kData->uiLibClose(); + pData->uiLibClose(); fUi.rdfDescriptor = nullptr; return true; } @@ -4739,7 +4739,7 @@ public: if (fUi.type == PLUGIN_UI_NULL) { - kData->uiLibClose(); + pData->uiLibClose(); fUi.descriptor = nullptr; fUi.rdfDescriptor = nullptr; return true; diff --git a/source/backend/plugin/NativePlugin.cpp b/source/backend/plugin/NativePlugin.cpp index b54ccc5cf..ea3931580 100644 --- a/source/backend/plugin/NativePlugin.cpp +++ b/source/backend/plugin/NativePlugin.cpp @@ -29,6 +29,8 @@ # include #endif +extern "C" { + // Simple plugins void carla_register_native_plugin_bypass(); void carla_register_native_plugin_lfo(); @@ -70,6 +72,7 @@ void carla_register_native_plugin_Notes(); // ZynAddSubFX void carla_register_native_plugin_zynaddsubfx(); #endif +} void carla_register_all_plugins() { @@ -254,18 +257,18 @@ public: fDescriptor->ui_show(fHandle, false); } - 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(); CARLA_ASSERT(! fIsProcessing); - if (kData->active) + if (pData->active) { deactivate(); - kData->active = false; + pData->active = false; } if (fDescriptor != nullptr) @@ -330,9 +333,9 @@ public: { CARLA_ASSERT(fDescriptor != nullptr); CARLA_ASSERT(fHandle != nullptr); - CARLA_ASSERT(parameterId < kData->param.count); + CARLA_ASSERT(parameterId < pData->param.count); - if (fDescriptor->get_parameter_info != nullptr && parameterId < kData->param.count) + if (fDescriptor->get_parameter_info != nullptr && parameterId < pData->param.count) { if (const Parameter* const param = fDescriptor->get_parameter_info(fHandle, parameterId)) return param->scalePointCount; @@ -366,11 +369,11 @@ public: if (midiInCount() == 0 && (fDescriptor->hints & ::PLUGIN_USES_STATIC_BUFFERS) == 0) 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; } @@ -392,9 +395,9 @@ public: { CARLA_ASSERT(fDescriptor != nullptr); CARLA_ASSERT(fHandle != nullptr); - CARLA_ASSERT(parameterId < kData->param.count); + CARLA_ASSERT(parameterId < pData->param.count); - if (fDescriptor->get_parameter_value != nullptr && parameterId < kData->param.count) + if (fDescriptor->get_parameter_value != nullptr && parameterId < pData->param.count) return fDescriptor->get_parameter_value(fHandle, parameterId); return 0.0f; @@ -404,10 +407,10 @@ public: { CARLA_ASSERT(fDescriptor != nullptr); CARLA_ASSERT(fHandle != nullptr); - CARLA_ASSERT(parameterId < kData->param.count); + CARLA_ASSERT(parameterId < pData->param.count); CARLA_ASSERT(scalePointId < parameterScalePointCount(parameterId)); - if (fDescriptor->get_parameter_info != nullptr && parameterId < kData->param.count) + if (fDescriptor->get_parameter_info != nullptr && parameterId < pData->param.count) { if (const Parameter* const param = fDescriptor->get_parameter_info(fHandle, parameterId)) { @@ -463,9 +466,9 @@ public: { CARLA_ASSERT(fDescriptor != nullptr); CARLA_ASSERT(fHandle != nullptr); - CARLA_ASSERT(parameterId < kData->param.count); + CARLA_ASSERT(parameterId < pData->param.count); - if (fDescriptor->get_parameter_info != nullptr && parameterId < kData->param.count) + if (fDescriptor->get_parameter_info != nullptr && parameterId < pData->param.count) { const Parameter* const param(fDescriptor->get_parameter_info(fHandle, parameterId)); @@ -483,9 +486,9 @@ public: { CARLA_ASSERT(fDescriptor != nullptr); CARLA_ASSERT(fHandle != nullptr); - CARLA_ASSERT(parameterId < kData->param.count); + CARLA_ASSERT(parameterId < pData->param.count); - if (fDescriptor->get_parameter_value != nullptr && fDescriptor->get_parameter_text != nullptr && parameterId < kData->param.count) + if (fDescriptor->get_parameter_value != nullptr && fDescriptor->get_parameter_text != nullptr && parameterId < pData->param.count) { const float value(fDescriptor->get_parameter_value(fHandle, parameterId)); @@ -503,9 +506,9 @@ public: { CARLA_ASSERT(fDescriptor != nullptr); CARLA_ASSERT(fHandle != nullptr); - CARLA_ASSERT(parameterId < kData->param.count); + CARLA_ASSERT(parameterId < pData->param.count); - if (fDescriptor->get_parameter_info != nullptr && parameterId < kData->param.count) + if (fDescriptor->get_parameter_info != nullptr && parameterId < pData->param.count) { const Parameter* const param(fDescriptor->get_parameter_info(fHandle, parameterId)); @@ -523,10 +526,10 @@ public: { CARLA_ASSERT(fDescriptor != nullptr); CARLA_ASSERT(fHandle != nullptr); - CARLA_ASSERT(parameterId < kData->param.count); + CARLA_ASSERT(parameterId < pData->param.count); CARLA_ASSERT(scalePointId < parameterScalePointCount(parameterId)); - if (fDescriptor->get_parameter_info != nullptr && parameterId < kData->param.count) + if (fDescriptor->get_parameter_info != nullptr && parameterId < pData->param.count) { if (const Parameter* const param = fDescriptor->get_parameter_info(fHandle, parameterId)) { @@ -551,7 +554,7 @@ public: CARLA_ASSERT(fDescriptor != nullptr); CARLA_ASSERT(fHandle != nullptr); - if (kData->midiprog.count > 0 && (fHints & PLUGIN_IS_SYNTH) != 0) + if (pData->midiprog.count > 0 && (fHints & PLUGIN_IS_SYNTH) != 0) { char strBuf[STR_MAX+1]; std::snprintf(strBuf, STR_MAX, "%i:%i:%i:%i:%i:%i:%i:%i:%i:%i:%i:%i:%i:%i:%i:%i", @@ -598,8 +601,8 @@ public: void setCtrlChannel(const int8_t channel, const bool sendOsc, const bool sendCallback) override { - if (channel < MAX_MIDI_CHANNELS && kData->midiprog.count > 0) - kData->midiprog.current = fCurMidiProgs[channel]; + if (channel < MAX_MIDI_CHANNELS && pData->midiprog.count > 0) + pData->midiprog.current = fCurMidiProgs[channel]; CarlaPlugin::setCtrlChannel(channel, sendOsc, sendCallback); } @@ -611,11 +614,11 @@ public: { CARLA_ASSERT(fDescriptor != nullptr); CARLA_ASSERT(fHandle != nullptr); - 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)); - if (fDescriptor->set_parameter_value != nullptr && parameterId < kData->param.count) + if (fDescriptor->set_parameter_value != nullptr && parameterId < pData->param.count) { fDescriptor->set_parameter_value(fHandle, parameterId, fixedValue); @@ -671,10 +674,10 @@ public: bool ok; const uint index(midiProg.toUInt(&ok)); - if (ok && index < kData->midiprog.count) + if (ok && index < pData->midiprog.count) { - 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; fDescriptor->set_midi_program(fHandle, i, bank, program); @@ -683,10 +686,10 @@ public: fCurMidiProgs[i] = index; - if (kData->ctrlChannel == static_cast(i)) + if (pData->ctrlChannel == static_cast(i)) { - kData->midiprog.current = index; - kData->engine->callback(CALLBACK_MIDI_PROGRAM_CHANGED, fId, index, 0, 0.0f, nullptr); + pData->midiprog.current = index; + pData->engine->callback(CALLBACK_MIDI_PROGRAM_CHANGED, fId, index, 0, 0.0f, nullptr); } } @@ -715,21 +718,21 @@ public: { CARLA_ASSERT(fDescriptor != nullptr); CARLA_ASSERT(fHandle != nullptr); - CARLA_ASSERT(index >= -1 && index < static_cast(kData->midiprog.count)); + CARLA_ASSERT(index >= -1 && index < static_cast(pData->midiprog.count)); if (index < -1) index = -1; - else if (index > static_cast(kData->midiprog.count)) + else if (index > static_cast(pData->midiprog.count)) return; - if ((fHints & PLUGIN_IS_SYNTH) != 0 && (kData->ctrlChannel < 0 || kData->ctrlChannel >= MAX_MIDI_CHANNELS)) + if ((fHints & PLUGIN_IS_SYNTH) != 0 && (pData->ctrlChannel < 0 || pData->ctrlChannel >= MAX_MIDI_CHANNELS)) return; if (index >= 0) { - const uint8_t channel = (kData->ctrlChannel >= 0 || kData->ctrlChannel < MAX_MIDI_CHANNELS) ? kData->ctrlChannel : 0; - const uint32_t bank = kData->midiprog.data[index].bank; - const uint32_t program = kData->midiprog.data[index].program; + const uint8_t channel = (pData->ctrlChannel >= 0 || pData->ctrlChannel < MAX_MIDI_CHANNELS) ? pData->ctrlChannel : 0; + const uint32_t bank = pData->midiprog.data[index].bank; + const uint32_t program = pData->midiprog.data[index].program; const ScopedSingleProcessLocker spl(this, (sendGui || sendOsc || sendCallback)); @@ -763,7 +766,7 @@ public: if (fDescriptor->ui_set_custom_data != nullptr) { - for (NonRtList::Itenerator it = kData->custom.begin(); it.valid(); it.next()) + for (NonRtList::Itenerator it = pData->custom.begin(); it.valid(); it.next()) { const CustomData& cData(*it); @@ -772,19 +775,19 @@ public: } } - if (fDescriptor->ui_set_midi_program != nullptr && kData->midiprog.current >= 0 && kData->midiprog.count > 0) + if (fDescriptor->ui_set_midi_program != nullptr && pData->midiprog.current >= 0 && pData->midiprog.count > 0) { - const uint32_t index = kData->midiprog.current; - const uint8_t channel = (kData->ctrlChannel >= 0 || kData->ctrlChannel < MAX_MIDI_CHANNELS) ? kData->ctrlChannel : 0; - const uint32_t bank = kData->midiprog.data[index].bank; - const uint32_t program = kData->midiprog.data[index].program; + const uint32_t index = pData->midiprog.current; + const uint8_t channel = (pData->ctrlChannel >= 0 || pData->ctrlChannel < MAX_MIDI_CHANNELS) ? pData->ctrlChannel : 0; + const uint32_t bank = pData->midiprog.data[index].bank; + const uint32_t program = pData->midiprog.data[index].program; fDescriptor->ui_set_midi_program(fHandle, channel, bank, program); } if (fDescriptor->ui_set_parameter_value != nullptr) { - for (uint32_t i=0; i < kData->param.count; ++i) + for (uint32_t i=0; i < pData->param.count; ++i) fDescriptor->ui_set_parameter_value(fHandle, i, fDescriptor->get_parameter_value(fHandle, i)); } } @@ -804,28 +807,28 @@ public: void reload() override { carla_debug("NativePlugin::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((float)kData->engine->getSampleRate()); + const float sampleRate((float)pData->engine->getSampleRate()); uint32_t aIns, aOuts, mIns, mOuts, params, j; @@ -864,7 +867,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) @@ -873,7 +876,7 @@ public: if (aOuts > 0) { - kData->audioOut.createNew(aOuts); + pData->audioOut.createNew(aOuts); fAudioOutBuffers = new float*[aOuts]; needsCtrlIn = true; @@ -895,10 +898,10 @@ public: if (params > 0) { - kData->param.createNew(params); + pData->param.createNew(params); } - const uint portNameSize(kData->engine->maxPortNameSize()); + const uint portNameSize(pData->engine->maxPortNameSize()); CarlaString portName; // Audio Ins @@ -922,14 +925,14 @@ public: 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; if (forcedStereoIn) { portName += "_2"; - kData->audioIn.ports[1].port = (CarlaEngineAudioPort*)kData->client->addPort(kEnginePortTypeAudio, portName, true); - kData->audioIn.ports[1].rindex = j; + pData->audioIn.ports[1].port = (CarlaEngineAudioPort*)pData->client->addPort(kEnginePortTypeAudio, portName, true); + pData->audioIn.ports[1].rindex = j; break; } } @@ -955,14 +958,14 @@ public: 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 (forcedStereoOut) { portName += "_2"; - kData->audioOut.ports[1].port = (CarlaEngineAudioPort*)kData->client->addPort(kEnginePortTypeAudio, portName, false); - kData->audioOut.ports[1].rindex = j; + pData->audioOut.ports[1].port = (CarlaEngineAudioPort*)pData->client->addPort(kEnginePortTypeAudio, portName, false); + pData->audioOut.ports[1].rindex = j; break; } } @@ -984,7 +987,7 @@ public: portName += CarlaString(j+1); portName.truncate(portNameSize); - fMidiIn.ports[j] = (CarlaEngineEventPort*)kData->client->addPort(kEnginePortTypeEvent, portName, true); + fMidiIn.ports[j] = (CarlaEngineEventPort*)pData->client->addPort(kEnginePortTypeEvent, portName, true); fMidiIn.indexes[j] = j; } } @@ -1006,7 +1009,7 @@ public: portName += CarlaString(j+1); portName.truncate(portNameSize); - fMidiOut.ports[j] = (CarlaEngineEventPort*)kData->client->addPort(kEnginePortTypeEvent, portName, false); + fMidiOut.ports[j] = (CarlaEngineEventPort*)pData->client->addPort(kEnginePortTypeEvent, portName, false); fMidiOut.indexes[j] = j; } } @@ -1020,11 +1023,11 @@ public: if (paramInfo == nullptr) continue; - kData->param.data[j].index = j; - kData->param.data[j].rindex = j; - 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 = j; + 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; @@ -1058,7 +1061,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 (paramInfo->hints & ::PARAMETER_IS_BOOLEAN) @@ -1066,14 +1069,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 (paramInfo->hints & ::PARAMETER_IS_INTEGER) { 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 { @@ -1085,37 +1088,37 @@ public: if (paramInfo->hints & ::PARAMETER_IS_OUTPUT) { - kData->param.data[j].type = PARAMETER_OUTPUT; + pData->param.data[j].type = PARAMETER_OUTPUT; needsCtrlOut = true; } else { - kData->param.data[j].type = PARAMETER_INPUT; + pData->param.data[j].type = PARAMETER_INPUT; needsCtrlIn = true; } // extra parameter hints if (paramInfo->hints & ::PARAMETER_IS_ENABLED) - kData->param.data[j].hints |= PARAMETER_IS_ENABLED; + pData->param.data[j].hints |= PARAMETER_IS_ENABLED; if (paramInfo->hints & ::PARAMETER_IS_AUTOMABLE) - kData->param.data[j].hints |= PARAMETER_IS_AUTOMABLE; + pData->param.data[j].hints |= PARAMETER_IS_AUTOMABLE; if (paramInfo->hints & ::PARAMETER_IS_LOGARITHMIC) - kData->param.data[j].hints |= PARAMETER_IS_LOGARITHMIC; + pData->param.data[j].hints |= PARAMETER_IS_LOGARITHMIC; if (paramInfo->hints & ::PARAMETER_USES_SCALEPOINTS) - kData->param.data[j].hints |= PARAMETER_USES_SCALEPOINTS; + pData->param.data[j].hints |= PARAMETER_USES_SCALEPOINTS; if (paramInfo->hints & ::PARAMETER_USES_CUSTOM_TEXT) - kData->param.data[j].hints |= PARAMETER_USES_CUSTOM_TEXT; + pData->param.data[j].hints |= PARAMETER_USES_CUSTOM_TEXT; - 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; } if (needsCtrlIn) @@ -1131,7 +1134,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) @@ -1147,7 +1150,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) @@ -1180,15 +1183,15 @@ public: fHints |= PLUGIN_HAS_SINGLE_THREAD; // extra plugin hints - kData->extraHints = 0x0; + pData->extraHints = 0x0; if (aIns <= 2 && aOuts <= 2 && (aIns == aOuts || aIns == 0 || aOuts == 0) && mIns <= 1 && mOuts <= 1) - kData->extraHints |= PLUGIN_HINT_CAN_RUN_RACK; + 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("NativePlugin::reload() - end"); @@ -1197,11 +1200,11 @@ public: void reloadPrograms(const bool init) override { carla_debug("NativePlugin::reloadPrograms(%s)", bool2str(init)); - uint32_t i, oldCount = kData->midiprog.count; - const int32_t current = kData->midiprog.current; + uint32_t i, oldCount = pData->midiprog.count; + const int32_t current = pData->midiprog.current; // Delete old programs - kData->midiprog.clear(); + pData->midiprog.clear(); // Query new programs uint32_t count = 0; @@ -1210,7 +1213,7 @@ public: if (count > 0) { - kData->midiprog.createNew(count); + pData->midiprog.createNew(count); // Update data for (i=0; i < count; ++i) @@ -1219,20 +1222,20 @@ public: CARLA_ASSERT(mpDesc != nullptr); CARLA_ASSERT(mpDesc->name != nullptr); - kData->midiprog.data[i].bank = mpDesc->bank; - kData->midiprog.data[i].program = mpDesc->program; - kData->midiprog.data[i].name = carla_strdup(mpDesc->name); + pData->midiprog.data[i].bank = mpDesc->bank; + pData->midiprog.data[i].program = mpDesc->program; + pData->midiprog.data[i].name = carla_strdup(mpDesc->name); } } #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 @@ -1249,37 +1252,37 @@ public: if (count == oldCount+1) { // one midi program added, probably created by user - kData->midiprog.current = oldCount; + pData->midiprog.current = oldCount; programChanged = true; } else if (current < 0 && count > 0) { // programs exist now, but not before - kData->midiprog.current = 0; + pData->midiprog.current = 0; programChanged = true; } else if (current >= 0 && count == 0) { // programs existed before, but not anymore - kData->midiprog.current = -1; + pData->midiprog.current = -1; programChanged = true; } else if (current >= static_cast(count)) { // current midi program > count - kData->midiprog.current = 0; + pData->midiprog.current = 0; programChanged = true; } else { // no change - kData->midiprog.current = current; + pData->midiprog.current = current; } if (programChanged) - setMidiProgram(kData->midiprog.current, true, true, true); + setMidiProgram(pData->midiprog.current, true, true, true); - kData->engine->callback(CALLBACK_RELOAD_PROGRAMS, fId, 0, 0, 0.0f, nullptr); + pData->engine->callback(CALLBACK_RELOAD_PROGRAMS, fId, 0, 0, 0.0f, nullptr); } } @@ -1321,10 +1324,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; @@ -1336,7 +1339,7 @@ public: // -------------------------------------------------------------------------------------------------------- // Check if needs reset - if (kData->needsReset) + if (pData->needsReset) { if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF) { @@ -1355,11 +1358,11 @@ public: fMidiEventCount = MAX_MIDI_CHANNELS*2; } - 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) { - fMidiEvents[k].data[0] = MIDI_STATUS_NOTE_OFF + kData->ctrlChannel; + fMidiEvents[k].data[0] = MIDI_STATUS_NOTE_OFF + pData->ctrlChannel; fMidiEvents[k].data[1] = k; fMidiEvents[k].data[2] = 0; fMidiEvents[k].size = 3; @@ -1368,7 +1371,7 @@ public: fMidiEventCount = MAX_MIDI_NOTE; } - kData->needsReset = false; + pData->needsReset = false; } CARLA_PROCESS_CONTINUE_CHECK; @@ -1376,7 +1379,7 @@ public: // -------------------------------------------------------------------------------------------------------- // Set TimeInfo - const EngineTimeInfo& timeInfo(kData->engine->getTimeInfo()); + const EngineTimeInfo& timeInfo(pData->engine->getTimeInfo()); fTimeInfo.playing = timeInfo.playing; fTimeInfo.frame = timeInfo.frame; @@ -1405,16 +1408,16 @@ public: // -------------------------------------------------------------------------------------------------------- // Event Input and Processing - if (kData->event.portIn != nullptr) + if (pData->event.portIn != nullptr) { // ---------------------------------------------------------------------------------------------------- // MIDI Input (External) - if (kData->extNotes.mutex.tryLock()) + if (pData->extNotes.mutex.tryLock()) { - while (fMidiEventCount < MAX_MIDI_EVENTS*2 && ! kData->extNotes.data.isEmpty()) + while (fMidiEventCount < MAX_MIDI_EVENTS*2 && ! 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); @@ -1427,7 +1430,7 @@ public: fMidiEventCount += 1; } - kData->extNotes.mutex.unlock(); + pData->extNotes.mutex.unlock(); } // End of MIDI Input (External) @@ -1437,17 +1440,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; @@ -1463,8 +1466,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; @@ -1497,7 +1500,7 @@ public: { #ifndef BUILD_BRIDGE // Control backend stuff - if (event.channel == kData->ctrlChannel) + if (event.channel == pData->ctrlChannel) { float value; @@ -1545,28 +1548,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); } @@ -1593,7 +1596,7 @@ 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; @@ -1602,9 +1605,9 @@ public: { 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) { fDescriptor->set_midi_program(fHandle, event.channel, nextBankId, nextProgramId); @@ -1613,7 +1616,7 @@ public: fCurMidiProgs[event.channel] = k; - if (event.channel == kData->ctrlChannel) + if (event.channel == pData->ctrlChannel) postponeRtEvent(kPluginPostRtEventMidiProgramChange, k, 0, 0.0f); break; @@ -1642,7 +1645,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(); @@ -1710,7 +1713,7 @@ public: } } - kData->postRtEvents.trySplice(); + pData->postRtEvents.trySplice(); if (frames > timeOffset) processSingle(inBuffer, outBuffer, frames - timeOffset, timeOffset); @@ -1731,22 +1734,22 @@ public: // -------------------------------------------------------------------------------------------------------- // Control and MIDI Output - if (fMidiOut.count > 0 || kData->event.portOut != nullptr) + if (fMidiOut.count > 0 || pData->event.portOut != nullptr) { float value, curValue; - 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; curValue = fDescriptor->get_parameter_value(fHandle, k); - kData->param.ranges[k].fixValue(curValue); + pData->param.ranges[k].fixValue(curValue); - if (kData->param.data[k].midiCC > 0) + if (pData->param.data[k].midiCC > 0) { - value = kData->param.ranges[k].normalizeValue(curValue); - kData->event.portOut->writeControlEvent(0, kData->param.data[k].midiChannel, kEngineControlEventTypeParameter, kData->param.data[k].midiCC, value); + value = pData->param.ranges[k].normalizeValue(curValue); + pData->event.portOut->writeControlEvent(0, pData->param.data[k].midiChannel, kEngineControlEventTypeParameter, pData->param.data[k].midiCC, value); } } @@ -1759,8 +1762,8 @@ public: const uint8_t channel = MIDI_GET_CHANNEL_FROM_DATA(fMidiEvents[k].data); const uint8_t port = fMidiEvents[k].port; - if (kData->event.portOut != nullptr) - kData->event.portOut->writeMidiEvent(fMidiEvents[k].time, channel, port, fMidiEvents[k].data, fMidiEvents[k].size); + if (pData->event.portOut != nullptr) + pData->event.portOut->writeMidiEvent(fMidiEvents[k].time, channel, port, fMidiEvents[k].data, fMidiEvents[k].size); else if (port < fMidiOut.count) fMidiOut.ports[port]->writeMidiEvent(fMidiEvents[k].time, channel, port, fMidiEvents[k].data, fMidiEvents[k].size); } @@ -1775,13 +1778,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) @@ -1793,13 +1796,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; @@ -1811,9 +1814,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); // -------------------------------------------------------------------------------------------------------- @@ -1828,13 +1831,13 @@ public: else { fDescriptor->process(fHandle, - (kData->audioIn.count > 0) ? &fAudioInBuffers[0] : nullptr, - (kData->audioOut.count > 0) ? &fAudioOutBuffers[0] : nullptr, + (pData->audioIn.count > 0) ? &fAudioInBuffers[0] : nullptr, + (pData->audioOut.count > 0) ? &fAudioOutBuffers[0] : nullptr, frames, fMidiEventCount, fMidiEvents); fDescriptor->process(fHandle2, - (kData->audioIn.count > 0) ? &fAudioInBuffers[1] : nullptr, - (kData->audioOut.count > 0) ? &fAudioOutBuffers[1] : nullptr, + (pData->audioIn.count > 0) ? &fAudioInBuffers[1] : nullptr, + (pData->audioOut.count > 0) ? &fAudioOutBuffers[1] : nullptr, frames, fMidiEventCount, fMidiEvents); } @@ -1846,21 +1849,21 @@ 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) { for (k=0; k < frames; ++k) { - 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)); } } @@ -1871,12 +1874,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) { @@ -1898,13 +1901,13 @@ 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; } } } // 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]; @@ -1913,7 +1916,7 @@ public: // -------------------------------------------------------------------------------------------------------- - kData->singleMutex.unlock(); + pData->singleMutex.unlock(); return true; } @@ -1922,14 +1925,14 @@ public: CARLA_ASSERT_INT(newBufferSize > 0, newBufferSize); carla_debug("NativePlugin::bufferSizeChanged(%i)", 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]; @@ -1975,8 +1978,8 @@ public: void initBuffers() override { - fMidiIn.initBuffers(kData->engine); - fMidiOut.initBuffers(kData->engine); + fMidiIn.initBuffers(pData->engine); + fMidiOut.initBuffers(pData->engine); CarlaPlugin::initBuffers(); } @@ -1987,7 +1990,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) { @@ -2002,7 +2005,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) { @@ -2030,13 +2033,13 @@ public: { CARLA_ASSERT(fDescriptor != nullptr); CARLA_ASSERT(fHandle != nullptr); - CARLA_ASSERT(index < kData->param.count); + CARLA_ASSERT(index < pData->param.count); if (! fIsUiVisible) return; if (fDescriptor == nullptr || fHandle == nullptr) return; - if (index >= kData->param.count) + if (index >= pData->param.count) return; if (fDescriptor->ui_set_parameter_value != nullptr) @@ -2047,17 +2050,17 @@ public: { CARLA_ASSERT(fDescriptor != nullptr); CARLA_ASSERT(fHandle != nullptr); - CARLA_ASSERT(index < kData->midiprog.count); + CARLA_ASSERT(index < pData->midiprog.count); if (! fIsUiVisible) return; if (fDescriptor == nullptr || fHandle == nullptr) return; - if (index >= kData->midiprog.count) + if (index >= pData->midiprog.count) return; if (fDescriptor->ui_set_midi_program != nullptr) // TODO - fDescriptor->ui_set_midi_program(fHandle, 0, kData->midiprog.data[index].bank, kData->midiprog.data[index].program); + fDescriptor->ui_set_midi_program(fHandle, 0, pData->midiprog.data[index].bank, pData->midiprog.data[index].program); } void uiNoteOn(const uint8_t channel, const uint8_t note, const uint8_t velo) override @@ -2106,17 +2109,17 @@ public: protected: uint32_t handleGetBufferSize() { - return kData->engine->getBufferSize(); + return pData->engine->getBufferSize(); } double handleGetSampleRate() { - return kData->engine->getSampleRate(); + return pData->engine->getSampleRate(); } bool handleIsOffline() { - return kData->engine->isOffline(); + return pData->engine->isOffline(); } const ::TimeInfo* handleGetTimeInfo() @@ -2130,7 +2133,7 @@ protected: { CARLA_ASSERT(fEnabled); CARLA_ASSERT(fIsProcessing); - CARLA_ASSERT(fMidiOut.count > 0 || kData->event.portOut != nullptr); + CARLA_ASSERT(fMidiOut.count > 0 || pData->event.portOut != nullptr); CARLA_ASSERT(event != nullptr); CARLA_ASSERT(event->data[0] != 0); @@ -2176,7 +2179,7 @@ protected: void handleUiClosed() { - kData->engine->callback(CALLBACK_SHOW_GUI, fId, 0, 0, 0.0f, nullptr); + pData->engine->callback(CALLBACK_SHOW_GUI, fId, 0, 0, 0.0f, nullptr); fIsUiVisible = false; } @@ -2248,7 +2251,7 @@ protected: case ::HOST_OPCODE_RELOAD_ALL: break; case HOST_OPCODE_UI_UNAVAILABLE: - kData->engine->callback(CALLBACK_SHOW_GUI, fId, -1, 0, 0.0f, nullptr); + pData->engine->callback(CALLBACK_SHOW_GUI, fId, -1, 0, 0.0f, nullptr); break; } @@ -2287,27 +2290,27 @@ public: bool init(const char* const name, const char* const label) { - CARLA_ASSERT(kData->engine != nullptr); - CARLA_ASSERT(kData->client == nullptr); + CARLA_ASSERT(pData->engine != nullptr); + CARLA_ASSERT(pData->client == 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 (label == nullptr) { - kData->engine->setLastError("null label"); + pData->engine->setLastError("null label"); return false; } @@ -2330,7 +2333,7 @@ public: if (fDescriptor == nullptr) { - kData->engine->setLastError("Invalid internal plugin"); + pData->engine->setLastError("Invalid internal plugin"); return false; } @@ -2361,11 +2364,11 @@ public: // get info if (name != nullptr) - fName = kData->engine->getUniquePluginName(name); + fName = pData->engine->getUniquePluginName(name); else if (fDescriptor->name != nullptr) - fName = kData->engine->getUniquePluginName(fDescriptor->name); + fName = pData->engine->getUniquePluginName(fDescriptor->name); else - fName = kData->engine->getUniquePluginName(label); + fName = pData->engine->getUniquePluginName(label); { CARLA_ASSERT(fHost.ui_name == nullptr); @@ -2380,11 +2383,11 @@ public: // --------------------------------------------------------------- // 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; } @@ -2395,7 +2398,7 @@ public: if (fHandle == nullptr) { - kData->engine->setLastError("Plugin failed to initialize"); + pData->engine->setLastError("Plugin failed to initialize"); return false; } @@ -2414,7 +2417,7 @@ public: if (midiInCount() > 0 || (fDescriptor->hints & ::PLUGIN_USES_STATIC_BUFFERS) != 0) fOptions |= PLUGIN_OPTION_FIXED_BUFFER; - if (kData->engine->getOptions().forceStereo) + if (pData->engine->getOptions().forceStereo) fOptions |= PLUGIN_OPTION_FORCE_STEREO; if (fDescriptor->supports & ::PLUGIN_SUPPORTS_CHANNEL_PRESSURE) @@ -2427,9 +2430,9 @@ public: fOptions |= PLUGIN_OPTION_SEND_ALL_SOUND_OFF; // load settings - kData->idStr = "Native/"; - kData->idStr += label; - fOptions = kData->loadSettings(fOptions, availableOptions()); + pData->idStr = "Native/"; + pData->idStr += label; + fOptions = pData->loadSettings(fOptions, availableOptions()); // ignore settings, we need this anyway if (midiInCount() > 0 || (fDescriptor->hints & ::PLUGIN_USES_STATIC_BUFFERS) != 0) diff --git a/source/backend/plugin/Vst3Plugin.cpp b/source/backend/plugin/Vst3Plugin.cpp index 5d16b0ed6..f6efa08a1 100644 --- a/source/backend/plugin/Vst3Plugin.cpp +++ b/source/backend/plugin/Vst3Plugin.cpp @@ -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(); } // ------------------------------------------------------------------- diff --git a/source/backend/plugin/VstPlugin.cpp b/source/backend/plugin/VstPlugin.cpp index 8cc0421c9..65b750e90 100644 --- a/source/backend/plugin/VstPlugin.cpp +++ b/source/backend/plugin/VstPlugin.cpp @@ -64,7 +64,7 @@ public: for (unsigned short i=0; i < MAX_MIDI_EVENTS*2; ++i) fEvents.data[i] = (VstEvent*)&fMidiEvents[i]; - kData->osc.thread.setMode(CarlaPluginThread::PLUGIN_THREAD_VST_GUI); + pData->osc.thread.setMode(CarlaPluginThread::PLUGIN_THREAD_VST_GUI); // make plugin valid srand(id); @@ -83,26 +83,26 @@ public: if (fGui.isOsc) { // 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("VST OSC-GUI thread still running, forcing termination now"); - kData->osc.thread.terminate(); + pData->osc.thread.terminate(); } } } - 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(); CARLA_ASSERT(! fIsProcessing); - if (kData->active) + if (pData->active) { deactivate(); - kData->active = false; + pData->active = false; } if (fEffect != nullptr) @@ -218,7 +218,7 @@ public: float getParameterValue(const uint32_t parameterId) override { CARLA_ASSERT(fEffect != nullptr); - CARLA_ASSERT(parameterId < kData->param.count); + CARLA_ASSERT(parameterId < pData->param.count); return fEffect->getParameter(fEffect, parameterId); } @@ -258,7 +258,7 @@ public: void getParameterName(const uint32_t parameterId, char* const strBuf) override { CARLA_ASSERT(fEffect != nullptr); - CARLA_ASSERT(parameterId < kData->param.count); + CARLA_ASSERT(parameterId < pData->param.count); strBuf[0] = '\0'; dispatcher(effGetParamName, parameterId, 0, strBuf, 0.0f); @@ -267,7 +267,7 @@ public: void getParameterText(const uint32_t parameterId, char* const strBuf) override { CARLA_ASSERT(fEffect != nullptr); - CARLA_ASSERT(parameterId < kData->param.count); + CARLA_ASSERT(parameterId < pData->param.count); strBuf[0] = '\0'; dispatcher(effGetParamDisplay, parameterId, 0, strBuf, 0.0f); @@ -279,7 +279,7 @@ public: void getParameterUnit(const uint32_t parameterId, char* const strBuf) override { CARLA_ASSERT(fEffect != nullptr); - CARLA_ASSERT(parameterId < kData->param.count); + CARLA_ASSERT(parameterId < pData->param.count); strBuf[0] = '\0'; dispatcher(effGetParamLabel, parameterId, 0, strBuf, 0.0f); @@ -297,8 +297,8 @@ public: { CarlaPlugin::setName(newName); - if (kData->gui != nullptr) - kData->gui->setWindowTitle(QString("%1 (GUI)").arg((const char*)fName)); + if (pData->gui != nullptr) + pData->gui->setWindowTitle(QString("%1 (GUI)").arg((const char*)fName)); } // ------------------------------------------------------------------- @@ -307,9 +307,9 @@ public: void setParameterValue(const uint32_t parameterId, const float value, const bool sendGui, const bool sendOsc, const bool sendCallback) override { CARLA_ASSERT(fEffect != nullptr); - 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)); fEffect->setParameter(fEffect, parameterId, fixedValue); @@ -350,11 +350,11 @@ public: void setProgram(int32_t index, const bool sendGui, const bool sendOsc, const bool sendCallback) override { CARLA_ASSERT(fEffect != nullptr); - CARLA_ASSERT(index >= -1 && index < static_cast(kData->prog.count)); + CARLA_ASSERT(index >= -1 && index < static_cast(pData->prog.count)); if (index < -1) index = -1; - else if (index > static_cast(kData->prog.count)) + else if (index > static_cast(pData->prog.count)) return; if (index >= 0) @@ -381,41 +381,41 @@ public: { if (yesNo) { - kData->osc.thread.start(); + pData->osc.thread.start(); } else { - if (kData->osc.data.target != nullptr) + if (pData->osc.data.target != nullptr) { - osc_send_hide(&kData->osc.data); - osc_send_quit(&kData->osc.data); - kData->osc.data.free(); + osc_send_hide(&pData->osc.data); + osc_send_quit(&pData->osc.data); + pData->osc.data.free(); } - if (kData->osc.thread.isRunning() && ! kData->osc.thread.wait(kData->engine->getOptions().oscUiTimeout)) - kData->osc.thread.terminate(); + if (pData->osc.thread.isRunning() && ! pData->osc.thread.wait(pData->engine->getOptions().oscUiTimeout)) + pData->osc.thread.terminate(); } } else { if (yesNo) { - CARLA_ASSERT(kData->gui == nullptr); + CARLA_ASSERT(pData->gui == nullptr); - if (kData->gui == nullptr) + if (pData->gui == nullptr) { CarlaPluginGui::Options guiOptions; guiOptions.parented = true; guiOptions.resizable = false; - kData->gui = new CarlaPluginGui(kData->engine, this, guiOptions, kData->guiGeometry); + pData->gui = new CarlaPluginGui(pData->engine, this, guiOptions, pData->guiGeometry); } int32_t value = 0; #ifdef Q_WS_X11 //value = (intptr_t)QX11Info::display(); #endif - void* const ptr = kData->gui->getContainerWinId(); + void* const ptr = pData->gui->getContainerWinId(); if (dispatcher(effEditOpen, 0, value, ptr, 0.0f) != 0) { @@ -431,44 +431,44 @@ public: CARLA_SAFE_ASSERT_INT2(width > 1 && height > 1, width, height); if (width > 1 && height > 1) - kData->gui->setSize(width, height); + pData->gui->setSize(width, height); else if (fGui.lastWidth > 1 && fGui.lastHeight > 1) - kData->gui->setSize(fGui.lastWidth, fGui.lastHeight); + pData->gui->setSize(fGui.lastWidth, fGui.lastHeight); } - kData->gui->setWindowTitle(QString("%1 (GUI)").arg((const char*)fName)); - kData->gui->show(); + pData->gui->setWindowTitle(QString("%1 (GUI)").arg((const char*)fName)); + pData->gui->show(); } else { - if (kData->gui != nullptr) + if (pData->gui != nullptr) { - kData->guiGeometry = kData->gui->saveGeometry(); - kData->gui->close(); - delete kData->gui; - kData->gui = nullptr; + pData->guiGeometry = pData->gui->saveGeometry(); + pData->gui->close(); + delete pData->gui; + pData->gui = nullptr; } - kData->engine->callback(CALLBACK_ERROR, fId, 0, 0, 0.0f, "Plugin refused to open its own UI"); - kData->engine->callback(CALLBACK_SHOW_GUI, fId, -1, 0, 0.0f, nullptr); + pData->engine->callback(CALLBACK_ERROR, fId, 0, 0, 0.0f, "Plugin refused to open its own UI"); + pData->engine->callback(CALLBACK_SHOW_GUI, fId, -1, 0, 0.0f, nullptr); return; } } else { - CARLA_ASSERT(kData->gui != nullptr); + CARLA_ASSERT(pData->gui != nullptr); dispatcher(effEditClose, 0, 0, nullptr, 0.0f); - if (kData->gui != nullptr) + if (pData->gui != nullptr) { - fGui.lastWidth = kData->gui->width(); - fGui.lastHeight = kData->gui->height(); + fGui.lastWidth = pData->gui->width(); + fGui.lastHeight = pData->gui->height(); - kData->guiGeometry = kData->gui->saveGeometry(); - kData->gui->close(); - delete kData->gui; - kData->gui = nullptr; + pData->guiGeometry = pData->gui->saveGeometry(); + pData->gui->close(); + delete pData->gui; + pData->gui = nullptr; } } } @@ -490,7 +490,7 @@ public: if (fGui.isVisible && ! fGui.isOsc) { dispatcher(effEditIdle, 0, 0, nullptr, 0.0f); - //kData->gui->idle(); + //pData->gui->idle(); } } @@ -503,20 +503,20 @@ public: void reload() override { carla_debug("VstPlugin::reload() - start"); - CARLA_ASSERT(kData->engine != nullptr); + CARLA_ASSERT(pData->engine != nullptr); CARLA_ASSERT(fEffect != nullptr); - if (kData->engine == nullptr) + if (pData->engine == nullptr) return; if (fEffect == 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(); @@ -548,22 +548,22 @@ public: if (aIns > 0) { - kData->audioIn.createNew(aIns); + pData->audioIn.createNew(aIns); } if (aOuts > 0) { - kData->audioOut.createNew(aOuts); + pData->audioOut.createNew(aOuts); needsCtrlIn = true; } if (params > 0) { - kData->param.createNew(params); + pData->param.createNew(params); needsCtrlIn = true; } - const uint portNameSize(kData->engine->maxPortNameSize()); + const uint portNameSize(pData->engine->maxPortNameSize()); CarlaString portName; // Audio Ins @@ -587,8 +587,8 @@ public: 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 @@ -612,18 +612,18 @@ public: 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; } for (j=0; j < params; ++j) { - kData->param.data[j].type = PARAMETER_INPUT; - kData->param.data[j].index = j; - kData->param.data[j].rindex = j; - kData->param.data[j].hints = 0x0; - kData->param.data[j].midiChannel = 0; - kData->param.data[j].midiCC = -1; + pData->param.data[j].type = PARAMETER_INPUT; + pData->param.data[j].index = j; + pData->param.data[j].rindex = j; + 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; @@ -699,14 +699,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 (prop.flags & kVstParameterUsesIntStep) { step = float(prop.stepInteger); stepSmall = float(prop.stepInteger)/10; stepLarge = float(prop.largeStepInteger); - kData->param.data[j].hints |= PARAMETER_IS_INTEGER; + pData->param.data[j].hints |= PARAMETER_IS_INTEGER; } else if (prop.flags & kVstParameterUsesFloatStep) { @@ -723,7 +723,7 @@ public: } if (prop.flags & kVstParameterCanRamp) - kData->param.data[j].hints |= PARAMETER_IS_LOGARITHMIC; + pData->param.data[j].hints |= PARAMETER_IS_LOGARITHMIC; } else { @@ -734,13 +734,13 @@ public: stepLarge = 0.1f; } - kData->param.data[j].hints |= PARAMETER_IS_ENABLED; + pData->param.data[j].hints |= PARAMETER_IS_ENABLED; #ifndef BUILD_BRIDGE - kData->param.data[j].hints |= PARAMETER_USES_CUSTOM_TEXT; + pData->param.data[j].hints |= PARAMETER_USES_CUSTOM_TEXT; #endif if ((fHints & PLUGIN_USES_OLD_VSTSDK) != 0 || dispatcher(effCanBeAutomated, j, 0, nullptr, 0.0f) == 1) - kData->param.data[j].hints |= PARAMETER_IS_AUTOMABLE; + pData->param.data[j].hints |= PARAMETER_IS_AUTOMABLE; // no such thing as VST default parameters def = fEffect->getParameter(fEffect, j); @@ -750,12 +750,12 @@ public: else if (def > max) def = max; - 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; } if (needsCtrlIn) @@ -771,7 +771,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) @@ -787,7 +787,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); } // plugin hints @@ -828,16 +828,16 @@ public: fHints |= PLUGIN_CAN_BALANCE; // extra plugin hints - kData->extraHints = 0x0; + pData->extraHints = 0x0; if (mIns > 0) - kData->extraHints |= PLUGIN_HINT_HAS_MIDI_IN; + pData->extraHints |= PLUGIN_HINT_HAS_MIDI_IN; if (mOuts > 0) - kData->extraHints |= PLUGIN_HINT_HAS_MIDI_OUT; + pData->extraHints |= PLUGIN_HINT_HAS_MIDI_OUT; 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; // dummy pre-start to get latency and wantEvents() on old plugins { @@ -851,13 +851,13 @@ public: #ifdef VESTIGE_HEADER char* const empty3Ptr = &fEffect->empty3[0]; int32_t* initialDelayPtr = (int32_t*)empty3Ptr; - kData->latency = *initialDelayPtr; + pData->latency = *initialDelayPtr; #else - kData->latency = fEffect->initialDelay; + pData->latency = fEffect->initialDelay; #endif - kData->client->setLatency(kData->latency); - kData->recreateLatencyBuffers(); + pData->client->setLatency(pData->latency); + pData->recreateLatencyBuffers(); } // special plugin fixes @@ -873,10 +873,10 @@ public: } } - bufferSizeChanged(kData->engine->getBufferSize()); + bufferSizeChanged(pData->engine->getBufferSize()); reloadPrograms(true); - if (kData->active) + if (pData->active) activate(); carla_debug("VstPlugin::reload() - end"); @@ -885,18 +885,18 @@ public: void reloadPrograms(const bool init) override { carla_debug("VstPlugin::reloadPrograms(%s)", bool2str(init)); - uint32_t i, oldCount = kData->prog.count; - const int32_t current = kData->prog.current; + uint32_t i, oldCount = pData->prog.count; + const int32_t current = pData->prog.current; // Delete old programs - kData->prog.clear(); + pData->prog.clear(); // Query new programs uint32_t count = static_cast(fEffect->numPrograms); if (count > 0) { - kData->prog.createNew(count); + pData->prog.createNew(count); // Update names for (i=0; i < count; ++i) @@ -908,18 +908,18 @@ public: dispatcher(effSetProgram, 0, i, nullptr, 0.0f); dispatcher(effGetProgramName, 0, 0, strBuf, 0.0f); } - kData->prog.names[i] = strdup(strBuf); + pData->prog.names[i] = strdup(strBuf); } } #ifndef BUILD_BRIDGE // Update OSC Names - if (kData->engine->isOscControlRegistered()) + if (pData->engine->isOscControlRegistered()) { - kData->engine->osc_send_control_set_program_count(fId, count); + pData->engine->osc_send_control_set_program_count(fId, count); for (i=0; i < count; ++i) - kData->engine->osc_send_control_set_program_name(fId, i, kData->prog.names[i]); + pData->engine->osc_send_control_set_program_name(fId, i, pData->prog.names[i]); } #endif @@ -936,45 +936,45 @@ public: if (count == oldCount+1) { // one program added, probably created by user - kData->prog.current = oldCount; + pData->prog.current = oldCount; programChanged = true; } else if (current < 0 && count > 0) { // programs exist now, but not before - kData->prog.current = 0; + pData->prog.current = 0; programChanged = true; } else if (current >= 0 && count == 0) { // programs existed before, but not anymore - kData->prog.current = -1; + pData->prog.current = -1; programChanged = true; } else if (current >= static_cast(count)) { // current program > count - kData->prog.current = 0; + pData->prog.current = 0; programChanged = true; } else { // no change - kData->prog.current = current; + pData->prog.current = current; } if (programChanged) { - setProgram(kData->prog.current, true, true, true); + setProgram(pData->prog.current, true, true, true); } else { // Program was changed during update, re-set it - if (kData->prog.current >= 0) - dispatcher(effSetProgram, 0, kData->prog.current, nullptr, 0.0f); + if (pData->prog.current >= 0) + dispatcher(effSetProgram, 0, pData->prog.current, nullptr, 0.0f); } - kData->engine->callback(CALLBACK_RELOAD_PROGRAMS, fId, 0, 0, 0.0f, nullptr); + pData->engine->callback(CALLBACK_RELOAD_PROGRAMS, fId, 0, 0, 0.0f, nullptr); } } @@ -1000,10 +1000,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; @@ -1015,7 +1015,7 @@ public: // -------------------------------------------------------------------------------------------------------- // Check if needs reset - if (kData->needsReset) + if (pData->needsReset) { if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF) { @@ -1034,26 +1034,26 @@ public: fMidiEventCount = MAX_MIDI_CHANNELS*2; } - 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) { fMidiEvents[k].type = kVstMidiType; fMidiEvents[k].byteSize = sizeof(VstMidiEvent); - fMidiEvents[k].midiData[0] = MIDI_STATUS_NOTE_OFF + kData->ctrlChannel; + fMidiEvents[k].midiData[0] = MIDI_STATUS_NOTE_OFF + pData->ctrlChannel; fMidiEvents[k].midiData[1] = k; } fMidiEventCount = MAX_MIDI_NOTE; } - 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; } CARLA_PROCESS_CONTINUE_CHECK; @@ -1061,7 +1061,7 @@ public: // -------------------------------------------------------------------------------------------------------- // Set TimeInfo - const EngineTimeInfo& timeInfo(kData->engine->getTimeInfo()); + const EngineTimeInfo& timeInfo(pData->engine->getTimeInfo()); fTimeInfo.flags = kVstTransportChanged; @@ -1069,7 +1069,7 @@ public: fTimeInfo.flags |= kVstTransportPlaying; fTimeInfo.samplePos = timeInfo.frame; - fTimeInfo.sampleRate = kData->engine->getSampleRate(); + fTimeInfo.sampleRate = pData->engine->getSampleRate(); if (timeInfo.usecs != 0) { @@ -1121,16 +1121,16 @@ public: // -------------------------------------------------------------------------------------------------------- // Event Input and Processing - if (kData->event.portIn != nullptr) + if (pData->event.portIn != nullptr) { // ---------------------------------------------------------------------------------------------------- // MIDI Input (External) - if (kData->extNotes.mutex.tryLock()) + if (pData->extNotes.mutex.tryLock()) { - while (fMidiEventCount < MAX_MIDI_EVENTS*2 && ! kData->extNotes.data.isEmpty()) + while (fMidiEventCount < MAX_MIDI_EVENTS*2 && ! 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); @@ -1144,7 +1144,7 @@ public: fMidiEventCount += 1; } - kData->extNotes.mutex.unlock(); + pData->extNotes.mutex.unlock(); } // End of MIDI Input (External) @@ -1154,13 +1154,13 @@ 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; 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; @@ -1205,7 +1205,7 @@ public: { #ifndef BUILD_BRIDGE // Control backend stuff - if (event.channel == kData->ctrlChannel) + if (event.channel == pData->ctrlChannel) { float value; @@ -1253,28 +1253,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); } @@ -1306,9 +1306,9 @@ public: 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) { - if (ctrlEvent.param < kData->prog.count) + if (ctrlEvent.param < pData->prog.count) { setProgram(ctrlEvent.param, false, false, false); postponeRtEvent(kPluginPostRtEventProgramChange, ctrlEvent.param, 0, 0.0f); @@ -1338,7 +1338,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(); @@ -1407,7 +1407,7 @@ public: } } - kData->postRtEvents.trySplice(); + pData->postRtEvents.trySplice(); if (frames > timeOffset) processSingle(inBuffer, outBuffer, frames - timeOffset, timeOffset); @@ -1428,7 +1428,7 @@ public: // -------------------------------------------------------------------------------------------------------- // MIDI Output - if (kData->event.portOut != nullptr) + if (pData->event.portOut != nullptr) { // reverse lookup MIDI events for (k = (MAX_MIDI_EVENTS*2)-1; k >= fMidiEventCount; --k) @@ -1443,7 +1443,7 @@ public: midiData[1] = fMidiEvents[k].midiData[1]; midiData[2] = fMidiEvents[k].midiData[2]; - kData->event.portOut->writeMidiEvent(fMidiEvents[k].deltaFrames, channel, 0, midiData, 3); + pData->event.portOut->writeMidiEvent(fMidiEvents[k].deltaFrames, channel, 0, midiData, 3); } } // End of Control and MIDI Output @@ -1456,13 +1456,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) @@ -1474,13 +1474,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; @@ -1492,12 +1492,12 @@ public: // -------------------------------------------------------------------------------------------------------- // Set audio buffers - float* vstInBuffer[kData->audioIn.count]; - float* vstOutBuffer[kData->audioOut.count]; + float* vstInBuffer[pData->audioIn.count]; + float* vstOutBuffer[pData->audioOut.count]; - for (i=0; i < kData->audioIn.count; ++i) + for (i=0; i < pData->audioIn.count; ++i) vstInBuffer[i] = inBuffer[i]+timeOffset; - for (i=0; i < kData->audioOut.count; ++i) + for (i=0; i < pData->audioOut.count; ++i) vstOutBuffer[i] = outBuffer[i]+timeOffset; // -------------------------------------------------------------------------------------------------------- @@ -1518,19 +1518,19 @@ public: if (fHints & PLUGIN_CAN_PROCESS_REPLACING) { fEffect->processReplacing(fEffect, - (kData->audioIn.count > 0) ? vstInBuffer : nullptr, - (kData->audioOut.count > 0) ? vstOutBuffer : nullptr, + (pData->audioIn.count > 0) ? vstInBuffer : nullptr, + (pData->audioOut.count > 0) ? vstOutBuffer : nullptr, frames); } else { - for (i=0; i < kData->audioOut.count; ++i) + for (i=0; i < pData->audioOut.count; ++i) carla_zeroFloat(vstOutBuffer[i], frames); #if ! VST_FORCE_DEPRECATED fEffect->process(fEffect, - (kData->audioIn.count > 0) ? vstInBuffer : nullptr, - (kData->audioOut.count > 0) ? vstOutBuffer : nullptr, + (pData->audioIn.count > 0) ? vstInBuffer : nullptr, + (pData->audioOut.count > 0) ? vstOutBuffer : nullptr, frames); #endif } @@ -1543,22 +1543,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+timeOffset]; - outBuffer[i][k+timeOffset] = (outBuffer[i][k+timeOffset] * kData->postProc.dryWet) + (bufValue * (1.0f - kData->postProc.dryWet)); + bufValue = inBuffer[(pData->audioIn.count == 1) ? 0 : i][k+timeOffset]; + outBuffer[i][k+timeOffset] = (outBuffer[i][k+timeOffset] * pData->postProc.dryWet) + (bufValue * (1.0f - pData->postProc.dryWet)); } } @@ -1569,12 +1569,12 @@ public: if (isPair) { - CARLA_ASSERT(i+1 < kData->audioOut.count); + CARLA_ASSERT(i+1 < pData->audioOut.count); carla_copyFloat(oldBufLeft, outBuffer[i]+timeOffset, 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) { @@ -1597,7 +1597,7 @@ public: if (doVolume) { for (k=0; k < frames; ++k) - outBuffer[i][k+timeOffset] *= kData->postProc.volume; + outBuffer[i][k+timeOffset] *= pData->postProc.volume; } } @@ -1606,7 +1606,7 @@ public: // -------------------------------------------------------------------------------------------------------- - kData->singleMutex.unlock(); + pData->singleMutex.unlock(); return true; } @@ -1615,15 +1615,15 @@ public: CARLA_ASSERT_INT(newBufferSize > 0, newBufferSize); carla_debug("VstPlugin::bufferSizeChanged(%i)", newBufferSize); - if (kData->active) + if (pData->active) deactivate(); #if ! VST_FORCE_DEPRECATED - dispatcher(effSetBlockSizeAndSampleRate, 0, newBufferSize, nullptr, kData->engine->getSampleRate()); + dispatcher(effSetBlockSizeAndSampleRate, 0, newBufferSize, nullptr, pData->engine->getSampleRate()); #endif dispatcher(effSetBlockSize, 0, newBufferSize, nullptr, 0.0f); - if (kData->active) + if (pData->active) activate(); } @@ -1632,15 +1632,15 @@ public: CARLA_ASSERT_INT(newSampleRate > 0.0, newSampleRate); carla_debug("VstPlugin::sampleRateChanged(%g)", newSampleRate); - if (kData->active) + if (pData->active) deactivate(); #if ! VST_FORCE_DEPRECATED - dispatcher(effSetBlockSizeAndSampleRate, 0, kData->engine->getBufferSize(), nullptr, newSampleRate); + dispatcher(effSetBlockSizeAndSampleRate, 0, pData->engine->getBufferSize(), nullptr, newSampleRate); #endif dispatcher(effSetSampleRate, 0, 0, nullptr, newSampleRate); - if (kData->active) + if (pData->active) activate(); } @@ -1654,30 +1654,30 @@ public: void uiParameterChange(const uint32_t index, const float value) override { - CARLA_ASSERT(index < kData->param.count); + CARLA_ASSERT(index < pData->param.count); - if (index >= kData->param.count) + if (index >= pData->param.count) return; if (! fGui.isOsc) return; - if (kData->osc.data.target == nullptr) + if (pData->osc.data.target == nullptr) return; - osc_send_control(&kData->osc.data, kData->param.data[index].rindex, value); + osc_send_control(&pData->osc.data, pData->param.data[index].rindex, value); } void uiProgramChange(const uint32_t index) override { - CARLA_ASSERT(index < kData->prog.count); + CARLA_ASSERT(index < pData->prog.count); - if (index >= kData->prog.count) + if (index >= pData->prog.count) return; if (! fGui.isOsc) return; - if (kData->osc.data.target == nullptr) + if (pData->osc.data.target == nullptr) return; - osc_send_program(&kData->osc.data, index); + osc_send_program(&pData->osc.data, index); } void uiNoteOn(const uint8_t channel, const uint8_t note, const uint8_t velo) override @@ -1694,7 +1694,7 @@ public: return; if (! fGui.isOsc) return; - if (kData->osc.data.target == nullptr) + if (pData->osc.data.target == nullptr) return; uint8_t midiData[4] = { 0 }; @@ -1702,7 +1702,7 @@ public: midiData[2] = note; midiData[3] = velo; - osc_send_midi(&kData->osc.data, midiData); + osc_send_midi(&pData->osc.data, midiData); } void uiNoteOff(const uint8_t channel, const uint8_t note) override @@ -1716,14 +1716,14 @@ public: return; if (! fGui.isOsc) return; - if (kData->osc.data.target == nullptr) + if (pData->osc.data.target == nullptr) return; uint8_t midiData[4] = { 0 }; midiData[1] = MIDI_STATUS_NOTE_OFF + channel; midiData[2] = note; - osc_send_midi(&kData->osc.data, midiData); + osc_send_midi(&pData->osc.data, midiData); } // ------------------------------------------------------------------- @@ -1732,7 +1732,7 @@ protected: void guiClosedCallback() override { showGui(false); - kData->engine->callback(CALLBACK_SHOW_GUI, fId, 0, 0, 0.0f, nullptr); + pData->engine->callback(CALLBACK_SHOW_GUI, fId, 0, 0, 0.0f, nullptr); } intptr_t dispatcher(int32_t opcode, int32_t index, intptr_t value, void* ptr, float opt) @@ -1790,9 +1790,9 @@ protected: break; // plugins should never do this: - CARLA_SAFE_ASSERT_INT(index < static_cast(kData->param.count), index); + CARLA_SAFE_ASSERT_INT(index < static_cast(pData->param.count), index); - if (index < 0 || index >= static_cast(kData->param.count)) + if (index < 0 || index >= static_cast(pData->param.count)) break; if (fGui.isVisible && ! fIsProcessing) @@ -1803,9 +1803,9 @@ protected: else if (fIsProcessing) { // Called from engine - const float fixedValue(kData->param.fixValue(index, opt)); + const float fixedValue(pData->param.fixValue(index, opt)); - if (kData->engine->isOffline()) + if (pData->engine->isOffline()) { CarlaPlugin::setParameterValue(index, fixedValue, true, true, true); } @@ -1854,14 +1854,14 @@ protected: case audioMasterProcessEvents: CARLA_ASSERT(fEnabled); CARLA_ASSERT(fIsProcessing); - CARLA_ASSERT(kData->event.portOut != nullptr); + CARLA_ASSERT(pData->event.portOut != nullptr); CARLA_ASSERT(ptr != nullptr); if (! fEnabled) return 0; if (! fIsProcessing) return 0; - if (kData->event.portOut == nullptr) + if (pData->event.portOut == nullptr) return 0; if (ptr == nullptr) return 0; @@ -1916,7 +1916,7 @@ protected: case audioMasterGetNumAutomatableParameters: // Deprecated in VST SDK 2.4 - ret = carla_min(0, fEffect->numParams, kData->engine->getOptions().maxParameters); + ret = carla_min(0, fEffect->numParams, pData->engine->getOptions().maxParameters); break; case audioMasterGetParameterQuantization: @@ -1974,21 +1974,21 @@ protected: break; case audioMasterSizeWindow: - if (kData->gui != nullptr) + if (pData->gui != nullptr) { CARLA_SAFE_ASSERT(fGui.isVisible); if (fGui.isVisible) - kData->gui->setSize(index, value); + pData->gui->setSize(index, value); ret = 1; } break; case audioMasterGetSampleRate: - ret = kData->engine->getSampleRate(); + ret = pData->engine->getSampleRate(); break; case audioMasterGetBlockSize: - ret = kData->engine->getBufferSize(); + ret = pData->engine->getBufferSize(); break; case audioMasterGetInputLatency: @@ -2017,7 +2017,7 @@ protected: #endif case audioMasterGetCurrentProcessLevel: - if (kData->engine->isOffline()) + if (pData->engine->isOffline()) ret = kVstProcessLevelOffline; else if (fIsProcessing) ret = kVstProcessLevelRealtime; @@ -2026,7 +2026,7 @@ protected: break; case audioMasterGetAutomationState: - ret = kData->active ? kVstAutomationReadWrite : kVstAutomationOff; + ret = pData->active ? kVstAutomationReadWrite : kVstAutomationOff; break; case audioMasterOfflineStart: @@ -2076,29 +2076,29 @@ protected: dispatcher(effEditIdle, 0, 0, nullptr, 0.0f); // Update current program - if (kData->prog.count > 0) + if (pData->prog.count > 0) { const int32_t current = dispatcher(effGetProgram, 0, 0, nullptr, 0.0f); - if (current >= 0 && current < static_cast(kData->prog.count)) + if (current >= 0 && current < static_cast(pData->prog.count)) { char strBuf[STR_MAX+1] = { '\0' }; dispatcher(effGetProgramName, 0, 0, strBuf, 0.0f); - if (kData->prog.names[current] != nullptr) - delete[] kData->prog.names[current]; + if (pData->prog.names[current] != nullptr) + delete[] pData->prog.names[current]; - kData->prog.names[current] = carla_strdup(strBuf); + pData->prog.names[current] = carla_strdup(strBuf); - if (kData->prog.current != current) + if (pData->prog.current != current) { - kData->prog.current = current; - kData->engine->callback(CALLBACK_PROGRAM_CHANGED, fId, current, 0, 0.0f, nullptr); + pData->prog.current = current; + pData->engine->callback(CALLBACK_PROGRAM_CHANGED, fId, current, 0, 0.0f, nullptr); } } } - kData->engine->callback(CALLBACK_UPDATE, fId, 0, 0, 0.0f, nullptr); + pData->engine->callback(CALLBACK_UPDATE, fId, 0, 0, 0.0f, nullptr); ret = 1; break; @@ -2142,51 +2142,51 @@ protected: public: bool init(const char* const filename, const char* const name) { - CARLA_ASSERT(kData->engine != nullptr); - CARLA_ASSERT(kData->client == nullptr); + CARLA_ASSERT(pData->engine != nullptr); + CARLA_ASSERT(pData->client == nullptr); CARLA_ASSERT(filename != 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; } // --------------------------------------------------------------- // 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 - VST_Function vstFn = (VST_Function)kData->libSymbol("VSTPluginMain"); + VST_Function vstFn = (VST_Function)pData->libSymbol("VSTPluginMain"); if (vstFn == nullptr) { - vstFn = (VST_Function)kData->libSymbol("main"); + vstFn = (VST_Function)pData->libSymbol("main"); if (vstFn == nullptr) { - kData->engine->setLastError("Could not find the VST main entry in the plugin library"); + pData->engine->setLastError("Could not find the VST main entry in the plugin library"); return false; } } @@ -2200,13 +2200,13 @@ public: if (fEffect == nullptr) { - kData->engine->setLastError("Plugin failed to initialize"); + pData->engine->setLastError("Plugin failed to initialize"); return false; } if (fEffect->magic != kEffectMagic) { - kData->engine->setLastError("Plugin is not valid (wrong vst effect magic code)"); + pData->engine->setLastError("Plugin is not valid (wrong vst effect magic code)"); return false; } @@ -2223,7 +2223,7 @@ public: if (name != nullptr) { - fName = kData->engine->getUniquePluginName(name); + fName = pData->engine->getUniquePluginName(name); } else { @@ -2232,12 +2232,12 @@ public: if (strBuf[0] != '\0') { - fName = kData->engine->getUniquePluginName(strBuf); + fName = pData->engine->getUniquePluginName(strBuf); } else { const char* const label = std::strrchr(filename, OS_SEP)+1; - fName = kData->engine->getUniquePluginName(label); + fName = pData->engine->getUniquePluginName(label); } } @@ -2246,11 +2246,11 @@ public: // --------------------------------------------------------------- // 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; } @@ -2258,10 +2258,10 @@ public: // initialize plugin (part 2) #if ! VST_FORCE_DEPRECATED - dispatcher(effSetBlockSizeAndSampleRate, 0, kData->engine->getBufferSize(), nullptr, kData->engine->getSampleRate()); + dispatcher(effSetBlockSizeAndSampleRate, 0, pData->engine->getBufferSize(), nullptr, pData->engine->getSampleRate()); #endif - dispatcher(effSetSampleRate, 0, 0, nullptr, kData->engine->getSampleRate()); - dispatcher(effSetBlockSize, 0, kData->engine->getBufferSize(), nullptr, 0.0f); + dispatcher(effSetSampleRate, 0, 0, nullptr, pData->engine->getSampleRate()); + dispatcher(effSetBlockSize, 0, pData->engine->getBufferSize(), nullptr, 0.0f); dispatcher(effSetProcessPrecision, 0, kVstProcessPrecision32, nullptr, 0.0f); if (dispatcher(effGetVstVersion, 0, 0, nullptr, 0.0f) < kVstVersion) @@ -2275,7 +2275,7 @@ public: if (fEffect->flags & effFlagsHasEditor) { - const EngineOptions& engineOptions(kData->engine->getOptions()); + const EngineOptions& engineOptions(pData->engine->getOptions()); #if defined(Q_WS_X11) CarlaString uiBridgeBinary(engineOptions.bridge_vstX11); @@ -2289,7 +2289,7 @@ public: if (engineOptions.preferUiBridges && uiBridgeBinary.isNotEmpty() && (fEffect->flags & effFlagsProgramChunks) == 0) { - kData->osc.thread.setOscData(uiBridgeBinary, nullptr); + pData->osc.thread.setOscData(uiBridgeBinary, nullptr); fGui.isOsc = true; } } @@ -2318,11 +2318,11 @@ public: } // load settings - kData->idStr = "VST/"; - //kData->idStr += std::strrchr(filename, OS_SEP)+1; // FIXME! - //kData->idStr += "/"; - kData->idStr += CarlaString(uniqueId()); - fOptions = kData->loadSettings(fOptions, availableOptions()); + pData->idStr = "VST/"; + //pData->idStr += std::strrchr(filename, OS_SEP)+1; // FIXME! + //pData->idStr += "/"; + pData->idStr += CarlaString(uniqueId()); + fOptions = pData->loadSettings(fOptions, availableOptions()); // ignore settings, we need this anyway if (midiInCount() > 0) diff --git a/source/backend/standalone/CarlaStandalone.cpp b/source/backend/standalone/CarlaStandalone.cpp index 8cb12c314..ac326b3ea 100644 --- a/source/backend/standalone/CarlaStandalone.cpp +++ b/source/backend/standalone/CarlaStandalone.cpp @@ -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(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(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(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(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(value); diff --git a/source/modules/utils/RtList.hpp b/source/modules/utils/RtList.hpp index b6bc423ab..e3e5a1053 100644 --- a/source/modules/utils/RtList.hpp +++ b/source/modules/utils/RtList.hpp @@ -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)