Skip to content

Commit

Permalink
Rename to DISTRHO_PLUGIN_WANT_MIDI_AS_MPE, implement in AU too
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <[email protected]>
  • Loading branch information
falkTX committed Dec 14, 2024
1 parent 2b3e67a commit 32d911c
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 20 deletions.
12 changes: 6 additions & 6 deletions distrho/DistrhoInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand Down
17 changes: 17 additions & 0 deletions distrho/src/DistrhoPluginAU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -1055,6 +1066,12 @@ class PluginAU
}
return noErr;

#if DISTRHO_PLUGIN_WANT_MIDI_AS_MPE
case kAudioUnitProperty_SupportsMPE:
*static_cast<UInt32*>(outData) = 1;
return noErr;
#endif

#if DISTRHO_PLUGIN_HAS_UI
case kAudioUnitProperty_CocoaUI:
{
Expand Down
32 changes: 18 additions & 14 deletions distrho/src/DistrhoPluginCLAP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

// --------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions distrho/src/DistrhoPluginChecks.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 32d911c

Please sign in to comment.