diff --git a/c++/carla-backend/carla_plugin.h b/c++/carla-backend/carla_plugin.h index 0b9e332..c6998a7 100644 --- a/c++/carla-backend/carla_plugin.h +++ b/c++/carla-backend/carla_plugin.h @@ -1568,7 +1568,7 @@ public: if (m_type == PLUGIN_DSSI) osc_send_program(&osc.data, midiprog.data[midiprog.current].bank, midiprog.data[midiprog.current].program); else - osc_send_midi_program(&osc.data, midiprog.current); + osc_send_midi_program(&osc.data, midiprog.data[midiprog.current].bank, midiprog.data[midiprog.current].program); } for (uint32_t i=0; i < param.count; i++) diff --git a/c++/carla-backend/lv2.cpp b/c++/carla-backend/lv2.cpp index 331e046..cc97364 100644 --- a/c++/carla-backend/lv2.cpp +++ b/c++/carla-backend/lv2.cpp @@ -2562,7 +2562,7 @@ public: if (gui.type == GUI_EXTERNAL_OSC) { if (osc.data.target) - osc_send_program(&osc.data, midiprog.data[index].bank, midiprog.data[index].program); + osc_send_midi_program(&osc.data, midiprog.data[index].bank, midiprog.data[index].program); } else #endif diff --git a/c++/carla-bridge/carla_bridge.h b/c++/carla-bridge/carla_bridge.h index cc98838..0000e1c 100644 --- a/c++/carla-bridge/carla_bridge.h +++ b/c++/carla-bridge/carla_bridge.h @@ -40,7 +40,7 @@ enum MessageType { MESSAGE_NULL = 0, MESSAGE_PARAMETER, // index, 0, value MESSAGE_PROGRAM, // index, 0, 0 - MESSAGE_MIDI_PROGRAM, // bank, program, 0 + MESSAGE_MIDI_PROGRAM, // index, 0, 0 | bank, program, 0 MESSAGE_NOTE_ON, // note, velocity, 0 MESSAGE_NOTE_OFF, // note, 0, 0 MESSAGE_SHOW_GUI, // show, 0, 0 diff --git a/c++/carla-bridge/carla_bridge_client.h b/c++/carla-bridge/carla_bridge_client.h index f99d9b7..26dc850 100644 --- a/c++/carla-bridge/carla_bridge_client.h +++ b/c++/carla-bridge/carla_bridge_client.h @@ -110,7 +110,11 @@ public: break; case MESSAGE_MIDI_PROGRAM: +#ifdef BUILD_BRIDGE_PLUGIN + setMidiProgram(m->value1); +#else setMidiProgram(m->value1, m->value2); +#endif break; case MESSAGE_NOTE_ON: @@ -165,7 +169,11 @@ public: // processing virtual void setParameter(const int32_t rindex, const double value) = 0; virtual void setProgram(const uint32_t index) = 0; +#ifdef BUILD_BRIDGE_PLUGIN + 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; diff --git a/c++/carla-bridge/carla_bridge_osc.cpp b/c++/carla-bridge/carla_bridge_osc.cpp index 8611d6d..5e1c98b 100644 --- a/c++/carla-bridge/carla_bridge_osc.cpp +++ b/c++/carla-bridge/carla_bridge_osc.cpp @@ -261,7 +261,7 @@ int CarlaOsc::handleMsgMidiProgram(CARLA_BRIDGE_OSC_HANDLE_ARGS) #ifdef BUILD_BRIDGE_PLUGIN const int32_t index = argv[0]->i; - client->quequeMessage(MESSAGE_MIDI_PROGRAM, index, -1, 0.0); + client->quequeMessage(MESSAGE_MIDI_PROGRAM, index, 0, 0.0); #else const int32_t bank = argv[0]->i; const int32_t program = argv[1]->i; diff --git a/c++/carla-bridge/carla_bridge_plugin.cpp b/c++/carla-bridge/carla_bridge_plugin.cpp index 2d290ff..88ef8be 100644 --- a/c++/carla-bridge/carla_bridge_plugin.cpp +++ b/c++/carla-bridge/carla_bridge_plugin.cpp @@ -137,17 +137,14 @@ public: } } - void setMidiProgram(const uint32_t index, const uint32_t test) + void setMidiProgram(const uint32_t index) { - qDebug("CarlaPluginClient::setMidiProgram(%i, %i)", index, test); + qDebug("CarlaPluginClient::setMidiProgram(%i)", index); Q_ASSERT(engine); Q_ASSERT(plugin); - Q_ASSERT(test == -1); if (! (plugin && engine)) return; - if (test != -1) - return; plugin->setMidiProgram(index, true, true, false, true); diff --git a/c++/carla-bridge/carla_bridge_ui-lv2.cpp b/c++/carla-bridge/carla_bridge_ui-lv2.cpp index 8c17b01..4f0f161 100644 --- a/c++/carla-bridge/carla_bridge_ui-lv2.cpp +++ b/c++/carla-bridge/carla_bridge_ui-lv2.cpp @@ -327,10 +327,36 @@ public: libClose(); } + // --------------------------------------------------------------------- + // ui management + + void* getWidget() const + { +#ifdef BRIDGE_LV2_X11 + return x11_widget; +#else + return widget; +#endif + } + + bool isResizable() const + { + return m_resizable; + } + + bool needsReparent() const + { +#ifdef BRIDGE_LV2_X11 + return true; +#else + return false; +#endif + } + // --------------------------------------------------------------------- // processing - void setParameter(int32_t rindex, double value) + void setParameter(const int32_t rindex, const double value) { Q_ASSERT(handle && descriptor); @@ -341,11 +367,11 @@ public: } } - void setProgram(uint32_t) + void setProgram(const uint32_t) { } - void setMidiProgram(uint32_t bank, uint32_t program) + void setMidiProgram(const uint32_t bank, const uint32_t program) { Q_ASSERT(handle); @@ -375,32 +401,6 @@ public: } } - // --------------------------------------------------------------------- - // gui - - void* getWidget() const - { -#ifdef BRIDGE_LV2_X11 - return x11_widget; -#else - return widget; -#endif - } - - bool isResizable() const - { - return m_resizable; - } - - bool needsReparent() const - { -#ifdef BRIDGE_LV2_X11 - return true; -#else - return false; -#endif - } - // --------------------------------------------------------------------- uint32_t getCustomURID(const char* const uri) diff --git a/c++/carla-bridge/carla_bridge_ui-vst.cpp b/c++/carla-bridge/carla_bridge_ui-vst.cpp index abf504d..5a9083b 100644 --- a/c++/carla-bridge/carla_bridge_ui-vst.cpp +++ b/c++/carla-bridge/carla_bridge_ui-vst.cpp @@ -145,6 +145,24 @@ public: } } + // --------------------------------------------------------------------- + // ui management + + void* getWidget() const + { + return widget; + } + + bool isResizable() const + { + return false; + } + + bool needsReparent() const + { + return true; + } + // --------------------------------------------------------------------- // processing @@ -172,24 +190,6 @@ public: { } - // --------------------------------------------------------------------- - // gui - - void* getWidget() const - { - return widget; - } - - bool isResizable() const - { - return false; - } - - bool needsReparent() const - { - return true; - } - // --------------------------------------------------------------------- void handleAudioMasterAutomate(const uint32_t index, const float value) diff --git a/c++/carla-includes/carla_osc_includes.h b/c++/carla-includes/carla_osc_includes.h index 1cb54d5..867a8f4 100644 --- a/c++/carla-includes/carla_osc_includes.h +++ b/c++/carla-includes/carla_osc_includes.h @@ -134,6 +134,23 @@ void osc_send_midi_program(const CarlaOscData* const oscData, const int32_t inde } } +static inline +void osc_send_midi_program(const CarlaOscData* const oscData, const int32_t bank, const int32_t program) +{ + Q_ASSERT(oscData && oscData->path); + Q_ASSERT(program >= 0 && program < 128); + Q_ASSERT(bank >= 0); + qDebug("osc_send_midi_program(path:\"%s\", %i, %i)", oscData->path, bank, program); + + if (oscData->target) + { + char targetPath[strlen(oscData->path)+14]; + strcpy(targetPath, oscData->path); + strcat(targetPath, "/midi_program"); + lo_send(oscData->target, targetPath, "ii", bank, program); + } +} + static inline void osc_send_midi(const CarlaOscData* const oscData, const uint8_t buf[4]) { diff --git a/src/shared_carla.py b/src/shared_carla.py index 0633eaf..001fc8f 100644 --- a/src/shared_carla.py +++ b/src/shared_carla.py @@ -1667,7 +1667,7 @@ class PluginWidget(QFrame, ui_carla_plugin.Ui_PluginWidget): def loadStateDict(self, content): # --------------------------------------------------------------------- - # Part 1 - set custom data (non-binary/chunks) + # Part 1 - set custom data (except binary/chunks) for customData in content['CustomData']: if customData['type'] not in (CUSTOM_DATA_BINARY, CUSTOM_DATA_CHUNK):