Skip to content

Commit

Permalink
Implement outbound CLAP_EVENT_NOTE_* from wrapped plugins (#104)
Browse files Browse the repository at this point in the history
* Implement outbound CLAP_EVENT_NOTE_* from wrapped plugins

Push them as kNoteOn/Off events onto the result bus.
  • Loading branch information
baconpaul authored Sep 7, 2023
1 parent 3524ccc commit f7a55fd
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/detail/vst3/categories.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ static const struct _translate
// CLAP main categories
{ CLAP_PLUGIN_FEATURE_INSTRUMENT , PlugType::kInstrument },
{ CLAP_PLUGIN_FEATURE_AUDIO_EFFECT , PlugType::kFx},
{ CLAP_PLUGIN_FEATURE_NOTE_EFFECT , PlugType::kInstrumentSynth}, // it seems there is no type for a sequencer etc
{ CLAP_PLUGIN_FEATURE_DRUM , PlugType::kInstrumentDrum},
{ CLAP_PLUGIN_FEATURE_ANALYZER , PlugType::kAnalyzer},

Expand Down
36 changes: 36 additions & 0 deletions src/detail/vst3/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,43 @@ namespace Clap
switch (event->type)
{
case CLAP_EVENT_NOTE_ON:
{
auto nevt = reinterpret_cast<const clap_event_note *>(event);

Steinberg::Vst::Event oe{};
oe.type = Steinberg::Vst::Event::kNoteOnEvent;
oe.noteOn.channel = nevt->channel;
oe.noteOn.pitch = nevt->key;
oe.noteOn.velocity = nevt->velocity;
oe.noteOn.length = 0;
oe.noteOn.tuning = 0.0f;
oe.noteOn.noteId = nevt->note_id;
oe.busIndex = 0; // FIXME - multi-out midi still needs work
oe.sampleOffset = nevt->header.time;

if (_vstdata && _vstdata->outputEvents)
_vstdata->outputEvents->addEvent(oe);
}
return true;
case CLAP_EVENT_NOTE_OFF:
{
auto nevt = reinterpret_cast<const clap_event_note *>(event);

Steinberg::Vst::Event oe{};
oe.type = Steinberg::Vst::Event::kNoteOffEvent;
oe.noteOff.channel = nevt->channel;
oe.noteOff.pitch = nevt->key;
oe.noteOff.velocity = nevt->velocity;
oe.noteOn.length = 0;
oe.noteOff.tuning = 0.0f;
oe.noteOff.noteId = nevt->note_id;
oe.busIndex = 0; // FIXME - multi-out midi still needs work
oe.sampleOffset = nevt->header.time;


if (_vstdata && _vstdata->outputEvents)
_vstdata->outputEvents->addEvent(oe);
}
return true;
case CLAP_EVENT_NOTE_END:
case CLAP_EVENT_NOTE_CHOKE:
Expand Down
4 changes: 4 additions & 0 deletions src/wrapasvst3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,10 @@ void ClapAsVst3::addMIDIBusFrom(const clap_note_port_info_t* info, uint32_t inde
{
addEventInput(name16, numchannels, Vst::BusTypes::kMain, Vst::BusInfo::kDefaultActive);
}
else
{
addEventOutput(name16, numchannels, Vst::BusTypes::kMain, Vst::BusInfo::kDefaultActive);
}
}
}

Expand Down

0 comments on commit f7a55fd

Please sign in to comment.