note-ports.h (2659B)
1 #pragma once 2 3 #include "../plugin.h" 4 #include "../string-sizes.h" 5 6 /// @page Note Ports 7 /// 8 /// This extension provides a way for the plugin to describe its current note ports. 9 /// If the plugin does not implement this extension, it won't have note input or output. 10 /// The plugin is only allowed to change its note ports configuration while it is deactivated. 11 12 static CLAP_CONSTEXPR const char CLAP_EXT_NOTE_PORTS[] = "clap.note-ports"; 13 14 #ifdef __cplusplus 15 extern "C" { 16 #endif 17 18 enum clap_note_dialect { 19 // Uses clap_event_note and clap_event_note_expression. 20 CLAP_NOTE_DIALECT_CLAP = 1 << 0, 21 22 // Uses clap_event_midi, no polyphonic expression 23 CLAP_NOTE_DIALECT_MIDI = 1 << 1, 24 25 // Uses clap_event_midi, with polyphonic expression (MPE) 26 CLAP_NOTE_DIALECT_MIDI_MPE = 1 << 2, 27 28 // Uses clap_event_midi2 29 CLAP_NOTE_DIALECT_MIDI2 = 1 << 3, 30 }; 31 32 typedef struct clap_note_port_info { 33 // id identifies a port and must be stable. 34 // id may overlap between input and output ports. 35 clap_id id; 36 uint32_t supported_dialects; // bitfield, see clap_note_dialect 37 uint32_t preferred_dialect; // one value of clap_note_dialect 38 char name[CLAP_NAME_SIZE]; // displayable name, i18n? 39 } clap_note_port_info_t; 40 41 // The note ports scan has to be done while the plugin is deactivated. 42 typedef struct clap_plugin_note_ports { 43 // Number of ports, for either input or output. 44 // [main-thread] 45 uint32_t(CLAP_ABI *count)(const clap_plugin_t *plugin, bool is_input); 46 47 // Get info about a note port. 48 // Returns true on success and stores the result into info. 49 // [main-thread] 50 bool(CLAP_ABI *get)(const clap_plugin_t *plugin, 51 uint32_t index, 52 bool is_input, 53 clap_note_port_info_t *info); 54 } clap_plugin_note_ports_t; 55 56 enum { 57 // The ports have changed, the host shall perform a full scan of the ports. 58 // This flag can only be used if the plugin is not active. 59 // If the plugin active, call host->request_restart() and then call rescan() 60 // when the host calls deactivate() 61 CLAP_NOTE_PORTS_RESCAN_ALL = 1 << 0, 62 63 // The ports name did change, the host can scan them right away. 64 CLAP_NOTE_PORTS_RESCAN_NAMES = 1 << 1, 65 }; 66 67 typedef struct clap_host_note_ports { 68 // Query which dialects the host supports 69 // [main-thread] 70 uint32_t(CLAP_ABI *supported_dialects)(const clap_host_t *host); 71 72 // Rescan the full list of note ports according to the flags. 73 // [main-thread] 74 void(CLAP_ABI *rescan)(const clap_host_t *host, uint32_t flags); 75 } clap_host_note_ports_t; 76 77 #ifdef __cplusplus 78 } 79 #endif