clap

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

commit 2db53c913380be4daa4acd6b877bf49fc7ee166c
parent 0892a6ceca189a5792110b30d384b31c1dac5aa9
Author: Alexandre BIQUE <bique.alexandre@gmail.com>
Date:   Thu, 22 Apr 2021 20:46:19 +0200

more work

Diffstat:
Minclude/clap/clap.h | 34+++++++++++++---------------------
Minclude/clap/ext/params.h | 98++++++++++++++++++++++++++++++++++++++-----------------------------------------
2 files changed, 60 insertions(+), 72 deletions(-)

diff --git a/include/clap/clap.h b/include/clap/clap.h @@ -25,6 +25,7 @@ #pragma once +#include <bits/stdint-intn.h> #ifdef __cplusplus extern "C" { #endif @@ -64,9 +65,6 @@ struct clap_host; enum clap_string_size { CLAP_ID_SIZE = 128, CLAP_NAME_SIZE = 64, - CLAP_DESC_SIZE = 256, - CLAP_DISPLAY_SIZE = 64, - CLAP_TAGS_SIZE = 256, }; enum clap_log_severity { @@ -79,8 +77,6 @@ enum clap_log_severity { // Description of the plugin #define CLAP_ATTR_DESCRIPTION "clap/description" -// Product version string -#define CLAP_ATTR_VERSION "clap/version" // Manufacturer name #define CLAP_ATTR_MANUFACTURER "clap/manufacturer" // Url to product @@ -117,15 +113,11 @@ enum clap_event_type { CLAP_EVENT_CONTROL = 5, // control attribute CLAP_EVENT_PROGRAM = 16, // program attribute CLAP_EVENT_MIDI = 6, // midi attribute - - CLAP_EVENT_PLAY = 12, // no attribute - CLAP_EVENT_PAUSE = 13, // no attribute - CLAP_EVENT_STOP = 14, // no attribute }; struct clap_event_param { - int8_t key; - int8_t channel; + int32_t key; + int32_t channel; uint32_t index; // parameter index union clap_param_value normalized_value; double normalized_ramp; @@ -133,16 +125,16 @@ struct clap_event_param { /** Note On/Off event. */ struct clap_event_note { - int8_t key; // 0..127 - int8_t channel; // 0..15 - double velocity; // 0..1 + int32_t key; // 0..127 + int32_t channel; // 0..15 + double velocity; // 0..1 }; struct clap_event_control { - int8_t key; // 0..127, or -1 to match all keys - int8_t channel; // 0..15, or -1 to match all channels - int8_t control; // 0..127 - double value; // 0..1 + int32_t key; // 0..127, or -1 to match all keys + int32_t channel; // 0..15, or -1 to match all channels + int32_t control; // 0..127 + double value; // 0..1 }; struct clap_event_midi { @@ -280,7 +272,7 @@ struct clap_host { /* Query an extension. * [thread-safe] */ - const void *(*extension)(struct clap_host *host, const char *extention_id); + const void *(*extension)(struct clap_host *host, const char *extension_id); }; //////////// @@ -343,8 +335,8 @@ struct clap_plugin { /* process audio, events, ... * [audio-thread] */ - enum clap_process_status (*process)(struct clap_plugin * plugin, - struct clap_process *process); + enum clap_process_status (*process)(struct clap_plugin * plugin, + const struct clap_process *process); /* query an extension * [thread-safe] */ diff --git a/include/clap/ext/params.h b/include/clap/ext/params.h @@ -7,7 +7,6 @@ extern "C" { #endif #define CLAP_EXT_PARAMS "clap/params" -#define CLAP_ROOT_MODULE_ID "" enum clap_param_type { CLAP_PARAM_FLOAT = 0, // uses value.d @@ -17,69 +16,66 @@ enum clap_param_type { }; /* This describes the parameter and provides the current value */ -struct clap_param { +struct clap_param_info { /* param info */ - char id[CLAP_ID_SIZE]; // a string which identify the param - char module[CLAP_ID_SIZE]; - char name[CLAP_NAME_SIZE]; // the display name - char desc[CLAP_DESC_SIZE]; - char display[CLAP_DISPLAY_SIZE]; // the text used to display the value - bool is_per_note; - bool is_per_channel; - bool is_used; // is this parameter used by the patch? - bool is_periodic; // after the last value, go back to the first one - bool is_locked; // if true, the parameter can't be changed by the host - bool is_automatable; + int32_t index; + int32_t id; // a string which identify the param + char name[CLAP_NAME_SIZE]; // the display name + bool is_per_note; + bool is_per_channel; + bool is_used; // is this parameter used by the patch? + bool is_periodic; // after the last value, go back to the first one + bool is_locked; // if true, the parameter can't be changed by the host + bool is_automatable; /* value */ enum clap_param_type type; - union clap_param_value plain_value; // current value - union clap_param_value normalized_value; - union clap_param_value min; // minimum value - union clap_param_value max; // maximum value - union clap_param_value deflt; // default value -}; - -struct clap_param_module { - char id[CLAP_ID_SIZE]; - char parent_id[CLAP_ID_SIZE]; - char name[CLAP_NAME_SIZE]; - char desc[CLAP_DESC_SIZE]; + union clap_param_value value; // current plain value + union clap_param_value min_value; // minimum plain value + union clap_param_value max_value; // maximum plain value + union clap_param_value default_value; // default plain value }; struct clap_plugin_params { - /* Returns the number of parameters. - * [main-thread] */ + // Returns the number of parameters. + // [main-thread] int32_t (*count)(struct clap_plugin *plugin); - /* Copies the parameter's info to param and returns true. - * If index is greater or equal to the number then return false. - * [main-thread] */ - bool (*get_param)(struct clap_plugin *plugin, - int32_t index, - struct clap_param * param); + // Copies the parameter's info to param_info and returns true on success. + // [main-thread] + bool (*get_param_info)(struct clap_plugin * plugin, + int32_t param_index, + struct clap_param_info *param_info); - /* Copies the module's info to module and returns true on success. - * [main-thread] */ - bool (*get_module)(struct clap_plugin * plugin, - const char * module_id, - struct clap_param_module *module); + // Gets the parameter plain value. + // [main-thread] + union clap_param_value (*get_param_value)(struct clap_plugin *plugin, + int32_t param_index); - // [thread-safe,lock-free] - double (*plain_to_normalized)(struct clap_plugin *plugin, - int32_t index, - double plain_value); - double (*normalized_to_plain)(struct clap_plugin *plugin, - int32_t index, - double normalized_value); - - // Sets the parameter 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] - void (*set_parameter_value)(struct clap_plugin * plugin, - int32_t index, - union clap_param_value plain_value); + void (*set_param_value)(struct clap_plugin * plugin, + int32_t param_index, + union clap_param_value plain_value); + + // Normalization only exists for float values + // [thread-safe,lock-free] + double (*plain_to_norm)(struct clap_plugin *plugin, + int32_t param_index, + double plain_value); + double (*norm_to_plain)(struct clap_plugin *plugin, + int32_t param_index, + double normalized_value); + + // Formats the display text for the given parameter value. + // [thread-safe,lock-free] + bool (*get_param_display)(struct clap_plugin * plugin, + int32_t param_index, + union clap_param_value plain_value, + char * display, + uint32_t size); }; struct clap_host_params { @@ -103,7 +99,7 @@ struct clap_host_params { union clap_param_value plain_value, bool is_recordable); - /* [main-thread] */ + // [main-thread] void (*rescan)(struct clap_host *host, struct clap_plugin *plugin); };