clap-wrapper icon indicating copy to clipboard operation
clap-wrapper copied to clipboard

Cannot get raw MIDI output (CLAP_EVENT_MIDI) to work

Open eon-42 opened this issue 4 months ago • 7 comments

I built a small CLAP test plugin that simply passes through the following midi events: note on/off, midi cc, channel aftertouch and pitchbend.

The CLAP plugin works fine in REAPER and Bitwig.

But no midi is sent out from the VST3 wrapped plugin when using CLAP_EVENT_MIDI events. Note on/off, however, does work if using CLAP_EVENT_NOTE_ON/OFF.

One note port is definied the the CLAP plugin, with supported_dialects set to "CLAP_NOTE_DIALECT_CLAP" and "CLAP_NOTE_DIALECT_MIDI", and preferred_dialect is set to "CLAP_NOTE_DIALECT_CLAP".

Plugin features are set to "CLAP_PLUGIN_FEATURE_INSTRUMENT" and "CLAP_PLUGIN_FEATURE_NOTE_EFFECT".

Question: Is there a specific setting in the VST3 wrapper that must be enabled to support CLAP_EVENT_MIDI for outgoing MIDI events? Or is something wrong with the port setup or plugin features?

Code to send CLAP_EVENT_MIDI events:

FillChar(event_midi, SizeOf(event_midi), 0);
event_midi.header.Size := SizeOf(event_midi);
event_midi.header.time := RawMidiData.Offset;
event_midi.header.space_id := CLAP_CORE_EVENT_SPACE_ID;
event_midi.header._type := CLAP_EVENT_MIDI;
event_midi.data[0] := RawMidiData.Byte0;
event_midi.data[1] := RawMidiData.Byte1;
event_midi.data[2] := RawMidiData.Byte2;
OutputEvents.try_push(OutputEvents, @event_midi);

Code to send CLAP_EVENT_NOTE_ON/OFF (and this works!):

FillChar(event_note, SizeOf(event_note), 0);
event_note.header.Size := SizeOf(event_note);
event_note.header.time := ClapNoteData.Offset;
event_note.header.space_id := CLAP_CORE_EVENT_SPACE_ID;
event_note.header._type := ClapNoteData.EventType;
event_note.note_id := ClapNoteData.NoteID;
event_note.port_index:= ClapNoteData.PortIndex;
event_note.channel := ClapNoteData.Channel;
event_note.key := ClapNoteData.Key;
event_note.velocity := ClapNoteData.Velocity;
OutputEvents.try_push(OutputEvents, @event_note);

Using Visual Studio Community 2022 to compile the VST3 wrapper.

eon-42 avatar Aug 10 '25 16:08 eon-42

Ugh ok sounds like that's a real implementation gap.

@defiantnerd - have you looked at this space? I think I looked at the auv2 but don't recall.

Thanks for the report @eon-42

baconpaul avatar Aug 10 '25 17:08 baconpaul

IIRC you need to declare an MIDI OUT port and this will pass those events to VST3 out.

Problem is, this never worked well in VST3 (as MIDI in general). Heavily depends on the host. STMG uses even a different, not very well documented, Module system.

defiantnerd avatar Aug 10 '25 19:08 defiantnerd

@eon-42 is your code for your test plugin up somewhere? That may help us

baconpaul avatar Aug 10 '25 21:08 baconpaul

@baconpaul

You can download it from https://codefn42.com/clap/claptest.zip.

This zip includes both the source code (Delphi!) and the compiled .clap and .vst3 files.

Note that this is a work-in-progress and far from complete.

However, the MIDI test functionality is quite simple.

In ClapBridge.pas, the "helper_my_plug_process_event" procedure (called from process) handles incoming MIDI events and sends them to the appropriate OnMidiXXX in ClapPluginBase.pas.

There, the data for outgoing MIDI events is prepared and added to FRawMidiOutputQueue, which is then dequeued by the HostSendEvents procedure (also called from process).

eon-42 avatar Aug 10 '25 22:08 eon-42

OK great .thanks. I'll add it to my list for this week to take a peek and maybe write a simple equivalent C++ test

baconpaul avatar Aug 11 '25 00:08 baconpaul

@baconpaul

I tested the wrapper with two additional CLAP MIDI plugins — in fact, the only two CLAP MIDI plugins I was able to locate — and in both cases, MIDI output from the VST3 plugin failed to function.

The two plugins are:

https://bonboa.com/products/bacara-plugin

and

https://audiomodern.com/shop/plugins/chordjam/

eon-42 avatar Aug 11 '25 17:08 eon-42

Right so sounds like this is just not working

Ok super clear! At least whatever we do for clap note we can do for 0x80 and 0x90

baconpaul avatar Aug 11 '25 19:08 baconpaul