From fd88a72c3712edeaaf560559ba4f79480deed023 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Sat, 7 Oct 2023 23:28:55 +0200 Subject: [PATCH 01/11] midi-info.h --- include/clap/ext/draft/midi-info.h | 84 ++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 include/clap/ext/draft/midi-info.h diff --git a/include/clap/ext/draft/midi-info.h b/include/clap/ext/draft/midi-info.h new file mode 100644 index 00000000..da3f8857 --- /dev/null +++ b/include/clap/ext/draft/midi-info.h @@ -0,0 +1,84 @@ +#pragma once + +#include "../../plugin.h" + +// This extension lets a plugin expose it's MIDI implementation. +// The primary goal is to allow a host to create a MIDI-CI Property Exchange "ChCtrlList" resource for the plugin, +// so keyboard controllers can assign their knobs to suitable controllers. + +//TODO : clap_midiinfo could contain more (optional) info (min/max, stepcount, paramPath etc.) +//TODO : for completeness this should work per-input port. Is that worth it? + +static CLAP_CONSTEXPR const char CLAP_EXT_MIDIINFO[] = "clap.midi-info.draft/0"; + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + //MIDI 2.0 message status + CLAP_MIDIINFO_STATUS_REGISTERED_PER_NOTE_CONTROLLER = 0x00, + CLAP_MIDIINFO_STATUS_ASSIGNABLE_PER_NOTE_CONTROLLER = 0x10, + CLAP_MIDIINFO_STATUS_RPN = 0x20, + CLAP_MIDIINFO_STATUS_NRPN = 0x30, + CLAP_MIDIINFO_STATUS_PER_NOTE_PITCHBEND = 0x60, + CLAP_MIDIINFO_STATUS_POLY_AFTERTOUCH = 0xA0, + CLAP_MIDIINFO_STATUS_CONTROLLER = 0xB0, + CLAP_MIDIINFO_STATUS_CHANNEL_AFTERTOUCH = 0xD0, + CLAP_MIDIINFO_STATUS_PITCHBEND = 0xE0, + + //CLAP note expressions. + //A host may map MIDI messages to note expressions, so it needs to know which note expressions are supported. + CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_VOLUME = 0x100, + CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_PAN = 0x101, + CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_TUNING = 0x102, + CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_VIBRATO = 0x103, + CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_EXPRESSION = 0x104, + CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_BRIGHTNESS = 0x105, + CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_PRESSURE = 0x106 +}; + +/* This describes a MIDI control/message */ +typedef struct clap_midiinfo { + //CLAP_MIDIINFO_STATUS, describes what kind of control this struct is about. + status: uint32_t; + + //controller number, nrpn number etc. + //zero if not applicable the status value + number: uint32_t; + + //Display name + //If name is empty the host can assume the standard MIDI name + char name[CLAP_NAME_SIZE]; +} clap_midiinfo_t; + +typedef struct clap_plugin_midiinfo { + // Returns the number of clap_midiinfo structs for a channel. + // channel is 0..15 + // [main-thread] + uint32_t(CLAP_ABI *count)(const clap_plugin_t *plugin, + uint32_t channel); + + // Fills midiinfo. Returns true on success. + // Important: the most important controls (from a performing musician's point of view) should be listed first, + // so the host can make sure these appear on a controller keyboard. + // [main-thread] + bool(CLAP_ABI *get_info)(const clap_plugin_t *plugin, + uint32_t channel, + uint32_t index, + clap_param_info_t *midiinfo); + + //if false all channels are the same, so the host doesn't have to scan them all. + bool(CLAP_ABI *multitimbral)(const clap_plugin_t *plugin); +} clap_plugin_midiinfo_t; + +typedef struct clap_host_midiinfo { + // Rescan the full list of structs. + // This can happen if an instrument switches to a different patch, for example. + // [main-thread] + void(CLAP_ABI *rescan)(const clap_host_t *host); +} clap_host_midiinfo_t; + +#ifdef __cplusplus +} +#endif \ No newline at end of file From 7cba1090bf871bd3e3b0aaa5d5c902c04e457464 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Mon, 9 Oct 2023 16:10:23 +0200 Subject: [PATCH 02/11] a few updates --- midi-info.h | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 midi-info.h diff --git a/midi-info.h b/midi-info.h new file mode 100644 index 00000000..f280ba12 --- /dev/null +++ b/midi-info.h @@ -0,0 +1,84 @@ +#pragma once + +#include "../../plugin.h" + +// This extension lets a plugin expose it's MIDI implementation. +// The primary goal is to allow a host to create a MIDI-CI Property Exchange "ChCtrlList" resource for the plugin, +// so keyboard controllers can assign their knobs to suitable controllers. + +//TODO : clap_midiinfo could contain more (optional) info (min/max, stepcount, paramPath etc.) +//TODO : for completeness this should work per-input port. Is that worth it? + +static CLAP_CONSTEXPR const char CLAP_EXT_MIDIINFO[] = "clap.midi-info.draft/0"; + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + //MIDI 2.0 message status + CLAP_MIDIINFO_STATUS_REGISTERED_PER_NOTE_CONTROLLER = 0x00, + CLAP_MIDIINFO_STATUS_ASSIGNABLE_PER_NOTE_CONTROLLER = 0x10, + CLAP_MIDIINFO_STATUS_RPN = 0x20, + CLAP_MIDIINFO_STATUS_NRPN = 0x30, + CLAP_MIDIINFO_STATUS_PER_NOTE_PITCHBEND = 0x60, + CLAP_MIDIINFO_STATUS_POLY_AFTERTOUCH = 0xA0, + CLAP_MIDIINFO_STATUS_CONTROLLER = 0xB0, + CLAP_MIDIINFO_STATUS_CHANNEL_AFTERTOUCH = 0xD0, + CLAP_MIDIINFO_STATUS_PITCHBEND = 0xE0, + + //CLAP note expressions. + //A host may map MIDI messages to note expressions, so it needs to know which note expressions are supported. + CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_VOLUME = 0x100, + CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_PAN = 0x101, + CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_TUNING = 0x102, + CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_VIBRATO = 0x103, + CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_EXPRESSION = 0x104, + CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_BRIGHTNESS = 0x105, + CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_PRESSURE = 0x106 +}; + +/* This describes a MIDI control/message */ +typedef struct clap_midiinfo { + //CLAP_MIDIINFO_STATUS, describes what kind of control this struct is about. + uint32_t status; + + //controller number, nrpn number etc. + //zero if not applicable the status value + uint32_t number; + + //Display name + //If name is empty the host can assume default MIDI controller names (cc7 is Volume etc.) + char name[CLAP_NAME_SIZE]; +} clap_midiinfo_t; + +typedef struct clap_plugin_midiinfo { + // Returns the number of clap_midiinfo structs for a channel. + // channel is 0..15 + // [main-thread] + uint32_t(CLAP_ABI *count)(const clap_plugin_t *plugin, + uint32_t channel); + + // Fills midiinfo. Returns true on success. + // Important: the most important controls (from a performing musician's point of view) should be listed first, + // so the host can make sure these appear on a controller keyboard. + // [main-thread] + bool(CLAP_ABI *get_info)(const clap_plugin_t *plugin, + uint32_t channel, + uint32_t index, + clap_param_info_t *midiinfo); + + //if false all channels are the same, so the host doesn't have to scan them all. + bool(CLAP_ABI *multitimbral)(const clap_plugin_t *plugin); +} clap_plugin_midiinfo_t; + +typedef struct clap_host_midiinfo { + // Rescan the full list of structs. + // This can happen if an instrument switches to a different patch, for example. + // [main-thread] + void(CLAP_ABI *rescan)(const clap_host_t *host); +} clap_host_midiinfo_t; + +#ifdef __cplusplus +} +#endif \ No newline at end of file From f4c261c8eaf3106c3e7c5bfb6131b322050e20c3 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Mon, 9 Oct 2023 16:17:17 +0200 Subject: [PATCH 03/11] Delete midi-info.h --- midi-info.h | 84 ----------------------------------------------------- 1 file changed, 84 deletions(-) delete mode 100644 midi-info.h diff --git a/midi-info.h b/midi-info.h deleted file mode 100644 index f280ba12..00000000 --- a/midi-info.h +++ /dev/null @@ -1,84 +0,0 @@ -#pragma once - -#include "../../plugin.h" - -// This extension lets a plugin expose it's MIDI implementation. -// The primary goal is to allow a host to create a MIDI-CI Property Exchange "ChCtrlList" resource for the plugin, -// so keyboard controllers can assign their knobs to suitable controllers. - -//TODO : clap_midiinfo could contain more (optional) info (min/max, stepcount, paramPath etc.) -//TODO : for completeness this should work per-input port. Is that worth it? - -static CLAP_CONSTEXPR const char CLAP_EXT_MIDIINFO[] = "clap.midi-info.draft/0"; - -#ifdef __cplusplus -extern "C" { -#endif - -enum { - //MIDI 2.0 message status - CLAP_MIDIINFO_STATUS_REGISTERED_PER_NOTE_CONTROLLER = 0x00, - CLAP_MIDIINFO_STATUS_ASSIGNABLE_PER_NOTE_CONTROLLER = 0x10, - CLAP_MIDIINFO_STATUS_RPN = 0x20, - CLAP_MIDIINFO_STATUS_NRPN = 0x30, - CLAP_MIDIINFO_STATUS_PER_NOTE_PITCHBEND = 0x60, - CLAP_MIDIINFO_STATUS_POLY_AFTERTOUCH = 0xA0, - CLAP_MIDIINFO_STATUS_CONTROLLER = 0xB0, - CLAP_MIDIINFO_STATUS_CHANNEL_AFTERTOUCH = 0xD0, - CLAP_MIDIINFO_STATUS_PITCHBEND = 0xE0, - - //CLAP note expressions. - //A host may map MIDI messages to note expressions, so it needs to know which note expressions are supported. - CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_VOLUME = 0x100, - CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_PAN = 0x101, - CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_TUNING = 0x102, - CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_VIBRATO = 0x103, - CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_EXPRESSION = 0x104, - CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_BRIGHTNESS = 0x105, - CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_PRESSURE = 0x106 -}; - -/* This describes a MIDI control/message */ -typedef struct clap_midiinfo { - //CLAP_MIDIINFO_STATUS, describes what kind of control this struct is about. - uint32_t status; - - //controller number, nrpn number etc. - //zero if not applicable the status value - uint32_t number; - - //Display name - //If name is empty the host can assume default MIDI controller names (cc7 is Volume etc.) - char name[CLAP_NAME_SIZE]; -} clap_midiinfo_t; - -typedef struct clap_plugin_midiinfo { - // Returns the number of clap_midiinfo structs for a channel. - // channel is 0..15 - // [main-thread] - uint32_t(CLAP_ABI *count)(const clap_plugin_t *plugin, - uint32_t channel); - - // Fills midiinfo. Returns true on success. - // Important: the most important controls (from a performing musician's point of view) should be listed first, - // so the host can make sure these appear on a controller keyboard. - // [main-thread] - bool(CLAP_ABI *get_info)(const clap_plugin_t *plugin, - uint32_t channel, - uint32_t index, - clap_param_info_t *midiinfo); - - //if false all channels are the same, so the host doesn't have to scan them all. - bool(CLAP_ABI *multitimbral)(const clap_plugin_t *plugin); -} clap_plugin_midiinfo_t; - -typedef struct clap_host_midiinfo { - // Rescan the full list of structs. - // This can happen if an instrument switches to a different patch, for example. - // [main-thread] - void(CLAP_ABI *rescan)(const clap_host_t *host); -} clap_host_midiinfo_t; - -#ifdef __cplusplus -} -#endif \ No newline at end of file From 87af3eecd53d2414b7fe348d39eefedec411b1bc Mon Sep 17 00:00:00 2001 From: Bremmers Date: Mon, 9 Oct 2023 16:18:20 +0200 Subject: [PATCH 04/11] a few updates --- include/clap/ext/draft/midi-info.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/clap/ext/draft/midi-info.h b/include/clap/ext/draft/midi-info.h index da3f8857..f280ba12 100644 --- a/include/clap/ext/draft/midi-info.h +++ b/include/clap/ext/draft/midi-info.h @@ -41,14 +41,14 @@ enum { /* This describes a MIDI control/message */ typedef struct clap_midiinfo { //CLAP_MIDIINFO_STATUS, describes what kind of control this struct is about. - status: uint32_t; + uint32_t status; //controller number, nrpn number etc. //zero if not applicable the status value - number: uint32_t; + uint32_t number; //Display name - //If name is empty the host can assume the standard MIDI name + //If name is empty the host can assume default MIDI controller names (cc7 is Volume etc.) char name[CLAP_NAME_SIZE]; } clap_midiinfo_t; From f77f0ae7abfd2807a1d2d717f17299088288969a Mon Sep 17 00:00:00 2001 From: Bremmers Date: Mon, 9 Oct 2023 16:54:48 +0200 Subject: [PATCH 05/11] added ports, and more --- include/clap/ext/draft/midi-info.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/include/clap/ext/draft/midi-info.h b/include/clap/ext/draft/midi-info.h index f280ba12..4707fd36 100644 --- a/include/clap/ext/draft/midi-info.h +++ b/include/clap/ext/draft/midi-info.h @@ -5,9 +5,9 @@ // This extension lets a plugin expose it's MIDI implementation. // The primary goal is to allow a host to create a MIDI-CI Property Exchange "ChCtrlList" resource for the plugin, // so keyboard controllers can assign their knobs to suitable controllers. +// Also, hosts can use it to indicate to users which controls actually work. //TODO : clap_midiinfo could contain more (optional) info (min/max, stepcount, paramPath etc.) -//TODO : for completeness this should work per-input port. Is that worth it? static CLAP_CONSTEXPR const char CLAP_EXT_MIDIINFO[] = "clap.midi-info.draft/0"; @@ -57,26 +57,31 @@ typedef struct clap_plugin_midiinfo { // channel is 0..15 // [main-thread] uint32_t(CLAP_ABI *count)(const clap_plugin_t *plugin, - uint32_t channel); + int16_t port_index, + uint16_t channel); // Fills midiinfo. Returns true on success. // Important: the most important controls (from a performing musician's point of view) should be listed first, // so the host can make sure these appear on a controller keyboard. // [main-thread] bool(CLAP_ABI *get_info)(const clap_plugin_t *plugin, - uint32_t channel, + int16_t port_index, + uint16_t channel, uint32_t index, clap_param_info_t *midiinfo); //if false all channels are the same, so the host doesn't have to scan them all. - bool(CLAP_ABI *multitimbral)(const clap_plugin_t *plugin); + bool(CLAP_ABI *is_multitimbral)(const clap_plugin_t *plugin, + int16_t port_index); } clap_plugin_midiinfo_t; typedef struct clap_host_midiinfo { // Rescan the full list of structs. // This can happen if an instrument switches to a different patch, for example. + // port_index = -1 means 'all ports' // [main-thread] - void(CLAP_ABI *rescan)(const clap_host_t *host); + void(CLAP_ABI *changed)(const clap_host_t *host, + int16_t port_index); } clap_host_midiinfo_t; #ifdef __cplusplus From 8751dd5ebd182c008ed1d8955c20c6b91f3ec83a Mon Sep 17 00:00:00 2001 From: Bremmers Date: Tue, 10 Oct 2023 11:02:55 +0200 Subject: [PATCH 06/11] added 'priority', some tweaks --- include/clap/ext/draft/midi-info.h | 35 +++++++++++++++++------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/include/clap/ext/draft/midi-info.h b/include/clap/ext/draft/midi-info.h index 4707fd36..0fc56f43 100644 --- a/include/clap/ext/draft/midi-info.h +++ b/include/clap/ext/draft/midi-info.h @@ -2,12 +2,13 @@ #include "../../plugin.h" -// This extension lets a plugin expose it's MIDI implementation. +// This extension lets a plugin expose its MIDI implementation. // The primary goal is to allow a host to create a MIDI-CI Property Exchange "ChCtrlList" resource for the plugin, -// so keyboard controllers can assign their knobs to suitable controllers. -// Also, hosts can use it to indicate to users which controls actually work. +// which is presented to a keyboard / controller. +// A keyboard can then assign its knobs to suitable controllers, decide between sending poly or channel afertouch etc. +// Also, hosts can use this extension to indicate to users which controls actually work. -//TODO : clap_midiinfo could contain more (optional) info (min/max, stepcount, paramPath etc.) +// TODO : clap_midiinfo could/should contain more (optional) info (min/max, stepcount, paramPath etc.) static CLAP_CONSTEXPR const char CLAP_EXT_MIDIINFO[] = "clap.midi-info.draft/0"; @@ -16,7 +17,7 @@ extern "C" { #endif enum { - //MIDI 2.0 message status + // MIDI 2.0 message status CLAP_MIDIINFO_STATUS_REGISTERED_PER_NOTE_CONTROLLER = 0x00, CLAP_MIDIINFO_STATUS_ASSIGNABLE_PER_NOTE_CONTROLLER = 0x10, CLAP_MIDIINFO_STATUS_RPN = 0x20, @@ -27,8 +28,8 @@ enum { CLAP_MIDIINFO_STATUS_CHANNEL_AFTERTOUCH = 0xD0, CLAP_MIDIINFO_STATUS_PITCHBEND = 0xE0, - //CLAP note expressions. - //A host may map MIDI messages to note expressions, so it needs to know which note expressions are supported. + // CLAP note expressions. + // A host may map MIDI messages to note expressions, so it needs to know which note expressions are supported. CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_VOLUME = 0x100, CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_PAN = 0x101, CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_TUNING = 0x102, @@ -40,15 +41,21 @@ enum { /* This describes a MIDI control/message */ typedef struct clap_midiinfo { - //CLAP_MIDIINFO_STATUS, describes what kind of control this struct is about. + // CLAP_MIDIINFO_STATUS, describes what kind of control this struct is about. uint32_t status; - //controller number, nrpn number etc. - //zero if not applicable the status value + // controller number, nrpn number etc. + // zero if not applicable the status value uint32_t number; - //Display name - //If name is empty the host can assume default MIDI controller names (cc7 is Volume etc.) + // Priority of this control (from a performing musician's point of view) + // 1..5, a value of 1 is the most important, descending down to 5 as the least important. + // Multiple controls can have the same priority. In this case the control at the lowest index + // (see clap_plugin_midiinfo.get_info) is more important than the next ones. + uint32_t priority; + + // Display name + // If name is empty the host can assume default MIDI controller names (cc7 is Volume etc.) char name[CLAP_NAME_SIZE]; } clap_midiinfo_t; @@ -61,8 +68,6 @@ typedef struct clap_plugin_midiinfo { uint16_t channel); // Fills midiinfo. Returns true on success. - // Important: the most important controls (from a performing musician's point of view) should be listed first, - // so the host can make sure these appear on a controller keyboard. // [main-thread] bool(CLAP_ABI *get_info)(const clap_plugin_t *plugin, int16_t port_index, @@ -81,7 +86,7 @@ typedef struct clap_host_midiinfo { // port_index = -1 means 'all ports' // [main-thread] void(CLAP_ABI *changed)(const clap_host_t *host, - int16_t port_index); + int16_t port_index); } clap_host_midiinfo_t; #ifdef __cplusplus From 9a223a79cebfa51e50b53bc4dd884f12c2eaa5a3 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Thu, 12 Oct 2023 13:32:12 +0200 Subject: [PATCH 07/11] renamed to midi-controls, removed note expressions --- include/clap/ext/draft/midi-controls.h | 85 ++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 include/clap/ext/draft/midi-controls.h diff --git a/include/clap/ext/draft/midi-controls.h b/include/clap/ext/draft/midi-controls.h new file mode 100644 index 00000000..c942ed5a --- /dev/null +++ b/include/clap/ext/draft/midi-controls.h @@ -0,0 +1,85 @@ +#pragma once + +#include "../../plugin.h" + +// This extension lets a plugin expose its MIDI control implementation. +// The primary goal is to allow a host to create a MIDI-CI Property Exchange "ChCtrlList" resource for the plugin, +// which is presented to a keyboard / controller. +// A keyboard can then assign its knobs to suitable controllers, decide between sending poly or channel afertouch etc. +// Also, hosts can use this extension to indicate to users which controls actually work, and display proper names. + +// TODO : clap_midi_control_info could/should contain more (optional) info (min/max, stepcount, paramPath etc.) + +static CLAP_CONSTEXPR const char CLAP_EXT_MIDI_CONTROLS[] = "clap.midi-controls.draft/0"; + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + // MIDI voice channel message status + CLAP_MIDI_CONTROL_STATUS_REGISTERED_PER_NOTE_CONTROLLER = 0x00, + CLAP_MIDI_CONTROL_STATUS_ASSIGNABLE_PER_NOTE_CONTROLLER = 0x10, + CLAP_MIDI_CONTROL_STATUS_RPN = 0x20, + CLAP_MIDI_CONTROL_STATUS_NRPN = 0x30, + CLAP_MIDI_CONTROL_STATUS_PER_NOTE_PITCHBEND = 0x60, + CLAP_MIDI_CONTROL_STATUS_POLY_AFTERTOUCH = 0xA0, + CLAP_MIDI_CONTROL_STATUS_CONTROLLER = 0xB0, + CLAP_MIDI_CONTROL_STATUS_CHANNEL_AFTERTOUCH = 0xD0, + CLAP_MIDI_CONTROL_STATUS_PITCHBEND = 0xE0, +}; + +/* This describes a MIDI control/message */ +typedef struct clap_midi_control_info { + // CLAP_MIDI_CONTROL_STATUS, describes what kind of control this struct is about. + uint32_t status; + + // controller number, nrpn number etc. + // zero if not applicable the status value + uint32_t number; + + // Priority of this control (from a performing musician's point of view) + // 1..5, a value of 1 is the most important, descending down to 5 as the least important. + // Multiple controls can have the same priority. In this case the control at the lowest index + // (see clap_plugin_midi_controls.get_info) is more important than the next ones. + uint32_t priority; + + // Display name + // If name is empty the host can assume default MIDI controller names (cc7 is Volume etc.) + char name[CLAP_NAME_SIZE]; +} clap_midi_control_info_t; + +typedef struct clap_plugin_midi_controls { + // Returns the number of clap_midi_control_info structs for a channel. + // channel is 0..15 + // [main-thread] + uint32_t(CLAP_ABI *count)(const clap_plugin_t *plugin, + int16_t port_index, + uint16_t channel); + + // Fills midi_control_info. Returns true on success. + // [main-thread] + bool(CLAP_ABI *get_info)(const clap_plugin_t *plugin, + int16_t port_index, + uint16_t channel, + uint32_t index, + clap_midi_control_info_t *midi_control_info); + + //if false all channels are the same, so the host doesn't have to scan them all. + // [main-thread] + bool(CLAP_ABI *is_multitimbral)(const clap_plugin_t *plugin, + int16_t port_index); +} clap_plugin_midi_controls_t; + +typedef struct clap_host_midi_controls { + // Rescan the full list of structs. + // This can happen if an instrument switches to a different patch, for example. + // port_index = -1 means 'all ports' + // [main-thread] + void(CLAP_ABI *changed)(const clap_host_t *host, + int16_t port_index); +} clap_host_midi_controls_t; + +#ifdef __cplusplus +} +#endif \ No newline at end of file From 11a9fc5c9b66574c289178008654a8d5d85905d6 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Thu, 12 Oct 2023 13:34:28 +0200 Subject: [PATCH 08/11] Delete include/clap/ext/draft/midi-info.h --- include/clap/ext/draft/midi-info.h | 94 ------------------------------ 1 file changed, 94 deletions(-) delete mode 100644 include/clap/ext/draft/midi-info.h diff --git a/include/clap/ext/draft/midi-info.h b/include/clap/ext/draft/midi-info.h deleted file mode 100644 index 0fc56f43..00000000 --- a/include/clap/ext/draft/midi-info.h +++ /dev/null @@ -1,94 +0,0 @@ -#pragma once - -#include "../../plugin.h" - -// This extension lets a plugin expose its MIDI implementation. -// The primary goal is to allow a host to create a MIDI-CI Property Exchange "ChCtrlList" resource for the plugin, -// which is presented to a keyboard / controller. -// A keyboard can then assign its knobs to suitable controllers, decide between sending poly or channel afertouch etc. -// Also, hosts can use this extension to indicate to users which controls actually work. - -// TODO : clap_midiinfo could/should contain more (optional) info (min/max, stepcount, paramPath etc.) - -static CLAP_CONSTEXPR const char CLAP_EXT_MIDIINFO[] = "clap.midi-info.draft/0"; - -#ifdef __cplusplus -extern "C" { -#endif - -enum { - // MIDI 2.0 message status - CLAP_MIDIINFO_STATUS_REGISTERED_PER_NOTE_CONTROLLER = 0x00, - CLAP_MIDIINFO_STATUS_ASSIGNABLE_PER_NOTE_CONTROLLER = 0x10, - CLAP_MIDIINFO_STATUS_RPN = 0x20, - CLAP_MIDIINFO_STATUS_NRPN = 0x30, - CLAP_MIDIINFO_STATUS_PER_NOTE_PITCHBEND = 0x60, - CLAP_MIDIINFO_STATUS_POLY_AFTERTOUCH = 0xA0, - CLAP_MIDIINFO_STATUS_CONTROLLER = 0xB0, - CLAP_MIDIINFO_STATUS_CHANNEL_AFTERTOUCH = 0xD0, - CLAP_MIDIINFO_STATUS_PITCHBEND = 0xE0, - - // CLAP note expressions. - // A host may map MIDI messages to note expressions, so it needs to know which note expressions are supported. - CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_VOLUME = 0x100, - CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_PAN = 0x101, - CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_TUNING = 0x102, - CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_VIBRATO = 0x103, - CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_EXPRESSION = 0x104, - CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_BRIGHTNESS = 0x105, - CLAP_MIDIINFO_STATUS_NOTE_EXPRESSION_PRESSURE = 0x106 -}; - -/* This describes a MIDI control/message */ -typedef struct clap_midiinfo { - // CLAP_MIDIINFO_STATUS, describes what kind of control this struct is about. - uint32_t status; - - // controller number, nrpn number etc. - // zero if not applicable the status value - uint32_t number; - - // Priority of this control (from a performing musician's point of view) - // 1..5, a value of 1 is the most important, descending down to 5 as the least important. - // Multiple controls can have the same priority. In this case the control at the lowest index - // (see clap_plugin_midiinfo.get_info) is more important than the next ones. - uint32_t priority; - - // Display name - // If name is empty the host can assume default MIDI controller names (cc7 is Volume etc.) - char name[CLAP_NAME_SIZE]; -} clap_midiinfo_t; - -typedef struct clap_plugin_midiinfo { - // Returns the number of clap_midiinfo structs for a channel. - // channel is 0..15 - // [main-thread] - uint32_t(CLAP_ABI *count)(const clap_plugin_t *plugin, - int16_t port_index, - uint16_t channel); - - // Fills midiinfo. Returns true on success. - // [main-thread] - bool(CLAP_ABI *get_info)(const clap_plugin_t *plugin, - int16_t port_index, - uint16_t channel, - uint32_t index, - clap_param_info_t *midiinfo); - - //if false all channels are the same, so the host doesn't have to scan them all. - bool(CLAP_ABI *is_multitimbral)(const clap_plugin_t *plugin, - int16_t port_index); -} clap_plugin_midiinfo_t; - -typedef struct clap_host_midiinfo { - // Rescan the full list of structs. - // This can happen if an instrument switches to a different patch, for example. - // port_index = -1 means 'all ports' - // [main-thread] - void(CLAP_ABI *changed)(const clap_host_t *host, - int16_t port_index); -} clap_host_midiinfo_t; - -#ifdef __cplusplus -} -#endif \ No newline at end of file From 0fa44e389452e1f31f88ceb34035bbfb7613ab03 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Thu, 12 Oct 2023 13:37:03 +0200 Subject: [PATCH 09/11] typo --- include/clap/ext/draft/midi-controls.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/clap/ext/draft/midi-controls.h b/include/clap/ext/draft/midi-controls.h index c942ed5a..5e24697c 100644 --- a/include/clap/ext/draft/midi-controls.h +++ b/include/clap/ext/draft/midi-controls.h @@ -2,7 +2,7 @@ #include "../../plugin.h" -// This extension lets a plugin expose its MIDI control implementation. +// This extension lets a plugin expose its MIDI controls implementation. // The primary goal is to allow a host to create a MIDI-CI Property Exchange "ChCtrlList" resource for the plugin, // which is presented to a keyboard / controller. // A keyboard can then assign its knobs to suitable controllers, decide between sending poly or channel afertouch etc. From fea742d5e768eeae3527936e323a746ed2d557f3 Mon Sep 17 00:00:00 2001 From: Bremmers Date: Sat, 18 Nov 2023 14:07:16 +0100 Subject: [PATCH 10/11] added profile specific data --- include/clap/ext/draft/midici-profiles.h | 73 ++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 include/clap/ext/draft/midici-profiles.h diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h new file mode 100644 index 00000000..68ed09e4 --- /dev/null +++ b/include/clap/ext/draft/midici-profiles.h @@ -0,0 +1,73 @@ +#pragma once + +#include "../../plugin.h" + +//usage examples: +//- the host can tell a MIDI keyboard the plugin conforms to the drawbar organ profile, so the keyboard can set up its faders for that. +//- the host can send per-note articulations in MIDI 2.0 protocol note-on attributes if there's an active profile for this. + +//the 5 bytes repesenting a profile go in a uint64_t. +//the Default Control Change Mapping profile would be 0x00000000_0000217e for example. + +//TODO : profiles can be different for each MIDI channel, and this should work per-input port. +// we can add that once we've agreed on the basic functionality. +//TODO : for completeness it could work for outputs too. A MIDI effect plugin might want to know +// the host can receive per-note articulations in note attributes for example. + +static CLAP_CONSTEXPR const char CLAP_EXT_MIDICI_PROFILES[] = "clap.midici-profiles.draft/0"; + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct clap_plugin_midici_profiles { + // Returns the number of profiles supported. + // [main-thread] + uint32_t(CLAP_ABI *count)(const clap_plugin_t *plugin); + + // Get a profile by index. + // [main-thread] + bool(CLAP_ABI *get)(const clap_plugin_t *plugin, + uint32_t profile_index, + uint64_t *profile + bool *active); + + // get number of bytes for profile specific data for the specified Inquiry Target + // if result=0 there's no data available for this Inquiry Target + // [main-thread] + uint32_t(CLAP_ABI *get_data_size)(const clap_plugin_t *plugin, + uint32_t profile_index, + uint8_t inquiry_target); + + // get profile specific data for the specified Inquiry Target + // buffer must be large enough to contain the number of bytes returned by get_data_size() + // [main-thread] + bool(CLAP_ABI *get_data)(const clap_plugin_t *plugin, + uint32_t profile_index, + uint8_t inquiry_target, + const uint8_t *buffer); + + // Actives a profile, so the plugin knows the host will use this + // returns true if the profile was activated + // Note: do not call clap_host_midici_profiles.changed + // [main-thread] + bool(CLAP_ABI *activate)(const clap_plugin_t *plugin, + uint64_t profile); + + // Deactives a profile + // returns true if the profile was deactivated + // Note: do not call clap_host_midici_profiles.changed + // [main-thread] + bool(CLAP_ABI *deactivate)(const clap_plugin_t *plugin, + uint64_t profile); +} clap_plugin_midici_profiles_t; + +typedef struct clap_host_midici_profiles { + // Informs the host that the available or active profiles changed. + // [main-thread] + void(CLAP_ABI *changed)(const clap_host_t *host); +} clap_host_midici_profiles_t; + +#ifdef __cplusplus +} +#endif \ No newline at end of file From 173740576379ec19c4a85b3e6a4ee423d0f2cc5c Mon Sep 17 00:00:00 2001 From: Bremmers Date: Sat, 18 Nov 2023 14:09:00 +0100 Subject: [PATCH 11/11] Delete include/clap/ext/draft/midici-profiles.h --- include/clap/ext/draft/midici-profiles.h | 73 ------------------------ 1 file changed, 73 deletions(-) delete mode 100644 include/clap/ext/draft/midici-profiles.h diff --git a/include/clap/ext/draft/midici-profiles.h b/include/clap/ext/draft/midici-profiles.h deleted file mode 100644 index 68ed09e4..00000000 --- a/include/clap/ext/draft/midici-profiles.h +++ /dev/null @@ -1,73 +0,0 @@ -#pragma once - -#include "../../plugin.h" - -//usage examples: -//- the host can tell a MIDI keyboard the plugin conforms to the drawbar organ profile, so the keyboard can set up its faders for that. -//- the host can send per-note articulations in MIDI 2.0 protocol note-on attributes if there's an active profile for this. - -//the 5 bytes repesenting a profile go in a uint64_t. -//the Default Control Change Mapping profile would be 0x00000000_0000217e for example. - -//TODO : profiles can be different for each MIDI channel, and this should work per-input port. -// we can add that once we've agreed on the basic functionality. -//TODO : for completeness it could work for outputs too. A MIDI effect plugin might want to know -// the host can receive per-note articulations in note attributes for example. - -static CLAP_CONSTEXPR const char CLAP_EXT_MIDICI_PROFILES[] = "clap.midici-profiles.draft/0"; - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct clap_plugin_midici_profiles { - // Returns the number of profiles supported. - // [main-thread] - uint32_t(CLAP_ABI *count)(const clap_plugin_t *plugin); - - // Get a profile by index. - // [main-thread] - bool(CLAP_ABI *get)(const clap_plugin_t *plugin, - uint32_t profile_index, - uint64_t *profile - bool *active); - - // get number of bytes for profile specific data for the specified Inquiry Target - // if result=0 there's no data available for this Inquiry Target - // [main-thread] - uint32_t(CLAP_ABI *get_data_size)(const clap_plugin_t *plugin, - uint32_t profile_index, - uint8_t inquiry_target); - - // get profile specific data for the specified Inquiry Target - // buffer must be large enough to contain the number of bytes returned by get_data_size() - // [main-thread] - bool(CLAP_ABI *get_data)(const clap_plugin_t *plugin, - uint32_t profile_index, - uint8_t inquiry_target, - const uint8_t *buffer); - - // Actives a profile, so the plugin knows the host will use this - // returns true if the profile was activated - // Note: do not call clap_host_midici_profiles.changed - // [main-thread] - bool(CLAP_ABI *activate)(const clap_plugin_t *plugin, - uint64_t profile); - - // Deactives a profile - // returns true if the profile was deactivated - // Note: do not call clap_host_midici_profiles.changed - // [main-thread] - bool(CLAP_ABI *deactivate)(const clap_plugin_t *plugin, - uint64_t profile); -} clap_plugin_midici_profiles_t; - -typedef struct clap_host_midici_profiles { - // Informs the host that the available or active profiles changed. - // [main-thread] - void(CLAP_ABI *changed)(const clap_host_t *host); -} clap_host_midici_profiles_t; - -#ifdef __cplusplus -} -#endif \ No newline at end of file