clap

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

commit ebcc57bbd64666a420f25841d00677e2ff496ab1
parent 7667bf6696b6150ccf4a28b2da39bddcc30921da
Author: Alexandre BIQUE <bique.alexandre@gmail.com>
Date:   Thu,  6 May 2021 22:14:58 +0200

Don't use enum for anything ABI relevant

Diffstat:
MCMakeLists.txt | 6++++--
Minclude/clap/channel-map.h | 7+++++--
Minclude/clap/clap.h | 14++++++++------
Minclude/clap/events.h | 13++++++++-----
Minclude/clap/ext/log.h | 5+++--
Minclude/clap/ext/params.h | 31++++++++++++++++---------------
Minclude/clap/ext/render.h | 5+++--
Minclude/clap/string-sizes.h | 4++--
Asrc/main.cc | 6++++++
9 files changed, 55 insertions(+), 36 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt @@ -1,5 +1,6 @@ cmake_minimum_required(VERSION 3.20) -project(CLAP C) +project(CLAP C CXX) include_directories(include) -add_executable(clap-compile-test src/main.c) +add_executable(clap-compile-test-c src/main.c) +add_executable(clap-compile-test-cpp src/main.cc) +\ No newline at end of file diff --git a/include/clap/channel-map.h b/include/clap/channel-map.h @@ -1,10 +1,12 @@ #pragma once +#include <stdint.h> + #ifdef __cplusplus extern "C" { #endif -typedef enum clap_chmap { +enum { CLAP_CHMAP_UNSPECIFIED = 0, CLAP_CHMAP_MONO = 1, @@ -14,7 +16,8 @@ typedef enum clap_chmap { // front left, front right, center, low, surround left, surround right // surround back left, surround back right CLAP_CHMAP_SURROUND = 3, -} clap_chmap; +}; +typedef int32_t clap_chmap; #ifdef __cplusplus } diff --git a/include/clap/clap.h b/include/clap/clap.h @@ -43,20 +43,21 @@ extern "C" { // PROCESS // ///////////// -typedef enum clap_process_status { +enum { // Processing failed. The output buffer must be discarded. CLAP_PROCESS_ERROR = 0, // Processing succeed, keep processing. CLAP_PROCESS_CONTINUE = 1, - // Processing succeed, keep processing until the output is silent. - CLAP_PROCESS_CONTINUE_UNTIL_QUIET = 2, + // Processing succeed, keep processing if the output is not quiet. + CLAP_PROCESS_CONTINUE_IF_NOT_QUIET = 2, // Processing succeed, but no more processing is required, // until next event or variation in audio input. CLAP_PROCESS_SLEEP = 3, -} clap_process_status; +}; +typedef int32_t clap_process_status; typedef struct clap_audio_buffer { // Either data32 or data64 will be set, but not both. @@ -119,7 +120,7 @@ typedef struct clap_host { /* bitfield * This gives an hint to the host what the plugin might do. */ -typedef enum clap_plugin_type { +enum { /* Instruments can play notes, and generate audio */ CLAP_PLUGIN_INSTRUMENT = (1 << 0), @@ -135,7 +136,8 @@ typedef enum clap_plugin_type { // If this is the only type reported by the plugin, the host can assume that it wont change the // audio and event signal. CLAP_PLUGIN_ANALYZER = (1 << 3), -} clap_plugin_type; +}; +typedef int32_t clap_plugin_type; typedef struct clap_plugin_descriptor { int32_t clap_version; // initialized to CLAP_VERSION diff --git a/include/clap/events.h b/include/clap/events.h @@ -7,7 +7,7 @@ extern "C" { #endif -typedef enum clap_event_type { +enum { CLAP_EVENT_NOTE_ON, // note attribute CLAP_EVENT_NOTE_OFF, // note attribute CLAP_EVENT_NOTE_EXPRESSION, // note_expression attribute @@ -17,7 +17,9 @@ typedef enum clap_event_type { CLAP_EVENT_CHORD, // chord attribute CLAP_EVENT_MIDI, // midi attribute CLAP_EVENT_MIDI_SYSEX, // midi attribute -} clap_event_type; +}; +typedef int32_t clap_event_type; +typedef uint32_t clap_param_id; /** Note On/Off event. */ typedef struct clap_event_note { @@ -26,7 +28,7 @@ typedef struct clap_event_note { double velocity; // 0..1 } clap_event_note; -typedef enum clap_note_expression { +enum { // x >= 0, use 20 * log(4 * x) CLAP_NOTE_EXPRESSION_VOLUME, @@ -44,7 +46,8 @@ typedef enum clap_note_expression { CLAP_NOTE_EXPRESSION_TIMBRE, // TODO... -} clap_note_expression; +}; +typedef int32_t clap_note_expression; typedef struct clap_event_note_expression { clap_note_expression expression_id; @@ -63,7 +66,7 @@ typedef union clap_param_value { typedef struct clap_event_param { int32_t key; int32_t channel; - uint32_t param_id; // parameter index + clap_param_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/log.h b/include/clap/ext/log.h @@ -8,7 +8,7 @@ extern "C" { #define CLAP_EXT_LOG "clap/log" -typedef enum clap_log_severity { +enum { CLAP_LOG_DEBUG = 0, CLAP_LOG_INFO = 1, CLAP_LOG_WARNING = 2, @@ -17,7 +17,8 @@ typedef enum clap_log_severity { // This severity should be used to report misbehaviour of the host CLAP_LOG_HOST_MISBEHAVING = 5, -} clap_log_severity; +}; +typedef int32_t clap_log_severity; typedef struct clap_host_log { // Log a message through the host. diff --git a/include/clap/ext/params.h b/include/clap/ext/params.h @@ -8,22 +8,23 @@ extern "C" { #define CLAP_EXT_PARAMS "clap/params" -typedef enum clap_param_type { +enum { CLAP_PARAM_FLOAT = 0, // uses value.d CLAP_PARAM_BOOL = 1, // uses value.b CLAP_PARAM_INT = 2, // uses value.i CLAP_PARAM_ENUM = 3, // uses value.i -} clap_param_type; +}; +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; - int32_t 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. + 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. bool is_per_note; // does this param supports per note automations? bool is_per_channel; // does this param supports per channel automations? @@ -53,7 +54,7 @@ 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, - int32_t param_id, + clap_param_id param_id, int32_t value_index, clap_param_value *plain_value); @@ -66,30 +67,30 @@ typedef struct clap_plugin_params { // in the next process call to update the audio processor. // [main-thread] bool (*set_value)(clap_plugin * plugin, - int32_t param_id, + clap_param_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, - int32_t param_id, + clap_param_id param_id, clap_param_value plain_value, char * display, uint32_t size); bool (*text_to_value)(clap_plugin * plugin, - int32_t param_id, + clap_param_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, int32_t param_id); + void (*touch_begin)(clap_host *host, clap_plugin *plugin, clap_param_id param_id); /* [main-thread] */ - void (*touch_end)(clap_host *host, clap_plugin *plugin, int32_t param_id); + void (*touch_end)(clap_host *host, clap_plugin *plugin, clap_param_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. @@ -97,7 +98,7 @@ typedef struct clap_host_params { // [main-thread] void (*changed)(clap_host * host, clap_plugin * plugin, - int32_t param_id, + clap_param_id param_id, clap_param_value plain_value); // [main-thread] diff --git a/include/clap/ext/render.h b/include/clap/ext/render.h @@ -8,13 +8,14 @@ extern "C" { #endif -typedef enum clap_plugin_render_mode { +enum { /* Default setting, used to play "realtime". */ CLAP_RENDER_REALTIME = 0, /* Render setting, used while rendering the song. */ CLAP_RENDER_OFFLINE = 1, -} clap_plugin_render_mode; +}; +typedef int32_t clap_plugin_render_mode; // The render extension is used to let the plugin know if it has "realtime" // pressure to process. diff --git a/include/clap/string-sizes.h b/include/clap/string-sizes.h @@ -6,10 +6,10 @@ extern "C" { #endif -typedef enum clap_string_size { +enum { CLAP_NAME_SIZE = 64, CLAP_MODULE_SIZE = 128, -} clap_string_size; +}; #ifdef __cplusplus } diff --git a/src/main.cc b/src/main.cc @@ -0,0 +1,5 @@ +#include <clap/all.h> + +// The purpose of this file is to check that all headers compile + +int main(int argc, char **argv) { return 0; } +\ No newline at end of file