free-audio / clap

Audio Plugin API
https://cleveraudio.org/
MIT License
1.76k stars 97 forks source link

Clap messaging: what's the difference? #267

Closed sadko4u closed 1 year ago

sadko4u commented 1 year ago

When I look at message types, it is pretty unclear for me, what's the difference between CLAP_EVENT_NOTE_ON, CLAP_EVENT_NOTE_OFF and CLAP_EVENT_MIDI and CLAP_EVENT_MIDI2 messages which also can be suitable for sending NOTE ON and NOTE OFF events.

What's the difference? When I will receive the MIDI NOTE ON event and when I will receive CLAP_EVENT_NOTE_ON?

What's the port_index field responsible for in event structures like clap_event_midi and clap_event_midi2?

I think it will be nice to have more details about the difference in the comments to the headers.

baconpaul commented 1 year ago

To answer your questions (but I agree we can expand these). A lot of it depends on https://github.com/free-audio/clap/blob/main/include/clap/ext/note-ports.h this extension.

  1. In the note ports extension you advertise the type of message you get. If you advertise that you are only MIDI1 you will not get CLAP_EVENT_NOTE_ON/OFF events (or should not). If you advertise a union of MIDI1, CLAP, MIDI2 then you must support them all and it is the hosts option on which to send. You can advertise if you want only CLAP note events. CLAP_EVENT_NOTE_etc have additional information that a MIDI1 note doesn't have for voice lifetime and the like, and also supports a CHOKE event.
  2. port_index is to allow plugins to advertise multiple logical note inbound ports. You issue them in the note_port extension. A DAW which allows multiple midi paths and plugin which consumes them would set this accordingly. -1 is the wildcard.
robbert-vdh commented 1 year ago

Also, give the event.h documentation a read for more details on what those events do: https://github.com/free-audio/clap/blob/main/include/clap/events.h

sadko4u commented 1 year ago

OK, now it's clear, thanks.