diff --git a/distrho/src/DistrhoPluginCLAP.cpp b/distrho/src/DistrhoPluginCLAP.cpp index 29a0316d..9bd4f5f4 100644 --- a/distrho/src/DistrhoPluginCLAP.cpp +++ b/distrho/src/DistrhoPluginCLAP.cpp @@ -957,13 +957,13 @@ public: case CLAP_EVENT_NOTE_ON: #if DISTRHO_PLUGIN_WANT_MIDI_INPUT // BUG: even though we only report CLAP_NOTE_DIALECT_MIDI as supported, Bitwig sends us this anyway - addNoteEvent(static_cast(static_cast(event)), true); + addNoteEvent(reinterpret_cast(event), true); #endif break; case CLAP_EVENT_NOTE_OFF: #if DISTRHO_PLUGIN_WANT_MIDI_INPUT // BUG: even though we only report CLAP_NOTE_DIALECT_MIDI as supported, Bitwig sends us this anyway - addNoteEvent(static_cast(static_cast(event)), false); + addNoteEvent(reinterpret_cast(event), false); #endif break; case CLAP_EVENT_NOTE_CHOKE: @@ -971,9 +971,10 @@ public: case CLAP_EVENT_NOTE_EXPRESSION: break; case CLAP_EVENT_PARAM_VALUE: - DISTRHO_SAFE_ASSERT_UINT2_BREAK(event->size == sizeof(clap_event_param_value), - event->size, sizeof(clap_event_param_value)); - setParameterValueFromEvent(static_cast(static_cast(event))); + DISTRHO_SAFE_ASSERT_UINT2_BREAK(event->size == sizeof(clap_event_param_value_t), + event->size, sizeof(clap_event_param_value_t)); + if (event->space_id == 0) + setParameterValueFromEvent(reinterpret_cast(event)); break; case CLAP_EVENT_PARAM_MOD: case CLAP_EVENT_PARAM_GESTURE_BEGIN: @@ -984,7 +985,7 @@ public: DISTRHO_SAFE_ASSERT_UINT2_BREAK(event->size == sizeof(clap_event_midi_t), event->size, sizeof(clap_event_midi_t)); #if DISTRHO_PLUGIN_WANT_MIDI_INPUT - addMidiEvent(static_cast(static_cast(event))); + addMidiEvent(reinterpret_cast(event)); #endif break; case CLAP_EVENT_MIDI_SYSEX: @@ -1232,11 +1233,13 @@ public: if (event->type != CLAP_EVENT_PARAM_VALUE) continue; + if (event->space_id != 0) + continue; DISTRHO_SAFE_ASSERT_UINT2_BREAK(event->size == sizeof(clap_event_param_value), event->size, sizeof(clap_event_param_value)); - setParameterValueFromEvent(static_cast(static_cast(event))); + setParameterValueFromEvent(reinterpret_cast(event)); } } @@ -1504,7 +1507,7 @@ public: for (int32_t wrtntotal = 0, wrtn; wrtntotal < size; wrtntotal += wrtn) { - wrtn = stream->write(stream, buffer, size - wrtntotal); + wrtn = stream->write(stream, buffer + wrtntotal, size - wrtntotal); DISTRHO_SAFE_ASSERT_INT_RETURN(wrtn > 0, wrtn, false); } @@ -1517,6 +1520,7 @@ public: ClapUI* const ui = fUI.get(); #endif String key, value; + bool empty = true; bool hasValue = false; bool fillingKey = true; // if filling key or value char queryingType = 'i'; // can be 'n', 's' or 'p' (none, states, parameters) @@ -1524,14 +1528,15 @@ public: char buffer[512], orig; buffer[sizeof(buffer)-1] = '\xff'; - for (int32_t terminated = 0, read; terminated == 0;) + for (int32_t terminated = 0; terminated == 0;) { - read = stream->read(stream, buffer, sizeof(buffer)-1); + const int32_t read = stream->read(stream, buffer, sizeof(buffer)-1); DISTRHO_SAFE_ASSERT_INT_RETURN(read >= 0, read, false); if (read == 0) - return true; + return !empty; + empty = false; for (int32_t i = 0; i < read; ++i) { // found terminator, stop here @@ -2502,6 +2507,8 @@ static const clap_plugin_descriptor_t* CLAP_ABI clap_get_plugin_descriptor(const DISTRHO_PLUGIN_CLAP_FEATURES, #elif DISTRHO_PLUGIN_IS_SYNTH "instrument", + #else + "audio-effect", #endif nullptr }; @@ -2528,8 +2535,11 @@ static const clap_plugin_descriptor_t* CLAP_ABI clap_get_plugin_descriptor(const static const clap_plugin_t* CLAP_ABI clap_create_plugin(const clap_plugin_factory_t* const factory, const clap_host_t* const host, - const char*) + const char* const plugin_id) { + if (plugin_id == nullptr || std::strcmp(plugin_id, DISTRHO_PLUGIN_CLAP_ID) != 0) + return nullptr; + clap_plugin_t* const pluginptr = static_cast(std::malloc(sizeof(clap_plugin_t))); DISTRHO_SAFE_ASSERT_RETURN(pluginptr != nullptr, nullptr); diff --git a/distrho/src/DistrhoPluginVST3.cpp b/distrho/src/DistrhoPluginVST3.cpp index 0522ce1b..ae1a51dd 100644 --- a/distrho/src/DistrhoPluginVST3.cpp +++ b/distrho/src/DistrhoPluginVST3.cpp @@ -943,6 +943,7 @@ public: const bool connectedToUI = fConnectionFromCtrlToView != nullptr && fConnectedToUI; #endif String key, value; + bool empty = true; bool hasValue = false; bool fillingKey = true; // if filling key or value char queryingType = 'i'; // can be 'n', 's' or 'p' (none, states, parameters) @@ -959,7 +960,7 @@ public: DISTRHO_SAFE_ASSERT_INT_RETURN(read > 0, read, V3_INTERNAL_ERR); if (read == 0) - return V3_OK; + return empty ? V3_INVALID_ARG : V3_OK; for (int32_t i = 0; i < read; ++i) { @@ -1245,7 +1246,7 @@ public: for (int32_t wrtntotal = 0, wrtn; wrtntotal < size; wrtntotal += wrtn) { wrtn = 0; - res = v3_cpp_obj(stream)->write(stream, const_cast(buffer), size - wrtntotal, &wrtn); + res = v3_cpp_obj(stream)->write(stream, const_cast(buffer) + wrtntotal, size - wrtntotal, &wrtn); DISTRHO_SAFE_ASSERT_INT_RETURN(res == V3_OK, res, res); DISTRHO_SAFE_ASSERT_INT_RETURN(wrtn > 0, wrtn, V3_INTERNAL_ERR); diff --git a/examples/CVPort/Makefile b/examples/CVPort/Makefile index e1f01ff0..dba38a4f 100644 --- a/examples/CVPort/Makefile +++ b/examples/CVPort/Makefile @@ -23,7 +23,7 @@ include ../../Makefile.plugins.mk # -------------------------------------------------------------- # Enable all possible plugin types -TARGETS = jack lv2_dsp +TARGETS = jack lv2_sep all: $(TARGETS) diff --git a/examples/CairoUI/DistrhoPluginInfo.h b/examples/CairoUI/DistrhoPluginInfo.h index 6a332baa..fe9f2036 100644 --- a/examples/CairoUI/DistrhoPluginInfo.h +++ b/examples/CairoUI/DistrhoPluginInfo.h @@ -39,6 +39,12 @@ */ #define DISTRHO_PLUGIN_URI "http://distrho.sf.net/examples/CairoUI" +/** + The plugin id when exporting in CLAP format, in reverse URI form. + @note This macro is required when building CLAP plugins +*/ +#define DISTRHO_PLUGIN_CLAP_ID "studio.kx.distrho.examples.cairo-ui" + /** Wherever the plugin has a custom %UI. @see DISTRHO_UI_USE_NANOVG diff --git a/examples/CairoUI/Makefile b/examples/CairoUI/Makefile index 309654a4..4ecaa0bb 100644 --- a/examples/CairoUI/Makefile +++ b/examples/CairoUI/Makefile @@ -29,21 +29,11 @@ include ../../Makefile.plugins.mk # -------------------------------------------------------------- # Enable all possible plugin types -ifeq ($(HAVE_CAIRO),true) - -TARGETS += jack - -ifneq ($(MACOS_OR_WINDOWS),true) -ifeq ($(HAVE_LIBLO),true) +TARGETS += clap TARGETS += dssi -endif # HAVE_LIBLO -endif # MACOS_OR_WINDOWS - +TARGETS += jack TARGETS += lv2_sep TARGETS += vst2 -TARGETS += vst3 - -endif # HAVE_CAIRO all: $(TARGETS)