Browse Source

CLAP midi output

pull/321/merge
falkTX 2 years ago
parent
commit
8d0269ee87
2 changed files with 22 additions and 2 deletions
  1. +21
    -2
      distrho/src/DistrhoPluginCLAP.cpp
  2. +1
    -0
      examples/MidiThrough/Makefile

+ 21
- 2
distrho/src/DistrhoPluginCLAP.cpp View File

@@ -565,6 +565,12 @@ public:
// ----------------------------------------------------------------------------------------------------------------
// core

template <class T>
const T* getHostExtension(const char* const extensionId) const
{
return static_cast<const T*>(fHost->get_extension(fHost, extensionId));
}

bool init()
{
if (!clap_version_is_compatible(fHost->clap_version))
@@ -1054,9 +1060,20 @@ private:
// DPF callbacks

#if DISTRHO_PLUGIN_WANT_MIDI_OUTPUT
bool writeMidi(const MidiEvent&)
bool writeMidi(const MidiEvent& midiEvent)
{
return true;
DISTRHO_SAFE_ASSERT_RETURN(fOutputEvents != nullptr, false);

if (midiEvent.size > 3)
return true;

const clap_event_midi clapEvent = {
{ sizeof(clap_event_midi), midiEvent.frame, 0, CLAP_EVENT_MIDI, CLAP_EVENT_IS_LIVE },
0, { midiEvent.data[0],
static_cast<uint8_t>(midiEvent.size >= 2 ? midiEvent.data[1] : 0),
static_cast<uint8_t>(midiEvent.size >= 3 ? midiEvent.data[2] : 0) }
};
return fOutputEvents->try_push(fOutputEvents, &clapEvent.header);
}

static bool writeMidiCallback(void* const ptr, const MidiEvent& midiEvent)
@@ -1294,6 +1311,8 @@ static bool clap_plugin_audio_ports_get(const clap_plugin_t* /* const plugin */,
return true;
#else
return false;
// unused
(void)info;
#endif
}



+ 1
- 0
examples/MidiThrough/Makefile View File

@@ -27,6 +27,7 @@ TARGETS += jack
TARGETS += lv2_dsp
TARGETS += vst2
TARGETS += vst3
TARGETS += clap

all: $(TARGETS)



Loading…
Cancel
Save