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