From dad00379a20edb5b7051d3a5453609493b995b24 Mon Sep 17 00:00:00 2001 From: falkTX Date: Wed, 24 Apr 2013 01:16:35 +0100 Subject: [PATCH] Continue plugin bridge work --- source/backend/CarlaBackend.hpp | 19 -- source/backend/CarlaPlugin.hpp | 10 +- source/backend/CarlaStandalone.hpp | 6 + source/backend/engine/CarlaEngineOsc.cpp | 9 + source/backend/plugin/BridgePlugin.cpp | 34 +- source/backend/plugin/CarlaPlugin.cpp | 302 ++++++++++-------- source/backend/plugin/CarlaPluginInternal.hpp | 34 +- source/backend/plugin/DssiPlugin.cpp | 13 +- source/backend/plugin/FluidSynthPlugin.cpp | 8 +- source/backend/plugin/LadspaPlugin.cpp | 6 + source/backend/plugin/LinuxSamplerPlugin.cpp | 12 +- source/backend/plugin/Lv2Plugin.cpp | 12 +- source/backend/plugin/NativePlugin.cpp | 12 +- source/backend/plugin/VstPlugin.cpp | 12 +- source/backend/standalone/CarlaStandalone.cpp | 6 + source/bridges/CarlaBridgeClient.hpp | 2 +- source/bridges/CarlaBridgeOsc.cpp | 4 +- source/bridges/CarlaBridgeOsc.hpp | 2 + source/bridges/CarlaBridgePlugin.cpp | 19 -- source/utils/CarlaBridgeUtils.hpp | 35 +- 20 files changed, 317 insertions(+), 240 deletions(-) diff --git a/source/backend/CarlaBackend.hpp b/source/backend/CarlaBackend.hpp index caee934d2..839c5ba1e 100644 --- a/source/backend/CarlaBackend.hpp +++ b/source/backend/CarlaBackend.hpp @@ -122,25 +122,6 @@ const char* const CUSTOM_DATA_CHUNK = "http://kxstudio.sf.net/ns/carla/chunk"; const char* const CUSTOM_DATA_STRING = "http://kxstudio.sf.net/ns/carla/string"; //!< Carla String URI /**@}*/ -#if 0 -/*! - * @defgroup BridgeMessages Bridge Messages - * - * Various bridge related messages, used as configure(, value). - * \note This is for internal use only. - * - * TODO: Review these, may not be needed anymore - * @{ - */ -const char* const CARLA_BRIDGE_MSG_HIDE_GUI = "CarlaBridgeHideGUI"; //!< Plugin -> Host call, tells host GUI is now hidden -const char* const CARLA_BRIDGE_MSG_SAVED = "CarlaBridgeSaved"; //!< Plugin -> Host call, tells host state is saved -const char* const CARLA_BRIDGE_MSG_SAVE_NOW = "CarlaBridgeSaveNow"; //!< Host -> Plugin call, tells plugin to save state now -const char* const CARLA_BRIDGE_MSG_SET_CHUNK = "CarlaBridgeSetChunk"; //!< Host -> Plugin call, tells plugin to set chunk in file \a value -const char* const CARLA_BRIDGE_MSG_SET_CUSTOM = "CarlaBridgeSetCustom"; //!< Host -> Plugin call, tells plugin to set a custom data set using \a value ("type·key·rvalue"). -//If \a type is 'chunk' or 'binary' \a rvalue refers to chunk file. -/**@}*/ -#endif - /*! * The binary type of a plugin. */ diff --git a/source/backend/CarlaPlugin.hpp b/source/backend/CarlaPlugin.hpp index dd5e29db0..b018473e0 100644 --- a/source/backend/CarlaPlugin.hpp +++ b/source/backend/CarlaPlugin.hpp @@ -460,6 +460,7 @@ public: */ void setActive(const bool active, const bool sendOsc, const bool sendCallback); +#ifndef BUILD_BRIDGE /*! * Set the plugin's dry/wet signal value to \a value.\n * \a value must be between 0.0 and 1.0. @@ -510,6 +511,7 @@ public: * \note Force-Stereo plugins only! */ void setPanning(const float value, const bool sendOsc, const bool sendCallback); +#endif /*! * Set the plugin's midi control channel. @@ -548,6 +550,7 @@ public: */ void setParameterValueByRealIndex(const int32_t rindex, const float value, const bool sendGui, const bool sendOsc, const bool sendCallback); +#ifndef BUILD_BRIDGE /*! * Set parameter's \a parameterId MIDI channel to \a channel.\n * \a channel must be between 0 and 15. @@ -559,6 +562,7 @@ public: * \a cc must be between 0 and 95 (0x5F), or -1 for invalid. */ void setParameterMidiCC(const uint32_t parameterId, int16_t cc, const bool sendOsc, const bool sendCallback); +#endif /*! * Add a custom data set.\n @@ -727,19 +731,21 @@ public: // ------------------------------------------------------------------- // MIDI events +#ifndef BUILD_BRIDGE /*! * Send a single midi note to be processed in the next audio callback.\n * A note with 0 velocity means note-off. * \note Non-RT call */ void sendMidiSingleNote(const uint8_t channel, const uint8_t note, const uint8_t velo, const bool sendGui, const bool sendOsc, const bool sendCallback); +#endif /*! - * Send all midi notes off for the next audio callback.\n + * Send all midi notes off to the host callback.\n * This doesn't send the actual MIDI All-Notes-Off event, but 128 note-offs instead (if ctrlChannel is valid). * \note RT call */ - void sendMidiAllNotesOff(); + void sendMidiAllNotesOffToCallback(); // ------------------------------------------------------------------- // Post-poned events diff --git a/source/backend/CarlaStandalone.hpp b/source/backend/CarlaStandalone.hpp index cafeadb76..dd0115384 100644 --- a/source/backend/CarlaStandalone.hpp +++ b/source/backend/CarlaStandalone.hpp @@ -575,6 +575,7 @@ CARLA_EXPORT void carla_set_option(unsigned int pluginId, unsigned int option, b */ CARLA_EXPORT void carla_set_active(unsigned int pluginId, bool onOff); +#ifndef BUILD_BRIDGE /*! * Change a plugin's internal drywet value to \a value. */ @@ -599,6 +600,7 @@ CARLA_EXPORT void carla_set_balance_right(unsigned int pluginId, float value); * Change a plugin's internal panning value to \a value. */ CARLA_EXPORT void carla_set_panning(unsigned int pluginId, float value); +#endif /*! * Change a plugin's internal control channel to \a channel. @@ -610,6 +612,7 @@ CARLA_EXPORT void carla_set_ctrl_channel(unsigned int pluginId, int8_t channel); */ CARLA_EXPORT void carla_set_parameter_value(unsigned int pluginId, uint32_t parameterId, float value); +#ifndef BUILD_BRIDGE /*! * Set the plugin's parameter \a parameterId midi channel to \a channel. */ @@ -619,6 +622,7 @@ CARLA_EXPORT void carla_set_parameter_midi_channel(unsigned int pluginId, uint32 * Set the plugin's parameter \a parameterId midi cc to \a cc. */ CARLA_EXPORT void carla_set_parameter_midi_cc(unsigned int pluginId, uint32_t parameterId, int16_t cc); +#endif /*! * Change a plugin's program to \a programId. @@ -646,11 +650,13 @@ CARLA_EXPORT void carla_set_chunk_data(unsigned int pluginId, const char* chunkD */ CARLA_EXPORT void carla_prepare_for_save(unsigned int pluginId); +#ifndef BUILD_BRIDGE /*! * Send a single note of a plugin.\n * If \a note if 0, note-off is sent; note-on otherwise. */ CARLA_EXPORT void carla_send_midi_note(unsigned int pluginId, uint8_t channel, uint8_t note, uint8_t velocity); +#endif /*! * Tell a plugin to show its own custom UI. diff --git a/source/backend/engine/CarlaEngineOsc.cpp b/source/backend/engine/CarlaEngineOsc.cpp index 9a6a52b1e..220731415 100644 --- a/source/backend/engine/CarlaEngineOsc.cpp +++ b/source/backend/engine/CarlaEngineOsc.cpp @@ -532,6 +532,14 @@ int CarlaEngineOsc::handleMsgMidi(CARLA_ENGINE_OSC_HANDLE_ARGS2) carla_debug("CarlaEngineOsc::handleMsgMidi()"); CARLA_ENGINE_OSC_CHECK_OSC_TYPES(1, "m"); +#ifdef BUILD_BRIDGE + CARLA_ASSERT(false); // this should never happen + return 1; + + // unused + (void)plugin; + (void)argv; +#else if (plugin->midiInCount() == 0) { carla_stderr("CarlaEngineOsc::handleMsgMidi() - recived midi when plugin has no midi inputs"); @@ -574,6 +582,7 @@ int CarlaEngineOsc::handleMsgMidi(CARLA_ENGINE_OSC_HANDLE_ARGS2) } return 0; +#endif } int CarlaEngineOsc::handleMsgExiting(CARLA_ENGINE_OSC_HANDLE_ARGS1) diff --git a/source/backend/plugin/BridgePlugin.cpp b/source/backend/plugin/BridgePlugin.cpp index 76237bf00..72c5edf4c 100644 --- a/source/backend/plugin/BridgePlugin.cpp +++ b/source/backend/plugin/BridgePlugin.cpp @@ -17,7 +17,7 @@ #include "CarlaPluginInternal.hpp" -#if 1//ndef BUILD_BRIDGE +#ifndef BUILD_BRIDGE #include "CarlaBridgeUtils.hpp" #include "CarlaShmUtils.hpp" @@ -1103,20 +1103,12 @@ public: CARLA_ASSERT(value != nullptr); if (key == nullptr || value == nullptr) - { - // invalid - pass(); - } -#if 0 - else if (std::strcmp(key, CARLA_BRIDGE_MSG_HIDE_GUI) == 0) - { - x_engine->callback(CALLBACK_SHOW_GUI, m_id, 0, 0, 0.0, nullptr); - } + break; + + if (std::strcmp(key, CARLA_BRIDGE_MSG_HIDE_GUI) == 0) + kData->engine->callback(CALLBACK_SHOW_GUI, fId, 0, 0, 0.0f, nullptr); else if (std::strcmp(key, CARLA_BRIDGE_MSG_SAVED) == 0) - { - m_saved = true; - } -#endif + fSaved = true; break; } @@ -1128,10 +1120,15 @@ public: const int32_t index = argv[0]->i; const float value = argv[1]->f; - CARLA_ASSERT(index != PARAMETER_NULL); + CARLA_ASSERT_INT2(index >= 0 && index < static_cast(kData->param.count), index, kData->param.count); - // FIXME ? - setParameterValueByRealIndex(index, value, false, true, true); + if (index >= 0 && static_cast(kData->param.count)) + { + const float fixedValue(kData->param.fixValue(index, value)); + fParams[index].value = fixedValue; + + CarlaPlugin::setParameterValue(index, fixedValue, false, true, true); + } break; } @@ -1310,6 +1307,7 @@ public: fName = kData->engine->getUniquePluginName(name); fFilename = filename; + fBridgeBinary = bridgeBinary; // --------------------------------------------------------------- // SHM Audio Pool @@ -1444,8 +1442,6 @@ public: return false; } - fBridgeBinary = bridgeBinary; - return true; } diff --git a/source/backend/plugin/CarlaPlugin.cpp b/source/backend/plugin/CarlaPlugin.cpp index 10a22ca34..6e7c902a1 100644 --- a/source/backend/plugin/CarlaPlugin.cpp +++ b/source/backend/plugin/CarlaPlugin.cpp @@ -644,12 +644,15 @@ const SaveState& CarlaPlugin::getSaveState() // Internals saveState.active = kData->active; + +#ifndef BUILD_BRIDGE saveState.dryWet = kData->postProc.dryWet; saveState.volume = kData->postProc.volume; saveState.balanceLeft = kData->postProc.balanceLeft; saveState.balanceRight = kData->postProc.balanceRight; saveState.panning = kData->postProc.panning; saveState.ctrlChannel = kData->ctrlChannel; +#endif // ---------------------------- // Chunk @@ -907,8 +910,10 @@ void CarlaPlugin::loadSaveState(const SaveState& saveState) stateParameter->value *= sampleRate; setParameterValue(index, stateParameter->value, true, true, true); +#ifndef BUILD_BRIDGE setParameterMidiCC(index, stateParameter->midiCC, true, true); setParameterMidiChannel(index, stateParameter->midiChannel, true, true); +#endif } else carla_stderr("Could not set parameter data for '%s'", stateParameter->name); @@ -940,12 +945,14 @@ void CarlaPlugin::loadSaveState(const SaveState& saveState) // --------------------------------------------------------------------- // Part 6 - set internal stuff +#ifndef BUILD_BRIDGE setDryWet(saveState.dryWet, true, true); setVolume(saveState.volume, true, true); setBalanceLeft(saveState.balanceLeft, true, true); setBalanceRight(saveState.balanceRight, true, true); setPanning(saveState.panning, true, true); setCtrlChannel(saveState.ctrlChannel, true, true); +#endif setActive(saveState.active, true, true); } @@ -1052,20 +1059,27 @@ void CarlaPlugin::setActive(const bool active, const bool sendOsc, const bool se kData->active = active; - const float value = active ? 1.0f : 0.0f; +#ifndef BUILD_BRIDGE + const float value(active ? 1.0f : 0.0f); -#ifdef BUILD_BRIDGE - if (fHints & PLUGIN_IS_BRIDGE) - osc_send_control(&kData->osc.data, PARAMETER_ACTIVE, value); -#else if (sendOsc) kData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_ACTIVE, value); -#endif if (sendCallback) kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_ACTIVE, 0, value, nullptr); + + if (fHints & PLUGIN_IS_BRIDGE) + osc_send_control(&kData->osc.data, PARAMETER_ACTIVE, value); +#else + return; + + // unused + (void)sendOsc; + (void)sendCallback; +#endif } +#ifndef BUILD_BRIDGE void CarlaPlugin::setDryWet(const float value, const bool sendOsc, const bool sendCallback) { CARLA_ASSERT(value >= 0.0f && value <= 1.0f); @@ -1077,19 +1091,11 @@ void CarlaPlugin::setDryWet(const float value, const bool sendOsc, const bool se kData->postProc.dryWet = fixedValue; - if (sendOsc || sendCallback) - { -#ifdef BUILD_BRIDGE - if (fHints & PLUGIN_IS_BRIDGE) - osc_send_control(&kData->osc.data, PARAMETER_DRYWET, fixedValue); -#else - if (sendOsc) - kData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_DRYWET, fixedValue); -#endif + if (sendOsc) + kData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_DRYWET, fixedValue); - if (sendCallback) - kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_DRYWET, 0, fixedValue, nullptr); - } + if (sendCallback) + kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_DRYWET, 0, fixedValue, nullptr); } void CarlaPlugin::setVolume(const float value, const bool sendOsc, const bool sendCallback) @@ -1103,19 +1109,11 @@ void CarlaPlugin::setVolume(const float value, const bool sendOsc, const bool se kData->postProc.volume = fixedValue; - if (sendOsc || sendCallback) - { -#ifdef BUILD_BRIDGE - if (fHints & PLUGIN_IS_BRIDGE) - osc_send_control(&kData->osc.data, PARAMETER_VOLUME, fixedValue); -#else - if (sendOsc) - kData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_VOLUME, fixedValue); -#endif + if (sendOsc) + kData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_VOLUME, fixedValue); - if (sendCallback) - kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_VOLUME, 0, fixedValue, nullptr); - } + if (sendCallback) + kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_VOLUME, 0, fixedValue, nullptr); } void CarlaPlugin::setBalanceLeft(const float value, const bool sendOsc, const bool sendCallback) @@ -1129,19 +1127,11 @@ void CarlaPlugin::setBalanceLeft(const float value, const bool sendOsc, const bo kData->postProc.balanceLeft = fixedValue; - if (sendOsc || sendCallback) - { -#ifdef BUILD_BRIDGE - if (fHints & PLUGIN_IS_BRIDGE) - osc_send_control(&kData->osc.data, PARAMETER_BALANCE_LEFT, fixedValue); -#else - if (sendOsc) - kData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_BALANCE_LEFT, fixedValue); -#endif + if (sendOsc) + kData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_BALANCE_LEFT, fixedValue); - if (sendCallback) - kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_BALANCE_LEFT, 0, fixedValue, nullptr); - } + if (sendCallback) + kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_BALANCE_LEFT, 0, fixedValue, nullptr); } void CarlaPlugin::setBalanceRight(const float value, const bool sendOsc, const bool sendCallback) @@ -1155,19 +1145,11 @@ void CarlaPlugin::setBalanceRight(const float value, const bool sendOsc, const b kData->postProc.balanceRight = fixedValue; - if (sendOsc || sendCallback) - { -#ifdef BUILD_BRIDGE - if (fHints & PLUGIN_IS_BRIDGE) - osc_send_control(&kData->osc.data, PARAMETER_BALANCE_RIGHT, fixedValue); -#else - if (sendOsc) - kData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_BALANCE_RIGHT, fixedValue); -#endif + if (sendOsc) + kData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_BALANCE_RIGHT, fixedValue); - if (sendCallback) - kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_BALANCE_RIGHT, 0, fixedValue, nullptr); - } + if (sendCallback) + kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_BALANCE_RIGHT, 0, fixedValue, nullptr); } void CarlaPlugin::setPanning(const float value, const bool sendOsc, const bool sendCallback) @@ -1181,43 +1163,42 @@ void CarlaPlugin::setPanning(const float value, const bool sendOsc, const bool s kData->postProc.panning = fixedValue; - if (sendOsc || sendCallback) - { -#ifdef BUILD_BRIDGE - if (fHints & PLUGIN_IS_BRIDGE) - osc_send_control(&kData->osc.data, PARAMETER_PANNING, fixedValue); -#else - if (sendOsc) - kData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_PANNING, fixedValue); -#endif + if (sendOsc) + kData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_PANNING, fixedValue); - if (sendCallback) - kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_PANNING, 0, fixedValue, nullptr); - } + if (sendCallback) + kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_PANNING, 0, fixedValue, nullptr); } +#endif void CarlaPlugin::setCtrlChannel(const int8_t channel, const bool sendOsc, const bool sendCallback) { + CARLA_ASSERT(sendOsc || sendCallback); // never call this from RT + CARLA_ASSERT_INT(channel >= -1 && channel < MAX_MIDI_CHANNELS, channel); + if (kData->ctrlChannel == channel) return; kData->ctrlChannel = channel; - if (sendOsc || sendCallback) - { - const float ctrlf = channel; +#ifndef BUILD_BRIDGE + const float ctrlf(channel); -#ifdef BUILD_BRIDGE - if (fHints & PLUGIN_IS_BRIDGE) - osc_send_control(&kData->osc.data, PARAMETER_CTRL_CHANNEL, ctrlf); + if (sendOsc) + kData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_CTRL_CHANNEL, ctrlf); + + if (sendCallback) + kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_CTRL_CHANNEL, 0, ctrlf, nullptr); + + if (fHints & PLUGIN_IS_BRIDGE) + osc_send_control(&kData->osc.data, PARAMETER_CTRL_CHANNEL, ctrlf); #else - if (sendOsc) - kData->engine->osc_send_control_set_parameter_value(fId, PARAMETER_CTRL_CHANNEL, ctrlf); -#endif + return; - if (sendCallback) - kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, PARAMETER_CTRL_CHANNEL, 0, ctrlf, nullptr); - } + // unused + (void)sendOsc; + (void)sendCallback; +#endif } // ------------------------------------------------------------------- @@ -1226,23 +1207,27 @@ void CarlaPlugin::setCtrlChannel(const int8_t channel, const bool sendOsc, const void CarlaPlugin::setParameterValue(const uint32_t parameterId, const float value, const bool sendGui, const bool sendOsc, const bool sendCallback) { CARLA_ASSERT(parameterId < kData->param.count); +#ifdef BUILD_BRIDGE + CARLA_ASSERT(! sendGui); // this should never happen +#endif +#ifndef BUILD_BRIDGE if (sendGui) uiParameterChange(parameterId, value); -#ifndef BUILD_BRIDGE if (sendOsc) kData->engine->osc_send_control_set_parameter_value(fId, parameterId, value); -#else - // unused - (void)sendOsc; #endif if (sendCallback) kData->engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, fId, parameterId, 0, value, nullptr); -#ifndef BUILD_BRIDGE - else if (fHints & PLUGIN_IS_BRIDGE) - osc_send_control(&kData->osc.data, parameterId, value); + +#ifdef BUILD_BRIDGE + return; + + // unused + (void)sendGui; + (void)sendOsc; #endif } @@ -1256,6 +1241,10 @@ void CarlaPlugin::setParameterValueByRealIndex(const int32_t rindex, const float return; if (rindex == PARAMETER_ACTIVE) return setActive((value > 0.0f), sendOsc, sendCallback); + if (rindex == PARAMETER_CTRL_CHANNEL) + return setCtrlChannel(int8_t(value), sendOsc, sendCallback); + +#ifndef BUILD_BRIDGE if (rindex == PARAMETER_DRYWET) return setDryWet(value, sendOsc, sendCallback); if (rindex == PARAMETER_VOLUME) @@ -1266,8 +1255,7 @@ void CarlaPlugin::setParameterValueByRealIndex(const int32_t rindex, const float return setBalanceRight(value, sendOsc, sendCallback); if (rindex == PARAMETER_PANNING) return setPanning(value, sendOsc, sendCallback); - if (rindex == PARAMETER_CTRL_CHANNEL) - return setCtrlChannel(int8_t(value), sendOsc, sendCallback); +#endif for (uint32_t i=0; i < kData->param.count; ++i) { @@ -1280,8 +1268,10 @@ void CarlaPlugin::setParameterValueByRealIndex(const int32_t rindex, const float } } +#ifndef BUILD_BRIDGE void CarlaPlugin::setParameterMidiChannel(const uint32_t parameterId, uint8_t channel, const bool sendOsc, const bool sendCallback) { + CARLA_ASSERT(sendOsc || sendCallback); // never call this from RT CARLA_ASSERT(parameterId < kData->param.count); CARLA_ASSERT_INT(channel < MAX_MIDI_CHANNELS, channel); @@ -1293,23 +1283,26 @@ void CarlaPlugin::setParameterMidiChannel(const uint32_t parameterId, uint8_t ch #ifndef BUILD_BRIDGE if (sendOsc) kData->engine->osc_send_control_set_parameter_midi_channel(fId, parameterId, channel); -#else - // unused - (void)sendOsc; -#endif if (sendCallback) kData->engine->callback(CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED, fId, parameterId, channel, 0.0f, nullptr); -#ifndef BUILD_BRIDGE - else if (fHints & PLUGIN_IS_BRIDGE) - {} // TODO + + if (fHints & PLUGIN_IS_BRIDGE) + {} // TODO +#else + return; + + // unused + (void)sendOsc; + (void)sendCallback; #endif } void CarlaPlugin::setParameterMidiCC(const uint32_t parameterId, int16_t cc, const bool sendOsc, const bool sendCallback) { + CARLA_ASSERT(sendOsc || sendCallback); // never call this from RT CARLA_ASSERT(parameterId < kData->param.count); - CARLA_ASSERT_INT(cc >= -1, cc); + CARLA_ASSERT_INT(cc >= -1 && cc <= 0x5F, cc); if (cc < -1 || cc > 0x5F) cc = -1; @@ -1319,24 +1312,30 @@ void CarlaPlugin::setParameterMidiCC(const uint32_t parameterId, int16_t cc, con #ifndef BUILD_BRIDGE if (sendOsc) kData->engine->osc_send_control_set_parameter_midi_cc(fId, parameterId, cc); -#else - // unused - (void)sendOsc; -#endif if (sendCallback) kData->engine->callback(CALLBACK_PARAMETER_MIDI_CC_CHANGED, fId, parameterId, cc, 0.0f, nullptr); -#ifndef BUILD_BRIDGE - else if (fHints & PLUGIN_IS_BRIDGE) - {} // TODO + + if (fHints & PLUGIN_IS_BRIDGE) + {} // TODO +#else + return; + + // unused + (void)sendOsc; + (void)sendCallback; #endif } +#endif void CarlaPlugin::setCustomData(const char* const type, const char* const key, const char* const value, const bool sendGui) { CARLA_ASSERT(type != nullptr); CARLA_ASSERT(key != nullptr); CARLA_ASSERT(value != nullptr); +#ifdef BUILD_BRIDGE + CARLA_ASSERT(! sendGui); // this should never happen +#endif if (type == nullptr) return carla_stderr2("CarlaPlugin::setCustomData(\"%s\", \"%s\", \"%s\", %s) - type is null", type, key, value, bool2str(sendGui)); @@ -1358,44 +1357,45 @@ void CarlaPlugin::setCustomData(const char* const type, const char* const key, c // saveData = false; } - if (saveData) + if (! saveData) + return; + + // Check if we already have this key + for (auto it = kData->custom.begin(); it.valid(); it.next()) { - // Check if we already have this key - for (auto it = kData->custom.begin(); it.valid(); it.next()) - { - CustomData& cData(*it); + CustomData& cData(*it); - CARLA_ASSERT(cData.type != nullptr); - CARLA_ASSERT(cData.key != nullptr); - CARLA_ASSERT(cData.value != nullptr); + CARLA_ASSERT(cData.type != nullptr); + CARLA_ASSERT(cData.key != nullptr); + CARLA_ASSERT(cData.value != nullptr); - if (cData.type == nullptr) - return; - if (cData.key == nullptr) - return; + if (cData.type == nullptr) + return; + if (cData.key == nullptr) + return; - if (std::strcmp(cData.key, key) == 0) - { - if (cData.value != nullptr) - delete[] cData.value; + if (std::strcmp(cData.key, key) == 0) + { + if (cData.value != nullptr) + delete[] cData.value; - cData.value = carla_strdup(value); - return; - } + cData.value = carla_strdup(value); + return; } - - // Otherwise store it - CustomData newData; - newData.type = carla_strdup(type); - newData.key = carla_strdup(key); - newData.value = carla_strdup(value); - kData->custom.append(newData); } + + // Otherwise store it + CustomData newData; + newData.type = carla_strdup(type); + newData.key = carla_strdup(key); + newData.value = carla_strdup(value); + kData->custom.append(newData); } void CarlaPlugin::setChunkData(const char* const stringData) { CARLA_ASSERT(stringData != nullptr); + CARLA_ASSERT(false); // this should never happen return; // unused @@ -1405,6 +1405,9 @@ void CarlaPlugin::setChunkData(const char* const stringData) void CarlaPlugin::setProgram(int32_t index, const bool sendGui, const bool sendOsc, const bool sendCallback) { CARLA_ASSERT(index >= -1 && index < static_cast(kData->prog.count)); +#ifdef BUILD_BRIDGE + CARLA_ASSERT(! sendGui); // this should never happen +#endif if (index > static_cast(kData->prog.count)) return; @@ -1416,8 +1419,10 @@ void CarlaPlugin::setProgram(int32_t index, const bool sendGui, const bool sendO // Change default parameter values if (fixedIndex >= 0) { +#ifndef BUILD_BRIDGE if (sendGui) uiProgramChange(fixedIndex); +#endif for (uint32_t i=0; i < kData->param.count; ++i) { @@ -1425,13 +1430,13 @@ void CarlaPlugin::setProgram(int32_t index, const bool sendGui, const bool sendO kData->param.ranges[i].def = getParameterValue(i); kData->param.ranges[i].fixDefault(); +#ifndef BUILD_BRIDGE if (sendOsc) { -#ifndef BUILD_BRIDGE kData->engine->osc_send_control_set_default_value(fId, i, kData->param.ranges[i].def); kData->engine->osc_send_control_set_parameter_value(fId, i, kData->param.ranges[i].def); -#endif } +#endif } } @@ -1442,11 +1447,22 @@ void CarlaPlugin::setProgram(int32_t index, const bool sendGui, const bool sendO if (sendCallback) kData->engine->callback(CALLBACK_PROGRAM_CHANGED, fId, fixedIndex, 0, 0.0f, nullptr); + +#ifdef BUILD_BRIDGE + return; + + // unused + (void)sendGui; + (void)sendOsc; +#endif } void CarlaPlugin::setMidiProgram(int32_t index, const bool sendGui, const bool sendOsc, const bool sendCallback) { CARLA_ASSERT(index >= -1 && index < static_cast(kData->midiprog.count)); +#ifdef BUILD_BRIDGE + CARLA_ASSERT(! sendGui); // this should never happen +#endif if (index > static_cast(kData->midiprog.count)) return; @@ -1457,13 +1473,13 @@ void CarlaPlugin::setMidiProgram(int32_t index, const bool sendGui, const bool s if (fixedIndex >= 0) { +#ifndef BUILD_BRIDGE if (sendGui) uiMidiProgramChange(fixedIndex); +#endif // Change default parameter values (sound banks never change defaults) -#ifndef BUILD_BRIDGE // FIXME if (type() != PLUGIN_GIG && type() != PLUGIN_SF2 && type() != PLUGIN_SFZ) -#endif { for (uint32_t i=0; i < kData->param.count; ++i) { @@ -1471,13 +1487,13 @@ void CarlaPlugin::setMidiProgram(int32_t index, const bool sendGui, const bool s kData->param.ranges[i].def = getParameterValue(i); kData->param.ranges[i].fixDefault(); +#ifndef BUILD_BRIDGE if (sendOsc) { -#ifndef BUILD_BRIDGE kData->engine->osc_send_control_set_default_value(fId, i, kData->param.ranges[i].def); kData->engine->osc_send_control_set_parameter_value(fId, i, kData->param.ranges[i].def); -#endif } +#endif } } } @@ -1489,6 +1505,14 @@ void CarlaPlugin::setMidiProgram(int32_t index, const bool sendGui, const bool s if (sendCallback) kData->engine->callback(CALLBACK_MIDI_PROGRAM_CHANGED, fId, fixedIndex, 0, 0.0f, nullptr); + +#ifdef BUILD_BRIDGE + return; + + // unused + (void)sendGui; + (void)sendOsc; +#endif } void CarlaPlugin::setMidiProgramById(const uint32_t bank, const uint32_t program, const bool sendGui, const bool sendOsc, const bool sendCallback) @@ -1505,6 +1529,7 @@ void CarlaPlugin::setMidiProgramById(const uint32_t bank, const uint32_t program void CarlaPlugin::showGui(const bool yesNo) { + CARLA_ASSERT(false); return; // unused @@ -1836,6 +1861,7 @@ bool CarlaPlugin::waitForOscGuiShow() // ------------------------------------------------------------------- // MIDI events +#ifndef BUILD_BRIDGE void CarlaPlugin::sendMidiSingleNote(const uint8_t channel, const uint8_t note, const uint8_t velo, const bool sendGui, const bool sendOsc, const bool sendCallback) { CARLA_ASSERT(channel < MAX_MIDI_CHANNELS); @@ -1860,7 +1886,6 @@ void CarlaPlugin::sendMidiSingleNote(const uint8_t channel, const uint8_t note, uiNoteOff(channel, note); } -#ifndef BUILD_BRIDGE if (sendOsc) { if (velo > 0) @@ -1868,16 +1893,13 @@ void CarlaPlugin::sendMidiSingleNote(const uint8_t channel, const uint8_t note, else kData->engine->osc_send_control_note_off(fId, channel, note); } -#else - // unused - (void)sendOsc; -#endif if (sendCallback) kData->engine->callback((velo > 0) ? CALLBACK_NOTE_ON : CALLBACK_NOTE_OFF, fId, channel, note, velo, nullptr); } +#endif -void CarlaPlugin::sendMidiAllNotesOff() +void CarlaPlugin::sendMidiAllNotesOffToCallback() { if (kData->ctrlChannel < 0 || kData->ctrlChannel >= MAX_MIDI_CHANNELS) return; diff --git a/source/backend/plugin/CarlaPluginInternal.hpp b/source/backend/plugin/CarlaPluginInternal.hpp index 69af589b9..bff49c6a2 100644 --- a/source/backend/plugin/CarlaPluginInternal.hpp +++ b/source/backend/plugin/CarlaPluginInternal.hpp @@ -29,7 +29,7 @@ #include "RtList.hpp" -#define CARLA_PROCESS_CONTINUE_CHECK if (! fEnabled) { kData->engine->callback(CALLBACK_DEBUG, fId, 0, 0, 0.0f, nullptr); return; } +#define CARLA_PROCESS_CONTINUE_CHECK if (! fEnabled) { kData->engine->callback(CALLBACK_DEBUG, fId, 0, 0, 0.0f, "Processing while plugin is disabled!!"); return; } CARLA_BACKEND_START_NAMESPACE @@ -214,7 +214,7 @@ struct PluginParameterData { float fixValue(const uint32_t parameterId, const float& value) { - CARLA_ASSERT(parameterId < count); + CARLA_ASSERT_INT2(parameterId < count, parameterId, count); return ranges[parameterId].fixValue(value); } @@ -266,7 +266,10 @@ struct PluginProgramData { for (uint32_t i=0; i < count; ++i) { if (names[i] != nullptr) + { delete[] names[i]; + names[i] = nullptr; + } } delete[] names; @@ -320,7 +323,10 @@ struct PluginMidiProgramData { for (uint32_t i=0; i < count; ++i) { if (data[i].name != nullptr) + { delete[] data[i].name; + data[i].name = nullptr; + } } delete[] data; @@ -333,7 +339,7 @@ struct PluginMidiProgramData { const MidiProgramData& getCurrent() const { - CARLA_ASSERT(current >= 0 && current < static_cast(count)); + CARLA_ASSERT_INT2(current >= 0 && current < static_cast(count), current, count); return data[current]; } @@ -484,6 +490,7 @@ struct CarlaPluginProtectedData { } postRtEvents; +#ifndef BUILD_BRIDGE struct PostProc { float dryWet; float volume; @@ -501,6 +508,7 @@ struct CarlaPluginProtectedData { CARLA_DECLARE_NON_COPY_STRUCT_WITH_LEAK_DETECTOR(PostProc) } postProc; +#endif struct OSC { CarlaOscData data; @@ -538,6 +546,7 @@ struct CarlaPluginProtectedData { ~CarlaPluginProtectedData() { CARLA_ASSERT(gui == nullptr); + CARLA_ASSERT(client == nullptr); CARLA_ASSERT(! active); CARLA_ASSERT(! needsReset); CARLA_ASSERT(lib == nullptr); @@ -578,18 +587,29 @@ struct CarlaPluginProtectedData { CARLA_ASSERT(cData.value != nullptr); if (cData.type != nullptr) + { delete[] cData.type; + cData.type = nullptr; + } + if (cData.key != nullptr) + { delete[] cData.key; + cData.key = nullptr; + } + if (cData.value != nullptr) + { delete[] cData.value; + cData.value = nullptr; + } } prog.clear(); midiprog.clear(); custom.clear(); - // MUST have been unlocked before + // MUST have been locked before masterMutex.unlock(); singleMutex.unlock(); @@ -609,7 +629,10 @@ struct CarlaPluginProtectedData { CARLA_ASSERT(latencyBuffers[i] != nullptr); if (latencyBuffers[i] != nullptr) + { delete[] latencyBuffers[i]; + latencyBuffers[i] = nullptr; + } } delete[] latencyBuffers; @@ -632,7 +655,10 @@ struct CarlaPluginProtectedData { CARLA_ASSERT(latencyBuffers[i] != nullptr); if (latencyBuffers[i] != nullptr) + { delete[] latencyBuffers[i]; + latencyBuffers[i] = nullptr; + } } delete[] latencyBuffers; diff --git a/source/backend/plugin/DssiPlugin.cpp b/source/backend/plugin/DssiPlugin.cpp index 7d577ef9c..17f8446fa 100644 --- a/source/backend/plugin/DssiPlugin.cpp +++ b/source/backend/plugin/DssiPlugin.cpp @@ -1108,6 +1108,7 @@ public: case kEngineControlEventTypeParameter: { +#ifndef BUILD_BRIDGE // Control backend stuff if (event.channel == kData->ctrlChannel) { @@ -1187,7 +1188,7 @@ public: setParameterValue(k, value, false, false, false); postponeRtEvent(kPluginPostRtEventParameterChange, static_cast(k), 0, value); } - +#endif break; } @@ -1218,7 +1219,7 @@ public: { if (! allNotesOffSent) { - sendMidiAllNotesOff(); + sendMidiAllNotesOffToCallback(); allNotesOffSent = true; } @@ -1241,7 +1242,6 @@ public: midiEventCount += 1; } - break; case kEngineControlEventTypeAllNotesOff: @@ -1250,7 +1250,7 @@ public: if (! allNotesOffSent) { allNotesOffSent = true; - sendMidiAllNotesOff(); + sendMidiAllNotesOffToCallback(); } } @@ -1269,7 +1269,6 @@ public: midiEventCount += 1; } - break; } @@ -1281,7 +1280,7 @@ public: if (midiEventCount >= MAX_MIDI_EVENTS) continue; - const EngineMidiEvent& midiEvent = event.midi; + const EngineMidiEvent& midiEvent(event.midi); uint8_t status = MIDI_GET_STATUS_FROM_DATA(midiEvent.data); uint8_t channel = event.channel; @@ -1483,6 +1482,7 @@ public: fDescriptor->run(fHandle2, frames); } +#ifndef BUILD_BRIDGE // -------------------------------------------------------------------------------------------------------- // Post-processing (dry/wet, volume and balance) @@ -1558,6 +1558,7 @@ public: } #endif } // End of Post-processing +#endif // -------------------------------------------------------------------------------------------------------- diff --git a/source/backend/plugin/FluidSynthPlugin.cpp b/source/backend/plugin/FluidSynthPlugin.cpp index 970773b73..d1aa62dbc 100644 --- a/source/backend/plugin/FluidSynthPlugin.cpp +++ b/source/backend/plugin/FluidSynthPlugin.cpp @@ -1021,6 +1021,7 @@ public: case kEngineControlEventTypeParameter: { +#ifndef BUILD_BRIDGE // Control backend stuff if (event.channel == kData->ctrlChannel) { @@ -1070,6 +1071,7 @@ public: continue; } } +#endif // Control plugin parameters for (k=0; k < kData->param.count; ++k) @@ -1138,7 +1140,7 @@ public: { if (! allNotesOffSent) { - sendMidiAllNotesOff(); + sendMidiAllNotesOffToCallback(); allNotesOffSent = true; } @@ -1161,7 +1163,7 @@ public: { if (! allNotesOffSent) { - sendMidiAllNotesOff(); + sendMidiAllNotesOffToCallback(); allNotesOffSent = true; } @@ -1310,6 +1312,7 @@ public: else fluid_synth_write_float(fSynth, frames, outBuffer[0] + timeOffset, 0, 1, outBuffer[1] + timeOffset, 0, 1); +#ifndef BUILD_BRIDGE // -------------------------------------------------------------------------------------------------------- // Post-processing (volume and balance) @@ -1362,6 +1365,7 @@ public: } } // End of Post-processing +#endif // -------------------------------------------------------------------------------------------------------- diff --git a/source/backend/plugin/LadspaPlugin.cpp b/source/backend/plugin/LadspaPlugin.cpp index b29e3e67c..c537dfe44 100644 --- a/source/backend/plugin/LadspaPlugin.cpp +++ b/source/backend/plugin/LadspaPlugin.cpp @@ -923,6 +923,7 @@ public: case kEngineControlEventTypeParameter: { +#ifndef BUILD_BRIDGE // Control backend stuff if (event.channel == kData->ctrlChannel) { @@ -972,6 +973,7 @@ public: continue; } } +#endif // Control plugin parameters for (k=0; k < kData->param.count; ++k) @@ -1011,11 +1013,13 @@ public: break; case kEngineControlEventTypeAllSoundOff: +#ifndef BUILD_BRIDGE if (event.channel == kData->ctrlChannel) { postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_ACTIVE, 0, 0.0f); postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_ACTIVE, 0, 1.0f); } +#endif break; case kEngineControlEventTypeAllNotesOff: @@ -1133,6 +1137,7 @@ public: if (fHandle2 != nullptr) fDescriptor->run(fHandle2, frames); +#ifndef BUILD_BRIDGE // -------------------------------------------------------------------------------------------------------- // Post-processing (dry/wet, volume and balance) @@ -1208,6 +1213,7 @@ public: } #endif } // End of Post-processing +#endif // -------------------------------------------------------------------------------------------------------- diff --git a/source/backend/plugin/LinuxSamplerPlugin.cpp b/source/backend/plugin/LinuxSamplerPlugin.cpp index ee5d1d97b..39b79cde4 100644 --- a/source/backend/plugin/LinuxSamplerPlugin.cpp +++ b/source/backend/plugin/LinuxSamplerPlugin.cpp @@ -621,6 +621,7 @@ public: case kEngineControlEventTypeParameter: { +#ifndef BUILD_BRIDGE // Control backend stuff if (event.channel == kData->ctrlChannel) { @@ -670,6 +671,7 @@ public: continue; } } +#endif // Control plugin parameters for (k=0; k < kData->param.count; ++k) @@ -731,7 +733,7 @@ public: { if (! allNotesOffSent) { - sendMidiAllNotesOff(); + sendMidiAllNotesOffToCallback(); allNotesOffSent = true; } @@ -741,7 +743,6 @@ public: if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF) fMidiInputPort->DispatchControlChange(MIDI_CONTROL_ALL_SOUND_OFF, 0, k, sampleAccurate ? startTime : time); - break; case kEngineControlEventTypeAllNotesOff: @@ -749,14 +750,13 @@ public: { if (! allNotesOffSent) { - sendMidiAllNotesOff(); + sendMidiAllNotesOffToCallback(); allNotesOffSent = true; } } if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF) fMidiInputPort->DispatchControlChange(MIDI_CONTROL_ALL_NOTES_OFF, 0, k, sampleAccurate ? startTime : time); - break; } @@ -765,7 +765,7 @@ public: case kEngineEventTypeMidi: { - const EngineMidiEvent& midiEvent = event.midi; + const EngineMidiEvent& midiEvent(event.midi); uint8_t status = MIDI_GET_STATUS_FROM_DATA(midiEvent.data); uint8_t channel = event.channel; @@ -872,6 +872,7 @@ public: // QUESTION: Need to clear it before? fAudioOutputDevice->Render(frames); +#ifndef BUILD_BRIDGE // -------------------------------------------------------------------------------------------------------- // Post-processing (dry/wet, volume and balance) @@ -918,6 +919,7 @@ public: } } // End of Post-processing +#endif // -------------------------------------------------------------------------------------------------------- diff --git a/source/backend/plugin/Lv2Plugin.cpp b/source/backend/plugin/Lv2Plugin.cpp index a40cd7016..f1a80b984 100644 --- a/source/backend/plugin/Lv2Plugin.cpp +++ b/source/backend/plugin/Lv2Plugin.cpp @@ -2476,6 +2476,7 @@ public: case kEngineControlEventTypeParameter: { +#ifndef BUILD_BRIDGE // Control backend stuff if (event.channel == kData->ctrlChannel) { @@ -2525,6 +2526,7 @@ public: continue; } } +#endif // Control plugin parameters for (k=0; k < kData->param.count; ++k) @@ -2586,7 +2588,7 @@ public: { if (! allNotesOffSent) { - sendMidiAllNotesOff(); + sendMidiAllNotesOffToCallback(); allNotesOffSent = true; } @@ -2598,7 +2600,6 @@ public: { // TODO } - break; case kEngineControlEventTypeAllNotesOff: @@ -2607,7 +2608,7 @@ public: if (! allNotesOffSent) { allNotesOffSent = true; - sendMidiAllNotesOff(); + sendMidiAllNotesOffToCallback(); } } @@ -2615,7 +2616,6 @@ public: { // TODO } - break; } @@ -2624,7 +2624,7 @@ public: case kEngineEventTypeMidi: { - const EngineMidiEvent& midiEvent = event.midi; + const EngineMidiEvent& midiEvent(event.midi); uint8_t status = MIDI_GET_STATUS_FROM_DATA(midiEvent.data); uint8_t channel = event.channel; @@ -2799,6 +2799,7 @@ public: if (fHandle2 != nullptr) fDescriptor->run(fHandle2, frames); +#ifndef BUILD_BRIDGE // -------------------------------------------------------------------------------------------------------- // Post-processing (dry/wet, volume and balance) @@ -2874,6 +2875,7 @@ public: } #endif } // End of Post-processing +#endif // -------------------------------------------------------------------------------------------------------- diff --git a/source/backend/plugin/NativePlugin.cpp b/source/backend/plugin/NativePlugin.cpp index f173efe5a..d300da2da 100644 --- a/source/backend/plugin/NativePlugin.cpp +++ b/source/backend/plugin/NativePlugin.cpp @@ -1340,6 +1340,7 @@ public: case kEngineControlEventTypeParameter: { +#ifndef BUILD_BRIDGE // Control backend stuff if (event.channel == kData->ctrlChannel) { @@ -1389,6 +1390,7 @@ public: continue; } } +#endif // Control plugin parameters for (k=0; k < kData->param.count; ++k) @@ -1450,7 +1452,7 @@ public: { if (! allNotesOffSent) { - sendMidiAllNotesOff(); + sendMidiAllNotesOffToCallback(); allNotesOffSent = true; } @@ -1473,7 +1475,6 @@ public: fMidiEventCount += 1; } - break; case kEngineControlEventTypeAllNotesOff: @@ -1482,7 +1483,7 @@ public: if (! allNotesOffSent) { allNotesOffSent = true; - sendMidiAllNotesOff(); + sendMidiAllNotesOffToCallback(); } } @@ -1501,7 +1502,6 @@ public: fMidiEventCount += 1; } - break; } @@ -1513,7 +1513,7 @@ public: if (fMidiEventCount >= MAX_MIDI_EVENTS*2) continue; - const EngineMidiEvent& midiEvent = event.midi; + const EngineMidiEvent& midiEvent(event.midi); uint8_t status = MIDI_GET_STATUS_FROM_DATA(midiEvent.data); uint8_t channel = event.channel; @@ -1683,6 +1683,7 @@ public: fIsProcessing = false; fTimeInfo.frame += frames; +#ifndef BUILD_BRIDGE // -------------------------------------------------------------------------------------------------------- // Post-processing (dry/wet, volume and balance) @@ -1744,6 +1745,7 @@ public: } } // End of Post-processing +#endif // -------------------------------------------------------------------------------------------------------- diff --git a/source/backend/plugin/VstPlugin.cpp b/source/backend/plugin/VstPlugin.cpp index 945230751..5eab122f1 100644 --- a/source/backend/plugin/VstPlugin.cpp +++ b/source/backend/plugin/VstPlugin.cpp @@ -1168,6 +1168,7 @@ public: case kEngineControlEventTypeParameter: { +#ifndef BUILD_BRIDGE // Control backend stuff if (event.channel == kData->ctrlChannel) { @@ -1217,6 +1218,7 @@ public: continue; } } +#endif // Control plugin parameters for (k=0; k < kData->param.count; ++k) @@ -1271,7 +1273,7 @@ public: { if (! allNotesOffSent) { - sendMidiAllNotesOff(); + sendMidiAllNotesOffToCallback(); allNotesOffSent = true; } @@ -1294,7 +1296,6 @@ public: fMidiEventCount += 1; } - break; case kEngineControlEventTypeAllNotesOff: @@ -1303,7 +1304,7 @@ public: if (! allNotesOffSent) { allNotesOffSent = true; - sendMidiAllNotesOff(); + sendMidiAllNotesOffToCallback(); } } @@ -1322,7 +1323,6 @@ public: fMidiEventCount += 1; } - break; } @@ -1334,7 +1334,7 @@ public: if (fMidiEventCount >= MAX_MIDI_EVENTS*2) continue; - const EngineMidiEvent& midiEvent = event.midi; + const EngineMidiEvent& midiEvent(event.midi); uint8_t status = MIDI_GET_STATUS_FROM_DATA(midiEvent.data); uint8_t channel = event.channel; @@ -1504,6 +1504,7 @@ public: fIsProcessing = false; fTimeInfo.samplePos += frames; +#ifndef BUILD_BRIDGE // -------------------------------------------------------------------------------------------------------- // Post-processing (dry/wet, volume and balance) @@ -1567,6 +1568,7 @@ public: } } // End of Post-processing +#endif // -------------------------------------------------------------------------------------------------------- diff --git a/source/backend/standalone/CarlaStandalone.cpp b/source/backend/standalone/CarlaStandalone.cpp index fa9ed25e9..76774f632 100644 --- a/source/backend/standalone/CarlaStandalone.cpp +++ b/source/backend/standalone/CarlaStandalone.cpp @@ -1741,6 +1741,7 @@ void carla_set_active(unsigned int pluginId, bool onOff) carla_stderr2("carla_set_active(%i, %s) - could not find plugin", pluginId, bool2str(onOff)); } +#ifndef BUILD_BRIDGE void carla_set_drywet(unsigned int pluginId, float value) { carla_debug("carla_set_drywet(%i, %f)", pluginId, value); @@ -1810,6 +1811,7 @@ void carla_set_panning(unsigned int pluginId, float value) carla_stderr2("carla_set_panning(%i, %f) - could not find plugin", pluginId, value); } +#endif void carla_set_ctrl_channel(unsigned int pluginId, int8_t channel) { @@ -1847,6 +1849,7 @@ void carla_set_parameter_value(unsigned int pluginId, uint32_t parameterId, floa carla_stderr2("carla_set_parameter_value(%i, %i, %f) - could not find plugin", pluginId, parameterId, value); } +#ifndef BUILD_BRIDGE void carla_set_parameter_midi_channel(unsigned int pluginId, uint32_t parameterId, uint8_t channel) { carla_debug("carla_set_parameter_midi_channel(%i, %i, %i)", pluginId, parameterId, channel); @@ -1904,6 +1907,7 @@ void carla_set_parameter_midi_cc(unsigned int pluginId, uint32_t parameterId, in carla_stderr2("carla_set_parameter_midi_cc(%i, %i, %i) - could not find plugin", pluginId, parameterId, cc); } +#endif // ------------------------------------------------------------------------------------------------------------------- @@ -1999,6 +2003,7 @@ void carla_prepare_for_save(unsigned int pluginId) carla_stderr2("carla_prepare_for_save(%i) - could not find plugin", pluginId); } +#ifndef BUILD_BRIDGE void carla_send_midi_note(unsigned int pluginId, uint8_t channel, uint8_t note, uint8_t velocity) { carla_debug("carla_send_midi_note(%i, %i, %i, %i)", pluginId, channel, note, velocity); @@ -2012,6 +2017,7 @@ void carla_send_midi_note(unsigned int pluginId, uint8_t channel, uint8_t note, carla_stderr2("carla_send_midi_note(%i, %i, %i, %i) - could not find plugin", pluginId, channel, note, velocity); } +#endif void carla_show_gui(unsigned int pluginId, bool yesno) { diff --git a/source/bridges/CarlaBridgeClient.hpp b/source/bridges/CarlaBridgeClient.hpp index 46720825d..4b7816861 100644 --- a/source/bridges/CarlaBridgeClient.hpp +++ b/source/bridges/CarlaBridgeClient.hpp @@ -72,9 +72,9 @@ public: virtual void setMidiProgram(const uint32_t index) = 0; #else virtual void setMidiProgram(const uint32_t bank, const uint32_t program) = 0; -#endif virtual void noteOn(const uint8_t channel, const uint8_t note, const uint8_t velo) = 0; virtual void noteOff(const uint8_t channel, const uint8_t note) = 0; +#endif // --------------------------------------------------------------------- // osc stuff diff --git a/source/bridges/CarlaBridgeOsc.cpp b/source/bridges/CarlaBridgeOsc.cpp index bd68dd002..562dca357 100644 --- a/source/bridges/CarlaBridgeOsc.cpp +++ b/source/bridges/CarlaBridgeOsc.cpp @@ -166,8 +166,10 @@ int CarlaBridgeOsc::handleMessage(const char* const path, const int argc, const return handleMsgProgram(argc, argv, types); if (std::strcmp(method, "midi-program") == 0) return handleMsgMidiProgram(argc, argv, types); +#ifndef BUILD_BRIDGE_PLUGIN if (std::strcmp(method, "midi") == 0) return handleMsgMidi(argc, argv, types); +#endif if (std::strcmp(method, "sample-rate") == 0) return 0; // unused if (std::strcmp(method, "show") == 0) @@ -311,7 +313,6 @@ int CarlaBridgeOsc::handleMsgMidiProgram(CARLA_BRIDGE_OSC_HANDLE_ARGS) return 0; } -#endif int CarlaBridgeOsc::handleMsgMidi(CARLA_BRIDGE_OSC_HANDLE_ARGS) { @@ -359,6 +360,7 @@ int CarlaBridgeOsc::handleMsgMidi(CARLA_BRIDGE_OSC_HANDLE_ARGS) return 0; } +#endif #ifdef BUILD_BRIDGE_UI int CarlaBridgeOsc::handleMsgShow() diff --git a/source/bridges/CarlaBridgeOsc.hpp b/source/bridges/CarlaBridgeOsc.hpp index b03f358f5..cac1fc8b2 100644 --- a/source/bridges/CarlaBridgeOsc.hpp +++ b/source/bridges/CarlaBridgeOsc.hpp @@ -101,7 +101,9 @@ private: int handleMsgControl(CARLA_BRIDGE_OSC_HANDLE_ARGS); int handleMsgProgram(CARLA_BRIDGE_OSC_HANDLE_ARGS); int handleMsgMidiProgram(CARLA_BRIDGE_OSC_HANDLE_ARGS); +#ifndef BUILD_BRIDGE_PLUGIN int handleMsgMidi(CARLA_BRIDGE_OSC_HANDLE_ARGS); +#endif int handleMsgShow(); int handleMsgHide(); int handleMsgQuit(); diff --git a/source/bridges/CarlaBridgePlugin.cpp b/source/bridges/CarlaBridgePlugin.cpp index 11760d672..417019ccf 100644 --- a/source/bridges/CarlaBridgePlugin.cpp +++ b/source/bridges/CarlaBridgePlugin.cpp @@ -317,25 +317,6 @@ public: fPlugin->setMidiProgram(index, true, true, false); } - void noteOn(const uint8_t channel, const uint8_t note, const uint8_t velo) - { - carla_debug("CarlaPluginClient::noteOn(%i, %i, %i)", channel, note, velo); - CARLA_ASSERT(fPlugin != nullptr); - CARLA_ASSERT(velo > 0); - - if (fPlugin != nullptr) - fPlugin->sendMidiSingleNote(channel, note, velo, true, true, false); - } - - void noteOff(const uint8_t channel, const uint8_t note) - { - carla_debug("CarlaPluginClient::noteOff(%i, %i)", channel, note); - CARLA_ASSERT(fPlugin != nullptr); - - if (fPlugin != nullptr) - fPlugin->sendMidiSingleNote(channel, note, 0, true, true, false); - } - protected: void handleCallback(const CarlaBackend::CallbackType action, const int value1, const int value2, const float value3, const char* const valueStr) { diff --git a/source/utils/CarlaBridgeUtils.hpp b/source/utils/CarlaBridgeUtils.hpp index c21ad2dbb..eb6aacd23 100644 --- a/source/utils/CarlaBridgeUtils.hpp +++ b/source/utils/CarlaBridgeUtils.hpp @@ -52,15 +52,36 @@ enum PluginBridgeInfoType { }; enum PluginBridgeOpcode { - kPluginBridgeOpcodeNull = 0, - kPluginBridgeOpcodeReadyWait = 1, - kPluginBridgeOpcodeSetBufferSize = 2, - kPluginBridgeOpcodeSetSampleRate = 3, - kPluginBridgeOpcodeSetParameter = 4, - kPluginBridgeOpcodeProcess = 5, - kPluginBridgeOpcodeQuit = 6 + kPluginBridgeOpcodeNull = 0, + kPluginBridgeOpcodeReadyWait = 1, + kPluginBridgeOpcodeSetBufferSize = 2, + kPluginBridgeOpcodeSetSampleRate = 3, + kPluginBridgeOpcodeSetParameter = 4, + kPluginBridgeOpcodeSetProgram = 5, + kPluginBridgeOpcodeSetMidiProgram = 6, + kPluginBridgeOpcodeProcess = 7, + kPluginBridgeOpcodeQuit = 8 }; +/*! + * @defgroup BridgeMessages Bridge Messages + * + * Various bridge related messages, used as configure(, value). + * \note This is for internal use only. + * + * TODO: Review these, may not be needed anymore + * @{ + */ +const char* const CARLA_BRIDGE_MSG_HIDE_GUI = "CarlaBridgeHideGUI"; //!< Plugin -> Host call, tells host GUI is now hidden +const char* const CARLA_BRIDGE_MSG_SAVED = "CarlaBridgeSaved"; //!< Plugin -> Host call, tells host state is saved +#if 0 +const char* const CARLA_BRIDGE_MSG_SAVE_NOW = "CarlaBridgeSaveNow"; //!< Host -> Plugin call, tells plugin to save state now +const char* const CARLA_BRIDGE_MSG_SET_CHUNK = "CarlaBridgeSetChunk"; //!< Host -> Plugin call, tells plugin to set chunk in file \a value +const char* const CARLA_BRIDGE_MSG_SET_CUSTOM = "CarlaBridgeSetCustom"; //!< Host -> Plugin call, tells plugin to set a custom data set using \a value ("type·key·rvalue"). +//If \a type is 'chunk' or 'binary' \a rvalue refers to chunk file. +#endif +/**@}*/ + /*! * TODO. */