diff --git a/distrho/DistrhoInfo.hpp b/distrho/DistrhoInfo.hpp index c8b2ae31..5016f319 100644 --- a/distrho/DistrhoInfo.hpp +++ b/distrho/DistrhoInfo.hpp @@ -553,6 +553,12 @@ START_NAMESPACE_DISTRHO */ #define DISTRHO_PLUGIN_WANT_LATENCY 1 +/** + Whether the plugin wants MPE for MIDI input and/or output. + @note Only AU and CLAP formats implement this at the moment +*/ +#define DISTRHO_PLUGIN_WANT_MIDI_AS_MPE 0 + /** Whether the plugin wants MIDI input.@n This is automatically enabled if @ref DISTRHO_PLUGIN_IS_SYNTH is true. @@ -565,12 +571,6 @@ START_NAMESPACE_DISTRHO */ #define DISTRHO_PLUGIN_WANT_MIDI_OUTPUT 1 -/** - Whether the plugin uses MIDI MPE for MIDI input and MIDI output. - @note Only CLAP implements this macro at the moment -*/ -#define DISTRHO_PLUGIN_MIDI_MPE 0 - /** Whether the plugin wants to change its own parameter inputs.@n Not all hosts or plugin formats support this, diff --git a/distrho/src/DistrhoPluginAU.cpp b/distrho/src/DistrhoPluginAU.cpp index 96b90f78..c6ac59e5 100644 --- a/distrho/src/DistrhoPluginAU.cpp +++ b/distrho/src/DistrhoPluginAU.cpp @@ -686,6 +686,17 @@ class PluginAU outWritable = true; return noErr; + case kAudioUnitProperty_SupportsMPE: + DISTRHO_SAFE_ASSERT_UINT_RETURN(inScope == kAudioUnitScope_Global, inScope, kAudioUnitErr_InvalidScope); + DISTRHO_SAFE_ASSERT_UINT_RETURN(inElement == 0, inElement, kAudioUnitErr_InvalidElement); + #if DISTRHO_PLUGIN_WANT_MIDI_AS_MPE + outDataSize = sizeof(UInt32); + outWritable = false; + return noErr; + #else + return kAudioUnitErr_InvalidProperty; + #endif + case kAudioUnitProperty_CocoaUI: DISTRHO_SAFE_ASSERT_UINT_RETURN(inScope == kAudioUnitScope_Global, inScope, kAudioUnitErr_InvalidScope); DISTRHO_SAFE_ASSERT_UINT_RETURN(inElement == 0, inElement, kAudioUnitErr_InvalidElement); @@ -1055,6 +1066,12 @@ class PluginAU } return noErr; + #if DISTRHO_PLUGIN_WANT_MIDI_AS_MPE + case kAudioUnitProperty_SupportsMPE: + *static_cast(outData) = 1; + return noErr; + #endif + #if DISTRHO_PLUGIN_HAS_UI case kAudioUnitProperty_CocoaUI: { diff --git a/distrho/src/DistrhoPluginCLAP.cpp b/distrho/src/DistrhoPluginCLAP.cpp index f7e52847..81924ecd 100644 --- a/distrho/src/DistrhoPluginCLAP.cpp +++ b/distrho/src/DistrhoPluginCLAP.cpp @@ -67,12 +67,6 @@ # define DPF_CLAP_TIMER_INTERVAL 16 /* ~60 fps */ #endif -#if defined(DISTRHO_PLUGIN_MIDI_MPE) && DISTRHO_PLUGIN_MIDI_MPE -# define DPF_CLAP_NOTE_DIALECT CLAP_NOTE_DIALECT_MIDI_MPE -#else -# define DPF_CLAP_NOTE_DIALECT CLAP_NOTE_DIALECT_MIDI -#endif - START_NAMESPACE_DISTRHO // -------------------------------------------------------------------------------------------------------------------- @@ -2290,23 +2284,33 @@ static bool CLAP_ABI clap_plugin_note_ports_get(const clap_plugin_t*, uint32_t, { if (is_input) { - #if DISTRHO_PLUGIN_WANT_MIDI_INPUT + #if DISTRHO_PLUGIN_WANT_MIDI_INPUT info->id = 0; - info->supported_dialects = DPF_CLAP_NOTE_DIALECT; - info->preferred_dialect = DPF_CLAP_NOTE_DIALECT; + #if DISTRHO_PLUGIN_WANT_MIDI_AS_MPE + info->supported_dialects = CLAP_NOTE_DIALECT_MIDI | CLAP_NOTE_DIALECT_MIDI_MPE; + info->preferred_dialect = CLAP_NOTE_DIALECT_MIDI_MPE; + #else + info->supported_dialects = CLAP_NOTE_DIALECT_MIDI; + info->preferred_dialect = CLAP_NOTE_DIALECT_MIDI; + #endif std::strcpy(info->name, "Event/MIDI Input"); return true; - #endif + #endif } else { - #if DISTRHO_PLUGIN_WANT_MIDI_OUTPUT + #if DISTRHO_PLUGIN_WANT_MIDI_OUTPUT info->id = 0; - info->supported_dialects = DPF_CLAP_NOTE_DIALECT; - info->preferred_dialect = DPF_CLAP_NOTE_DIALECT; + #if DISTRHO_PLUGIN_WANT_MIDI_AS_MPE + info->supported_dialects = CLAP_NOTE_DIALECT_MIDI | CLAP_NOTE_DIALECT_MIDI_MPE; + info->preferred_dialect = CLAP_NOTE_DIALECT_MIDI_MPE; + #else + info->supported_dialects = CLAP_NOTE_DIALECT_MIDI; + info->preferred_dialect = CLAP_NOTE_DIALECT_MIDI; + #endif std::strcpy(info->name, "Event/MIDI Output"); return true; - #endif + #endif } return false; diff --git a/distrho/src/DistrhoPluginChecks.h b/distrho/src/DistrhoPluginChecks.h index fb05181b..a5349002 100644 --- a/distrho/src/DistrhoPluginChecks.h +++ b/distrho/src/DistrhoPluginChecks.h @@ -65,6 +65,10 @@ # define DISTRHO_PLUGIN_WANT_LATENCY 0 #endif +#ifndef DISTRHO_PLUGIN_WANT_MIDI_AS_MPE +# define DISTRHO_PLUGIN_WANT_MIDI_AS_MPE 0 +#endif + #ifndef DISTRHO_PLUGIN_WANT_MIDI_OUTPUT # define DISTRHO_PLUGIN_WANT_MIDI_OUTPUT 0 #endif @@ -178,6 +182,13 @@ # error Synths need audio output to work! #endif +// -------------------------------------------------------------------------------------------------------------------- +// Test if MIDI as MPE enabled where it doesn't make sense + +#if DISTRHO_PLUGIN_WANT_MIDI_AS_MPE && ! (DISTRHO_PLUGIN_WANT_MIDI_INPUT || DISTRHO_PLUGIN_WANT_MIDI_OUTPUT) +# error MIDI as MPE needs MIDI input or output to work! +#endif + // -------------------------------------------------------------------------------------------------------------------- // Enable MIDI input if synth, test if midi-input disabled when synth