clap

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

commit 2db3b95b0cdf8d8d6f10ad60aef1f3f36ea814d6
parent 552bb31f999c5dc87f39a983c02abd117af781ba
Author: Alexandre BIQUE <bique.alexandre@gmail.com>
Date:   Thu, 13 May 2021 21:54:49 +0200

More work

Diffstat:
Minclude/clap/clap.h | 5+++++
Minclude/clap/events.h | 6++++--
Minclude/clap/ext/audio-ports.h | 5+++--
Minclude/clap/ext/draft/event-loop.h | 14++++++--------
Minclude/clap/ext/draft/remote-controls.h | 8++++----
Minclude/clap/ext/draft/track-info.h | 2+-
Minclude/clap/ext/draft/vst2-convert.h | 4++--
Minclude/clap/ext/draft/vst3-convert.h | 7+++----
Minclude/clap/ext/params.h | 27+++++++++++++--------------
9 files changed, 41 insertions(+), 37 deletions(-)

diff --git a/include/clap/clap.h b/include/clap/clap.h @@ -170,6 +170,10 @@ typedef struct clap_plugin { void *plugin_data; // reserved pointer for the plugin + // Must be called after creating the plugin. + // If init returns false, the host must destroy the plugin instance. + bool (*init)(struct clap_plugin *plugin); + /* Free the plugin and its resources. * It is not required to deactivate the plugin prior to this call. */ void (*destroy)(struct clap_plugin *plugin); @@ -214,6 +218,7 @@ struct clap_plugin_entry { /* Create a clap_plugin by its plugin_id. * The returned pointer must be freed by calling plugin->destroy(plugin); + * The plugin is not allowed to use the host callbacks in the create method. * Returns null in case of error. * [thread-safe] */ clap_plugin *(*create_plugin)(clap_host *host, const char *plugin_id); diff --git a/include/clap/events.h b/include/clap/events.h @@ -19,7 +19,9 @@ enum { CLAP_EVENT_MIDI_SYSEX, // midi attribute }; typedef int32_t clap_event_type; -typedef uint32_t clap_param_id; +typedef uint32_t clap_id; + +#define CLAP_INVALID_ID UINT32_MAX /** Note On/Off event. */ typedef struct clap_event_note { @@ -66,7 +68,7 @@ typedef union clap_param_value { typedef struct clap_event_param { int32_t key; int32_t channel; - clap_param_id param_id; // parameter index + clap_id param_id; // parameter index clap_param_value value; double ramp; // valid until the end of the block or the next event } clap_event_param; diff --git a/include/clap/ext/audio-ports.h b/include/clap/ext/audio-ports.h @@ -10,7 +10,7 @@ extern "C" { #define CLAP_EXT_AUDIO_PORTS "clap/audio-ports" typedef struct clap_audio_port_info { - int32_t id; // stable identifier + clap_id id; // stable identifier char name[CLAP_NAME_SIZE]; // displayable name, i18n? bool is_main; // there can only be 1 main input and output bool is_cv; // control voltage @@ -32,7 +32,8 @@ typedef struct clap_plugin_audio_ports { // [main-thread] void (*get_info)(clap_plugin *plugin, int32_t index, bool is_input, clap_audio_port_info *info); - void (*set_active)(clap_plugin *plugin, int32_t index, bool is_input, bool use_64, bool is_active); + void (*set_active)( + clap_plugin *plugin, int32_t index, bool is_input, bool use_64, bool is_active); } clap_plugin_audio_ports; typedef struct clap_host_audio_ports { diff --git a/include/clap/ext/draft/event-loop.h b/include/clap/ext/draft/event-loop.h @@ -15,8 +15,6 @@ typedef void *clap_fd; typedef int clap_fd; #endif -typedef uint32_t clap_timer_id; - enum { CLAP_FD_READ = 1 << 0, CLAP_FD_WRITE = 1 << 1, @@ -25,7 +23,7 @@ enum { typedef struct clap_plugin_event_loop { // [main-thread] - void (*on_timer)(clap_plugin *plugin, clap_timer_id timer_id); + void (*on_timer)(clap_plugin *plugin, clap_id timer_id); // [main-thread] void (*on_fd)(clap_plugin *plugin, clap_fd fd, uint32_t flags); @@ -33,13 +31,13 @@ typedef struct clap_plugin_event_loop { typedef struct clap_host_event_loop { // [main-thread] - bool (*register_timer)(clap_host * host, - clap_plugin * plugin, - uint32_t period_ms, - clap_timer_id *timer_id); + bool (*register_timer)(clap_host * host, + clap_plugin *plugin, + uint32_t period_ms, + clap_id * timer_id); // [main-thread] - bool (*unregister_timer)(clap_host *host, clap_plugin *plugin, clap_timer_id timer_id); + bool (*unregister_timer)(clap_host *host, clap_plugin *plugin, clap_id timer_id); // [main-thread] bool (*register_fd)(clap_host *host, clap_plugin *plugin, clap_fd fd, uint32_t flags); diff --git a/include/clap/ext/draft/remote-controls.h b/include/clap/ext/draft/remote-controls.h @@ -10,19 +10,19 @@ extern "C" { #define CLAP_EXT_REMOTE_CONTROLS "clap/draft/remote-controls" typedef struct clap_remote_controls_page { - int32_t id; + clap_id id; char name[CLAP_NAME_SIZE]; - int32_t param_id[8]; + clap_id param_id[8]; } clap_remote_controls_page; typedef struct clap_plugin_remote_controls { - int32_t (*count)(clap_plugin *plugin); + int32_t (*page_count)(clap_plugin *plugin); // [main-thread] bool (*get_page)(clap_plugin *plugin, int32_t page_index, clap_remote_controls_page *page); // [main-thread] - void (*select_page)(clap_plugin *plugin, int32_t page_id); + void (*select_page)(clap_plugin *plugin, clap_id page_id); } clap_host_plugin_info; typedef struct clap_host_remote_controls { diff --git a/include/clap/ext/draft/track-info.h b/include/clap/ext/draft/track-info.h @@ -11,7 +11,7 @@ extern "C" { #define CLAP_EXT_TRACK_INFO "clap/draft/track-info" typedef struct clap_track_info { - int32_t id; + clap_id id; int32_t index; char name[CLAP_NAME_SIZE]; char path[512]; // Like "/group1/group2/drum-machine/drum-pad" diff --git a/include/clap/ext/draft/vst2-convert.h b/include/clap/ext/draft/vst2-convert.h @@ -28,7 +28,7 @@ typedef struct clap_plugin_vst2_convert { bool (*convert_normalized_value)(clap_plugin * plugin, uint32_t vst2_param_id, double vst2_normalized_value, - int32_t * clap_param_id, + clap_id * clap_param_id, clap_param_value *clap_plain_value); // converts the vst2 param id and plain value to clap param id and @@ -37,7 +37,7 @@ typedef struct clap_plugin_vst2_convert { bool (*convert_plain_value)(clap_plugin * plugin, uint32_t vst2_param_id, double vst2_plain_value, - int32_t * clap_param_id, + clap_id * clap_param_id, clap_param_value *clap_plain_value); } clap_plugin_vst2_convert; diff --git a/include/clap/ext/draft/vst3-convert.h b/include/clap/ext/draft/vst3-convert.h @@ -11,9 +11,8 @@ extern "C" { typedef struct clap_plugin_vst3_convert { // Copies the name and VST3 plugin id that we can convert from. - // Returns the lenght of the name. // [thread-safe] - int32_t (*get_vst3_plugin_id)(clap_plugin *plugin, uint8_t *vst3_plugin_id); + void (*get_vst3_plugin_id)(clap_plugin *plugin, uint8_t *vst3_plugin_uuid); // Loads the plugin state from stream using the vst3 chunk. // [main-thread] @@ -25,7 +24,7 @@ typedef struct clap_plugin_vst3_convert { bool (*convert_normalized_value)(clap_plugin * plugin, uint32_t vst3_param_id, double vst3_normalized_value, - int32_t * clap_param_id, + clap_id * clap_param_id, clap_param_value *clap_plain_value); // converts the vst3 param id and plain value to clap param id and @@ -34,7 +33,7 @@ typedef struct clap_plugin_vst3_convert { bool (*convert_plain_value)(clap_plugin * plugin, uint32_t vst3_param_id, double vst3_plain_value, - int32_t * clap_param_id, + clap_id * clap_param_id, clap_param_value *clap_plain_value); } clap_plugin_vst3_convert; diff --git a/include/clap/ext/params.h b/include/clap/ext/params.h @@ -19,12 +19,11 @@ typedef int32_t clap_param_type; /* This describes the parameter and provides the current value */ typedef struct clap_param_info { /* param info */ - int32_t index; - clap_param_id id; - char name[CLAP_NAME_SIZE]; // the display name - char module[CLAP_MODULE_SIZE]; // the module containing the param, eg: - // "/filters/moog"; '/' will be used as a - // separator to show a tree like structure. + clap_id id; + char name[CLAP_NAME_SIZE]; // the display name + char module[CLAP_MODULE_SIZE]; // the module containing the param, eg: + // "/filters/moog"; '/' will be used as a + // separator to show a tree like structure. bool is_per_note; // does this param supports per note automations? bool is_per_channel; // does this param supports per channel automations? @@ -54,43 +53,43 @@ typedef struct clap_plugin_params { bool (*get_info)(clap_plugin *plugin, int32_t param_index, clap_param_info *param_info); bool (*get_enum_value)(clap_plugin * plugin, - clap_param_id param_id, + clap_id param_id, int32_t value_index, clap_param_value *plain_value); // Gets the parameter plain value. // [main-thread] - bool (*get_value)(clap_plugin *plugin, clap_param_id param_id, clap_param_value *plain_value); + bool (*get_value)(clap_plugin *plugin, clap_id param_id, clap_param_value *plain_value); // Sets the parameter plain value. // If the plupin is activated, then the host must send a param event // in the next process call to update the audio processor. // [main-thread] bool (*set_value)(clap_plugin * plugin, - clap_param_id param_id, + clap_id param_id, clap_param_value plain_value, clap_param_value plain_modulated_value); // Formats the display text for the given parameter value. // [thread-safe,lock-wait-free] bool (*value_to_text)(clap_plugin * plugin, - clap_param_id param_id, + clap_id param_id, clap_param_value plain_value, char * display, uint32_t size); bool (*text_to_value)(clap_plugin * plugin, - clap_param_id param_id, + clap_id param_id, const char * display, clap_param_value *plain_value); } clap_plugin_params; typedef struct clap_host_params { /* [main-thread] */ - void (*touch_begin)(clap_host *host, clap_plugin *plugin, clap_param_id param_id); + void (*touch_begin)(clap_host *host, clap_plugin *plugin, clap_id param_id); /* [main-thread] */ - void (*touch_end)(clap_host *host, clap_plugin *plugin, clap_param_id param_id); + void (*touch_end)(clap_host *host, clap_plugin *plugin, clap_id param_id); // If the plugin is activated, the host must send a parameter update // in the next process call to update the audio processor. @@ -98,7 +97,7 @@ typedef struct clap_host_params { // [main-thread] void (*changed)(clap_host * host, clap_plugin * plugin, - clap_param_id param_id, + clap_id param_id, clap_param_value plain_value); // [main-thread]