clap

CLAP Audio Plugin API
Log | Files | Refs | README | LICENSE

commit f9b21130042030533ca808402196fcceb4668c62
parent d1e9c23cb404a00c43d7882306c0164373af84f1
Author: Alexandre BIQUE <bique.alexandre@gmail.com>
Date:   Sun, 28 Nov 2021 10:14:45 +0100

Add a note_port extensions

This lets the plugin work with multiple notes ports.

Diffstat:
Minclude/clap/events.h | 21+++++++++++++++------
Minclude/clap/ext/audio-ports.h | 27++++-----------------------
Minclude/clap/ext/note-name.h | 5+++--
Ainclude/clap/ext/note-ports.h | 61+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Minclude/clap/ext/params.h | 17++++++++++-------
5 files changed, 93 insertions(+), 38 deletions(-)

diff --git a/include/clap/events.h b/include/clap/events.h @@ -32,6 +32,7 @@ typedef int32_t clap_event_type; * - key and channel are used to match active notes, a value of -1 matches all. */ typedef struct clap_event_note { + int32_t port_index; int32_t key; // 0..127 int32_t channel; // 0..15 double velocity; // 0..1 @@ -60,11 +61,13 @@ typedef int32_t clap_note_expression; typedef struct clap_event_note_expression { clap_note_expression expression_id; - // target a specific key and channel, -1 for global + + // target a specific port, key and channel, -1 for global + int32_t port_index; int32_t key; int32_t channel; - double value; // see expression for the range + double value; // see expression for the range } clap_event_note_expression; enum { @@ -81,10 +84,11 @@ typedef int32_t clap_event_param_flags; typedef struct clap_event_param_value { // target parameter - void * cookie; // @ref clap_param_info.cookie + void *cookie; // @ref clap_param_info.cookie clap_id param_id; // @ref clap_param_info.id - // target a specific key and channel, -1 for global + // target a specific port, key and channel, -1 for global + int32_t port_index; int32_t key; int32_t channel; @@ -95,10 +99,11 @@ typedef struct clap_event_param_value { typedef struct clap_event_param_mod { // target parameter - void * cookie; // @ref clap_param_info.cookie + void *cookie; // @ref clap_param_info.cookie clap_id param_id; // @ref clap_param_info.id - // target a specific key and channel, -1 for global + // target a specific port, key and channel, -1 for global + int32_t port_index; int32_t key; int32_t channel; @@ -140,6 +145,8 @@ typedef struct clap_event_transport { } clap_event_transport; typedef struct clap_event_note_mask { + int32_t port_index; + // bitset of active keys: // - 11 bits // - root note is not part of the bitset @@ -152,10 +159,12 @@ typedef struct clap_event_note_mask { } clap_event_note_mask; typedef struct clap_event_midi { + int32_t port_index; uint8_t data[3]; } clap_event_midi; typedef struct clap_event_midi_sysex { + int32_t port_index; const uint8_t *buffer; // midi buffer uint32_t size; } clap_event_midi_sysex; diff --git a/include/clap/ext/audio-ports.h b/include/clap/ext/audio-ports.h @@ -6,30 +6,11 @@ /// @page Audio Ports /// -/// This extension provides a way for the plugin to describe: -/// - its current ports -/// - possible ports configurations, for example mono, stereo, surround, ... -/// and a way for the host to select a configuration. +/// This extension provides a way for the plugin to describe its current audio ports. /// -/// If the plugin does not implement this extension, it will have a stereo input and output. +/// If the plugin does not implement this extension, it will have a default stereo input and output. /// /// The plugin is only allowed to change its ports configuration while it is deactivated. -/// -/// During @ref clap_plugin.init, the plugin may query @ref clap_host_track_info and select a -/// configuration adapted to the track. -/// -/// After the plugin initialization, the host may scan the list of configurations and eventually -/// select one that fits the plugin context. The host can only select a configuration if the plugin -/// is deactivated. -/// -/// A configuration is a very simple description of the audio ports: -/// - it describes the main input and output ports -/// - it has a name that can be displayed to the user -/// -/// The idea behind the configurations, is to let the user choose one via a menu. -/// -/// Plugin with very complex configuration possibilities should let the user configure the ports -/// from the plugin GUI, and call @ref clap_host_audio_ports.rescan(CLAP_AUDIO_PORTS_RESCAN_ALL). static CLAP_CONSTEXPR const char CLAP_EXT_AUDIO_PORTS[] = "clap.audio-ports"; @@ -39,7 +20,7 @@ extern "C" { typedef struct clap_audio_port_info { clap_id id; // stable identifier - char name[CLAP_NAME_SIZE]; // displayable name, i18n? + char name[CLAP_NAME_SIZE]; // displayable name uint32_t channel_count; clap_chmap channel_map; @@ -60,7 +41,7 @@ typedef struct clap_plugin_audio_ports { // get info about about an audio port. // [main-thread] - bool (*get)(const clap_plugin * plugin, + bool (*get)(const clap_plugin *plugin, uint32_t index, bool is_input, clap_audio_port_info *info); diff --git a/include/clap/ext/note-name.h b/include/clap/ext/note-name.h @@ -12,8 +12,9 @@ static CLAP_CONSTEXPR const char CLAP_EXT_NOTE_NAME[] = "clap.note-name"; typedef struct clap_note_name { char name[CLAP_NAME_SIZE]; - int8_t key; - int8_t channel; // -1 for every channels + int32_t port; + int32_t key; + int32_t channel; // -1 for every channels } clap_note_name; typedef struct clap_plugin_note_name { diff --git a/include/clap/ext/note-ports.h b/include/clap/ext/note-ports.h @@ -0,0 +1,60 @@ +#pragma once + + +#include "../clap.h" +#include "../chmap.h" +#include "../string-sizes.h" + +/// @page Note Ports +/// +/// This extension provides a way for the plugin to describe its current note ports. +/// +/// If the plugin does not implement this extension, it will have a single note input and output. +/// +/// The plugin is only allowed to change its note ports configuration while it is deactivated. + +static CLAP_CONSTEXPR const char CLAP_EXT_NOTE_PORTS[] = "clap.note-ports"; + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct clap_note_port_info { + clap_id id; // stable identifier + char name[CLAP_NAME_SIZE]; // displayable name, i18n? +} clap_note_port_info; + +// The audio ports scan has to be done while the plugin is deactivated. +typedef struct clap_plugin_note_ports { + // number of ports, for either input or output + // [main-thread] + uint32_t (*count)(const clap_plugin *plugin, bool is_input); + + // get info about about a note port. + // [main-thread] + bool (*get)(const clap_plugin * plugin, + uint32_t index, + bool is_input, + clap_note_port_info *info); +} clap_plugin_note_ports; + +enum { + // The ports have changed, the host shall perform a full scan of the ports. + // This flag can only be used if the plugin is not active. + // If the plugin active, call host->request_restart() and then call rescan() + // when the host calls deactivate() + CLAP_NOTE_PORTS_RESCAN_ALL = 1 << 0, + + // The ports name did change, the host can scan them right away. + CLAP_NOTE_PORTS_RESCAN_NAMES = 1 << 1, +}; + +typedef struct clap_host_note_ports { + // Rescan the full list of audio ports according to the flags. + // [main-thread] + void (*rescan)(const clap_host *host, uint32_t flags); +} clap_host_note_ports; + +#ifdef __cplusplus +} +#endif +\ No newline at end of file diff --git a/include/clap/ext/params.h b/include/clap/ext/params.h @@ -91,31 +91,34 @@ enum { // Does this param supports per channel automations? CLAP_PARAM_IS_PER_CHANNEL = 1 << 2, - // Useful for phase ;-) - CLAP_PARAM_IS_PERIODIC = 1 << 3, + // Does this param supports per port automations? + CLAP_PARAM_IS_PER_PORT = 1 << 3, + + // Useful for for periodic parameters like a phase + CLAP_PARAM_IS_PERIODIC = 1 << 4, // The parameter should not be shown to the user, because it is currently not used. // It is not necessary to process automation for this parameter. - CLAP_PARAM_IS_HIDDEN = 1 << 4, + CLAP_PARAM_IS_HIDDEN = 1 << 5, // This parameter is used to merge the plugin and host bypass button. // It implies that the parameter is stepped. // min: 0 -> bypass off // max: 1 -> bypass on - CLAP_PARAM_IS_BYPASS = (1 << 5) | CLAP_PARAM_IS_STEPPED, + CLAP_PARAM_IS_BYPASS = (1 << 6) | CLAP_PARAM_IS_STEPPED, // The parameter can't be changed by the host. - CLAP_PARAM_IS_READONLY = 1 << 6, + CLAP_PARAM_IS_READONLY = 1 << 7, // Does the parameter support the modulation signal? - CLAP_PARAM_IS_MODULATABLE = 1 << 7, + CLAP_PARAM_IS_MODULATABLE = 1 << 8, // Any change to this parameter will affect the plugin output and requires to be done via // process() if the plugin is active. // // A simple example would be a DC Offset, changing it will change the output signal and must be // processed. - CLAP_PARAM_REQUIRES_PROCESS = 1 << 8, + CLAP_PARAM_REQUIRES_PROCESS = 1 << 9, }; typedef uint32_t clap_param_info_flags;