clap

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

commit c7f10930b95cf7c11ff043192dc00635b1ab4e6c
parent aa1a21369c720898e9587e7d8aa81455d776e0be
Author: Alexandre BIQUE <bique.alexandre@gmail.com>
Date:   Sun, 25 Apr 2021 13:07:38 +0200

Use typedef to make the headers smaller and easier to read

Diffstat:
Minclude/clap/clap.h | 163+++++++++++++++++++++++++++++++++++++------------------------------------------
Minclude/clap/ext/audio-ports.h | 46++++++++++++++++++++++------------------------
Minclude/clap/ext/draft/ev-loop.h | 33+++++++++++++++------------------
Minclude/clap/ext/draft/key-name.h | 20+++++++++-----------
Minclude/clap/ext/draft/preset-load.h | 6+++---
Minclude/clap/ext/draft/thread-check.h | 8++++----
Minclude/clap/ext/draft/tuning.h | 14+++++++-------
Minclude/clap/ext/draft/vst2-convert.h | 37++++++++++++++++++-------------------
Minclude/clap/ext/draft/vst3-convert.h | 15++++++++-------
Minclude/clap/ext/gui-cocoa.h | 8++++----
Minclude/clap/ext/gui-free-standing.h | 10+++++-----
Minclude/clap/ext/gui-win32.h | 8++++----
Minclude/clap/ext/gui-x11.h | 12++++++------
Minclude/clap/ext/gui.h | 22++++++++++------------
Minclude/clap/ext/idle.h | 6+++---
Minclude/clap/ext/log.h | 16++++++++--------
Minclude/clap/ext/params.h | 101++++++++++++++++++++++++++++++++++++++-----------------------------------------
Minclude/clap/ext/render.h | 11+++++------
Minclude/clap/ext/state.h | 16++++++++--------
Dinclude/clap/ext/stream.h | 31-------------------------------
Ainclude/clap/stream.h | 29+++++++++++++++++++++++++++++
21 files changed, 292 insertions(+), 320 deletions(-)

diff --git a/include/clap/clap.h b/include/clap/clap.h @@ -54,17 +54,10 @@ extern "C" { # endif #endif -/////////////////////////// -// FORWARD DELCLARATIONS // -/////////////////////////// - -struct clap_plugin; -struct clap_host; - -enum clap_string_size { +typedef enum clap_string_size { CLAP_ID_SIZE = 128, CLAP_NAME_SIZE = 64, -}; +} clap_string_size; // Description of the plugin #define CLAP_ATTR_DESCRIPTION "clap/description" @@ -79,17 +72,17 @@ enum clap_string_size { // PARAMETERS // //////////////// -union clap_param_value { +typedef union clap_param_value { bool b; double d; int64_t i; -}; +} clap_param_value; //////////// // EVENTS // //////////// -enum clap_event_type { +typedef enum clap_event_type { CLAP_EVENT_NOTE_ON = 0, // note attribute CLAP_EVENT_NOTE_OFF = 1, // note attribute CLAP_EVENT_CHOKE = 2, // no attribute @@ -100,38 +93,38 @@ enum clap_event_type { CLAP_EVENT_PROGRAM = 5, // program attribute CLAP_EVENT_MIDI = 6, // midi attribute CLAP_EVENT_MIDI_SYSEX = 7, // midi attribute -}; +} clap_event_type; -struct clap_event_param { - int32_t key; - int32_t channel; - uint32_t index; // parameter index - union clap_param_value normalized_value; - double normalized_ramp; // only applies to float values -}; +typedef struct clap_event_param { + int32_t key; + int32_t channel; + uint32_t index; // parameter index + clap_param_value normalized_value; + double normalized_ramp; // only applies to float values +} clap_event_param; /** Note On/Off event. */ -struct clap_event_note { +typedef struct clap_event_note { int32_t key; // 0..127 int32_t channel; // 0..15 double velocity; // 0..1 -}; +} clap_event_note; -struct clap_event_control { +typedef struct clap_event_control { 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 -}; +} clap_event_control; -struct clap_event_midi { +typedef struct clap_event_midi { uint8_t data[4]; -}; +} clap_event_midi; -struct clap_event_midi_sysex { +typedef struct clap_event_midi_sysex { const uint8_t *buffer; // midi buffer uint32_t size; -}; +} clap_event_midi_sysex; /** * Asks the plugin to load a program. @@ -141,46 +134,44 @@ struct clap_event_midi_sysex { * a preset, is that the program should already be in the plugin's * memory, and can be set instantly. */ -struct clap_event_program { +typedef struct clap_event_program { int32_t channel; // 0..15, -1 unspecified int32_t bank_msb; // 0..0x7FFFFFFF, -1 unspecified int32_t bank_lsb; // 0..0x7FFFFFFF, -1 unspecified int32_t program; // 0..0x7FFFFFFF -}; +} clap_event_program; -struct clap_event { - enum clap_event_type type; +typedef struct clap_event { + clap_event_type type; uint32_t time; // offset from the first sample in the process block union { - struct clap_event_note note; - struct clap_event_control control; - struct clap_event_param param; - struct clap_event_midi midi; - struct clap_event_midi_sysex midi_sysex; - struct clap_event_program program; + clap_event_note note; + clap_event_control control; + clap_event_param param; + clap_event_midi midi; + clap_event_midi_sysex midi_sysex; + clap_event_program program; }; -}; +} clap_event; -struct clap_event_list { +typedef struct clap_event_list { void *ctx; - uint32_t (*size)(const struct clap_event_list *list); + uint32_t (*size)(const clap_event_list *list); // Don't free the return event, it belongs to the list - const struct clap_event *(*get)(const struct clap_event_list *list, - uint32_t index); + const clap_event *(*get)(const clap_event_list *list, uint32_t index); // Makes a copy of the event - void (*push_back)(const struct clap_event_list *list, - const struct clap_event * event); -}; + void (*push_back)(const clap_event_list *list, const clap_event *event); +} clap_event_list; ///////////// // PROCESS // ///////////// -enum clap_process_status { +typedef enum clap_process_status { // Processing failed. The output buffer must be discarded. CLAP_PROCESS_ERROR = 0, @@ -189,9 +180,9 @@ enum clap_process_status { // Processing succeed, but no more processing is required, until next event. CLAP_PROCESS_SLEEP = 2, -}; +} clap_process_status; -struct clap_audio_buffer { +typedef struct clap_audio_buffer { // Either data32 or data64 will be set, but not both. // If none are set, assume that the input has the value 0 for each samples. // data[i] for channel i buffer @@ -201,9 +192,9 @@ struct clap_audio_buffer { uint32_t latency; // latency from/to the audio interface uint64_t constant_mask; // bitmask for each channel, 1 if the value is // constant for the whole buffer -}; +} clap_audio_buffer; -struct clap_transport { +typedef struct clap_transport { bool is_free_running; // free running host, no info provided bool is_playing; @@ -221,12 +212,12 @@ struct clap_transport { int16_t tsig_denom; // time signature denominator int64_t steady_time; // the steady time in samples -}; +} clap_transport; -struct clap_process { +typedef struct clap_process { int32_t frames_count; // number of frame to process - struct clap_transport transport; + clap_transport transport; // Audio buffers, they must have the same count as specified // by clap_plugin_audio_ports->get_count(). @@ -234,21 +225,21 @@ struct clap_process { // // If a plugin does not implement clap_plugin_audio_ports, // then it gets a default stereo input and output. - const struct clap_audio_buffer *audio_inputs; - const struct clap_audio_buffer *audio_outputs; - int32_t audio_inputs_count; - int32_t audio_outputs_count; + const clap_audio_buffer *audio_inputs; + const clap_audio_buffer *audio_outputs; + int32_t audio_inputs_count; + int32_t audio_outputs_count; /* events */ - const struct clap_event_list *in_events; - const struct clap_event_list *out_events; -}; + const clap_event_list *in_events; + const clap_event_list *out_events; +} clap_process; ////////// // HOST // ////////// -struct clap_host { +typedef struct clap_host { int32_t clap_version; // initialized to CLAP_VERSION void *host_data; // reserved pointer for the host @@ -260,15 +251,15 @@ struct clap_host { /* Returns the size of the original string. If this is larger than size, then * the function did not have enough space to copy all the data. * [thread-safe] */ - int32_t (*get_attribute)(struct clap_host *host, - const char * attr, - char * buffer, - int32_t size); + int32_t (*get_attribute)(clap_host * host, + const char *attr, + char * buffer, + int32_t size); /* Query an extension. * [thread-safe] */ - const void *(*extension)(struct clap_host *host, const char *extension_id); -}; + const void *(*extension)(clap_host *host, const char *extension_id); +} clap_host; //////////// // PLUGIN // @@ -276,7 +267,7 @@ struct clap_host { /* bitfield * This gives an hint to the host what the plugin might do. */ -enum clap_plugin_type { +typedef enum clap_plugin_type { /* Instruments can play notes, and generate audio */ CLAP_PLUGIN_INSTRUMENT = (1 << 0), @@ -291,9 +282,9 @@ enum clap_plugin_type { /* Analyze audio and/or events, and produces analysis results, * but doesn't change audio. */ CLAP_PLUGIN_ANALYZER = (1 << 3), -}; +} clap_plugin_type; -struct clap_plugin { +typedef struct clap_plugin { int32_t clap_version; // initialized to CLAP_VERSION void *plugin_data; // reserved pointer for the plugin @@ -308,36 +299,36 @@ struct clap_plugin { char id[CLAP_ID_SIZE]; // plugin id, eg: "com.u-he.diva" char version[CLAP_NAME_SIZE]; // the plugin version, eg: "1.3.2" - uint64_t plugin_type; // bitfield of enum clap_plugin_type + uint64_t plugin_type; // bitfield of clap_plugin_type /* Free the plugin and its resources. * It is not required to deactivate the plugin prior to this call. */ - void (*destroy)(struct clap_plugin *plugin); + void (*destroy)(clap_plugin *plugin); /* Copy at most size of the attribute's value into buffer. * This function must place a '\0' byte at the end of the string. * Returns the size of the original string or 0 if there is no * value for this attributes. * [thread-safe] */ - int32_t (*get_attribute)(struct clap_plugin *plugin, - const char * attr, - char * buffer, - int32_t size); + int32_t (*get_attribute)(clap_plugin *plugin, + const char * attr, + char * buffer, + int32_t size); /* activation/deactivation * [main-thread] */ - bool (*activate)(struct clap_plugin *plugin, int sample_rate); - void (*deactivate)(struct clap_plugin *plugin); + bool (*activate)(clap_plugin *plugin, int sample_rate); + void (*deactivate)(clap_plugin *plugin); /* process audio, events, ... * [audio-thread] */ - enum clap_process_status (*process)(struct clap_plugin * plugin, - const struct clap_process *process); + clap_process_status (*process)(clap_plugin * plugin, + const clap_process *process); /* query an extension * [thread-safe] */ - const void *(*extension)(struct clap_plugin *plugin, const char *id); -}; + const void *(*extension)(clap_plugin *plugin, const char *id); +} clap_plugin; /* This interface is the entry point of the dynamic library. * @@ -353,14 +344,12 @@ struct clap_plugin_entry { /* Create a clap_plugin by its index. * Returns null in case of error. * [thread-safe] */ - struct clap_plugin *(*create_plugin_by_index)(struct clap_host *host, - int32_t index); + clap_plugin *(*create_plugin_by_index)(clap_host *host, int32_t index); /* Create a clap_plugin by its plugin_id. * Returns null in case of error. * [thread-safe] */ - struct clap_plugin *(*create_plugin_by_id)(struct clap_host *host, - const char * plugin_id); + clap_plugin *(*create_plugin_by_id)(clap_host *host, const char *plugin_id); }; /* Entry point */ diff --git a/include/clap/ext/audio-ports.h b/include/clap/ext/audio-ports.h @@ -8,7 +8,7 @@ extern "C" { #define CLAP_EXT_AUDIO_PORTS "clap/audio-ports" -enum clap_audio_port_channel_mapping { +typedef enum clap_audio_port_channel_mapping { CLAP_AUDIO_PORT_UNSPECIFIED = 0, CLAP_AUDIO_PORT_MONO = 1, @@ -18,51 +18,49 @@ enum clap_audio_port_channel_mapping { // front left, front right, center, low, surround left, surround right // surround back left, surround back right CLAP_AUDIO_PORT_SURROUND = 3, -}; +} clap_audio_port_channel_mapping; -struct clap_audio_port_info { +typedef struct clap_audio_port_info { char name[CLAP_NAME_SIZE]; // displayable name - bool is_main; // there can only be 1 main input and output - bool is_cv; // control voltage - bool supports_64_bits; // 32 bit support is mandatory, the host chooses - // between 32 and 64. + bool is_main; // there can only be 1 main input and output + bool is_cv; // control voltage + bool supports_64_bits; // 32 bit support is mandatory, the host chooses + // between 32 and 64. bool supports_in_place; // if true the daw can use the same buffer for input // and output, only for main input to main output - int32_t channel_count; - enum clap_audio_port_channel_mapping channel_mapping; -}; + int32_t channel_count; + clap_audio_port_channel_mapping channel_mapping; +} clap_audio_port_info; // The audio ports scan has to be done while the plugin is deactivated. -struct clap_plugin_audio_ports { +typedef struct clap_plugin_audio_ports { // number of ports, for either input or output // [main-thread] - int32_t (*get_count)(struct clap_plugin *plugin, bool is_input); + int32_t (*get_count)(clap_plugin *plugin, bool is_input); // get info about about an audio port. // [main-thread] - void (*get_info)(struct clap_plugin * plugin, - int32_t index, - bool is_input, - struct clap_audio_port_info *info); + void (*get_info)(clap_plugin * plugin, + int32_t index, + bool is_input, + clap_audio_port_info *info); // Returns the port latency. // [main-thread] - int32_t (*get_latency)(struct clap_plugin *plugin, - int32_t index, - bool is_input); -}; + int32_t (*get_latency)(clap_plugin *plugin, int32_t index, bool is_input); +} clap_plugin_audio_ports; -struct clap_host_audio_ports { +typedef struct clap_host_audio_ports { // Tell the host that the plugin ports has changed. // The host shall deactivate the plugin and then scan the ports again. // [main-thread] - void (*changed)(struct clap_host *host, struct clap_plugin *plugin); + void (*changed)(clap_host *host, clap_plugin *plugin); // Tell the host that the latency changed. // The host should call get_port_latency on each ports. // [main-thread] - void (*latency_changed)(struct clap_host *host, struct clap_plugin *plugin); -}; + void (*latency_changed)(clap_host *host, clap_plugin *plugin); +} clap_host_audio_ports; #ifdef __cplusplus } diff --git a/include/clap/ext/draft/ev-loop.h b/include/clap/ext/draft/ev-loop.h @@ -13,36 +13,33 @@ enum { CLAP_EV_LOOP_WRITE = 2, }; -typedef void (*clap_fd_callback)(struct clap_plugin *plugin, int fd, int flags); +typedef void (*clap_fd_callback)(clap_plugin *plugin, int fd, int flags); -typedef void (*clap_timer_callback)(struct clap_plugin *plugin, - uint64_t timer_id); +typedef void (*clap_timer_callback)(clap_plugin *plugin, uint64_t timer_id); -struct clap_host_ev_loop { +typedef struct clap_host_ev_loop { // [main-thread] - bool (*register_timer)(struct clap_host * host, - struct clap_plugin *plugin, + bool (*register_timer)(clap_host * host, + clap_plugin * plugin, int64_t period_ms, clap_timer_callback callback, uint64_t * timer_id); // [main-thread] - bool (*unregister_timer)(struct clap_host * host, - struct clap_plugin *plugin, - uint64_t timer_id); + bool (*unregister_timer)(clap_host * host, + clap_plugin *plugin, + uint64_t timer_id); // [main-thread] - bool (*register_fd)(struct clap_host * host, - struct clap_plugin *plugin, - int fd, - int flags, - clap_fd_callback callback); + bool (*register_fd)(clap_host * host, + clap_plugin * plugin, + int fd, + int flags, + clap_fd_callback callback); // [main-thread] - bool (*unregister_fd)(struct clap_host * host, - struct clap_plugin *plugin, - int fd); -}; + bool (*unregister_fd)(clap_host *host, clap_plugin *plugin, int fd); +} clap_host_ev_loop; #ifdef __cplusplus } diff --git a/include/clap/ext/draft/key-name.h b/include/clap/ext/draft/key-name.h @@ -8,29 +8,27 @@ extern "C" { #define CLAP_EXT_NOTE_NAME "clap/draft/note-name" -struct clap_note_name { +typedef struct clap_note_name { char name[CLAP_NAME_SIZE]; int8_t key; int8_t channel; // -1 for every channels -}; +} clap_note_name; -struct clap_plugin_note_name { +typedef struct clap_plugin_note_name { // Return the number of note names // [main-thread] - int (*count)(struct clap_plugin *plugin); + int (*count)(clap_plugin *plugin); // Returns true on success and stores the result into note_name // [main-thread] - bool (*get)(struct clap_plugin * plugin, - int index, - struct clap_note_name *note_name); -}; + bool (*get)(clap_plugin *plugin, int index, clap_note_name *note_name); +} clap_plugin_note_name; -struct clap_host_note_name { +typedef struct clap_host_note_name { // Informs the host that the note names has changed. // [main-thread] - void (*changed)(struct clap_host *host, struct clap_plugin *plugin); -}; + void (*changed)(clap_host *host, clap_plugin *plugin); +} clap_host_note_name; #ifdef __cplusplus } diff --git a/include/clap/ext/draft/preset-load.h b/include/clap/ext/draft/preset-load.h @@ -8,11 +8,11 @@ extern "C" { #define CLAP_EXT_PRESET_LOAD "clap/draft/preset-load" -struct clap_plugin_preset_load { +typedef struct clap_plugin_preset_load { // Loads a preset in the plugin native preset file format from a path. // [main-thread] - bool (*load_from_file)(struct clap_plugin *plugin, const char *path); -}; + bool (*load_from_file)(clap_plugin *plugin, const char *path); +} clap_plugin_preset_load; #ifdef __cplusplus } diff --git a/include/clap/ext/draft/thread-check.h b/include/clap/ext/draft/thread-check.h @@ -10,15 +10,15 @@ extern "C" { // This interface is useful to do runtime checks and make // sure that the functions are called on the correct threads. -struct clap_host_thread_check { +typedef struct clap_host_thread_check { // Returns true if the "this" thread is the main thread. // [thread-safe] - bool (*is_main_thread)(struct clap_host *host); + bool (*is_main_thread)(clap_host *host); // Returns true if the "this" thread is one of the audio threads. // [thread-safe] - bool (*is_audio_thread)(struct clap_host *host); -}; + bool (*is_audio_thread)(clap_host *host); +} clap_host_thread_check; #ifdef __cplusplus } diff --git a/include/clap/ext/draft/tuning.h b/include/clap/ext/draft/tuning.h @@ -9,19 +9,19 @@ extern "C" { #define CLAP_EXT_IDLE "clap/draft/tuning" // This extension is to providet a dynamic tuning table to the plugin. -struct clap_host_tuning { +typedef struct clap_host_tuning { // The plugin can ask the host, the frequency of a given key, // at a given time in case the tuning is automated. // Returns the frequency in Hz. // The plugin is not supposed to query it for each samples, // but at a rate that makes sense for low frequency modulations. // [audio-thread] - double (*key_freq)(struct clap_host * host, - struct clap_plugin *plugin, - int32_t key, - int32_t channel, - int32_t frameIndex); -}; + double (*key_freq)(clap_host * host, + clap_plugin *plugin, + int32_t key, + int32_t channel, + int32_t frameIndex); +} clap_host_tuning; #ifdef __cplusplus } diff --git a/include/clap/ext/draft/vst2-convert.h b/include/clap/ext/draft/vst2-convert.h @@ -5,42 +5,41 @@ extern "C" { #endif #include "../../clap.h" +#include "../../stream.h" #define CLAP_EXT_VST2_CONVERT "clap/draft/vst2-convert" -struct clap_plugin_vst2_convert { +typedef struct clap_plugin_vst2_convert { // Copies the name and VST2 plugin id that we can convert from. // Returns the lenght of the name. // [thread-safe] - int32_t (*get_vst2_plugin_id)(struct clap_plugin *plugin, - uint32_t * vst2_plugin_id, - char * name, - uint32_t name_size); + int32_t (*get_vst2_plugin_id)(clap_plugin *plugin, + uint32_t * vst2_plugin_id, + char * name, + uint32_t name_size); // Loads the plugin state from stream using the VST2 chunk. // [main-thread] - bool (*restore_vst2_state)(struct clap_plugin * plugin, - struct clap_istream *stream); + bool (*restore_vst2_state)(clap_plugin *plugin, clap_istream *stream); // converts the vst2 param id and normalized value to clap param id and // normalized value. // [thread-safe] - bool (*convert_normalize_value)( - struct clap_plugin * plugin, - uint32_t vst2_param_id, - double vst2_normalized_value, - uint32_t * clap_param_id, - union clap_param_value *clap_normalized_value); + bool (*convert_normalize_value)(clap_plugin * plugin, + uint32_t vst2_param_id, + double vst2_normalized_value, + uint32_t * clap_param_id, + clap_param_value *clap_normalized_value); // converts the vst2 param id and plain value to clap param id and // plain value. // [thread-safe] - bool (*convert_plain_value)(struct clap_plugin * plugin, - uint32_t vst2_param_index, - double vst2_plain_value, - uint32_t * clap_param_index, - union clap_param_value *clap_plain_value); -}; + bool (*convert_plain_value)(clap_plugin * plugin, + uint32_t vst2_param_index, + double vst2_plain_value, + uint32_t * clap_param_index, + clap_param_value *clap_plain_value); +} clap_plugin_vst2_convert; #ifdef __cplusplus } diff --git a/include/clap/ext/draft/vst3-convert.h b/include/clap/ext/draft/vst3-convert.h @@ -5,6 +5,7 @@ extern "C" { #endif #include "../../clap.h" +#include "../../stream.h" #define CLAP_EXT_VST3_CONVERT "clap/draft/vst3-convert" @@ -12,32 +13,32 @@ 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)(struct clap_plugin *plugin, + int32_t (*get_vst3_plugin_id)(clap_plugin *plugin, uint8_t * vst3_plugin_id); // Loads the plugin state from stream using the vst3 chunk. // [main-thread] - bool (*restore_vst3_state)(struct clap_plugin * plugin, - struct clap_istream *stream); + bool (*restore_vst3_state)(clap_plugin * plugin, + clap_istream *stream); // converts the VST3 param id and normalized value to clap param id and // normalized value. // [thread-safe] bool (*convert_normalize_value)( - struct clap_plugin * plugin, + clap_plugin * plugin, uint32_t vst3_param_id, double vst3_normalized_value, uint32_t * clap_param_id, - union clap_param_value *clap_normalized_value); + clap_param_value *clap_normalized_value); // converts the vst3 param id and plain value to clap param id and // plain value. // [thread-safe] - bool (*convert_plain_value)(struct clap_plugin * plugin, + bool (*convert_plain_value)(clap_plugin * plugin, uint32_t vst3_param_index, double vst3_plain_value, uint32_t * clap_param_index, - union clap_param_value *clap_plain_value); + clap_param_value *clap_plain_value); }; #ifdef __cplusplus diff --git a/include/clap/ext/gui-cocoa.h b/include/clap/ext/gui-cocoa.h @@ -8,13 +8,13 @@ extern "C" { #define CLAP_EXT_GUI_COCOA "clap/gui/cocoa" -struct clap_plugin_embed_cocoa { +typedef struct clap_plugin_embed_cocoa { // [main-thread] - bool (*attach)(struct clap_plugin *plugin, void *nsView); + bool (*attach)(clap_plugin *plugin, void *nsView); // [main-thread] - bool (*detach)(struct clap_plugin *plugin); -}; + bool (*detach)(clap_plugin *plugin); +} clap_plugin_embed_cocoa; #ifdef __cplusplus } diff --git a/include/clap/ext/gui-free-standing.h b/include/clap/ext/gui-free-standing.h @@ -8,14 +8,14 @@ extern "C" { #endif -struct clap_plugin_gui_free_standing { +typedef struct clap_plugin_gui_free_standing { // Opens the plugin window as a free standing window, which means it is not // embedded in the host and managed by the plugin. // [main-thread] - bool (*open)(struct clap_plugin *plugin, - const char * display_name, - unsigned long window); -}; + bool (*open)(clap_plugin * plugin, + const char * display_name, + unsigned long window); +} clap_plugin_gui_free_standing; #ifdef __cplusplus } diff --git a/include/clap/ext/gui-win32.h b/include/clap/ext/gui-win32.h @@ -11,13 +11,13 @@ extern "C" { // we don't want to include windows.h from this file. typedef void *clap_hwnd; -struct clap_plugin_gui_win32 { +typedef struct clap_plugin_gui_win32 { // [main-thread] - bool (*attach)(struct clap_plugin *plugin, clap_hwnd window); + bool (*attach)(clap_plugin *plugin, clap_hwnd window); // [main-thread] - bool (*detach)(struct clap_plugin *plugin); -}; + bool (*detach)(clap_plugin *plugin); +} clap_plugin_gui_win32; #ifdef __cplusplus } diff --git a/include/clap/ext/gui-x11.h b/include/clap/ext/gui-x11.h @@ -8,16 +8,16 @@ extern "C" { #endif -struct clap_plugin_gui_x11 { +typedef struct clap_plugin_gui_x11 { // Use the protocol XEmbed // [main-thread] - bool (*attach)(struct clap_plugin *plugin, - const char * display_name, - unsigned long window); + bool (*attach)(clap_plugin * plugin, + const char * display_name, + unsigned long window); // [main-thread] - bool (*detach)(struct clap_plugin *plugin); -}; + bool (*detach)(clap_plugin *plugin); +} clap_plugin_gui_x11; #ifdef __cplusplus } diff --git a/include/clap/ext/gui.h b/include/clap/ext/gui.h @@ -9,30 +9,28 @@ extern "C" { #endif -struct clap_plugin_gui { +typedef struct clap_plugin_gui { // Get the size of the plugin UI. // [main-thread] - void (*get_size)(struct clap_plugin *plugin, - int32_t * width, - int32_t * height); + void (*get_size)(clap_plugin *plugin, int32_t *width, int32_t *height); // Sets the GUI scaling factor. // [main-thread] - void (*set_scale)(struct clap_plugin *plugin, double scale); + void (*set_scale)(clap_plugin *plugin, double scale); - void (*show)(struct clap_plugin *plugin); - void (*hide)(struct clap_plugin *plugin); + void (*show)(clap_plugin *plugin); + void (*hide)(clap_plugin *plugin); // [main-thread] - void (*close)(struct clap_plugin *plugin); -}; + void (*close)(clap_plugin *plugin); +} clap_plugin_gui; -struct clap_host_gui { +typedef struct clap_host_gui { /* Request the host to resize the client area to width, height. * Return true on success, false otherwise. * [thread-safe] */ - bool (*resize)(struct clap_host *host, int32_t width, int32_t height); -}; + bool (*resize)(clap_host *host, int32_t width, int32_t height); +} clap_host_gui; #ifdef __cplusplus } diff --git a/include/clap/ext/idle.h b/include/clap/ext/idle.h @@ -8,11 +8,11 @@ extern "C" { #define CLAP_EXT_IDLE "clap/idle" -struct clap_plugin_idle { +typedef struct clap_plugin_idle { // IDLE time that can be used by the plugin on the main thread // [main-thread] - void (*idle)(struct clap_plugin *plugin); -}; + void (*idle)(clap_plugin *plugin); +} clap_plugin_idle; #ifdef __cplusplus } 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" -enum clap_log_severity { +typedef enum clap_log_severity { CLAP_LOG_DEBUG = 0, CLAP_LOG_INFO = 1, CLAP_LOG_WARNING = 2, @@ -17,16 +17,16 @@ enum clap_log_severity { // This severity should be used to report misbehaviour of the host CLAP_LOG_HOST_MISBEHAVING = 5, -}; +} clap_log_severity; -struct clap_host_log { +typedef struct clap_host_log { // Log a message through the host. // [thread-safe] - void (*log)(struct clap_host * host, - struct clap_plugin * plugin, - enum clap_log_severity severity, - const char * msg); -}; + void (*log)(clap_host * host, + clap_plugin * plugin, + clap_log_severity severity, + const char * msg); +} clap_host_log; #ifdef __cplusplus } diff --git a/include/clap/ext/params.h b/include/clap/ext/params.h @@ -8,15 +8,15 @@ extern "C" { #define CLAP_EXT_PARAMS "clap/params" -enum clap_param_type { +typedef enum clap_param_type { 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; /* This describes the parameter and provides the current value */ -struct clap_param_info { +typedef struct clap_param_info { /* param info */ int32_t index; int32_t id; // a string which identify the param @@ -31,86 +31,81 @@ struct clap_param_info { bool is_bypass; /* value */ - enum clap_param_type type; - 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 -}; + clap_param_type type; + clap_param_value min_value; // minimum plain value + clap_param_value max_value; // maximum plain value + clap_param_value default_value; // default plain value +} clap_param_info; -struct clap_plugin_params { +typedef struct clap_plugin_params { // Returns the number of parameters. // [main-thread] - int32_t (*count)(struct clap_plugin *plugin); + int32_t (*count)(clap_plugin *plugin); // 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); + bool (*get_info)(clap_plugin * plugin, + int32_t param_index, + clap_param_info *param_info); // Gets the parameter plain value. // [main-thread] - union clap_param_value (*get_param_value)(struct clap_plugin *plugin, - int32_t param_index); + clap_param_value (*get_value)(clap_plugin *plugin, int32_t param_index); // 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_param_value)(struct clap_plugin * plugin, - int32_t param_index, - union clap_param_value plain_value); + void (*set_param_value)(clap_plugin * plugin, + int32_t param_index, + clap_param_value plain_value); // Normalization only exists for float values // [thread-safe,lock-wait-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); + double (*plain_to_norm)(clap_plugin *plugin, + int32_t param_index, + double plain_value); + double (*norm_to_plain)(clap_plugin *plugin, + int32_t param_index, + double normalized_value); // Formats the display text for the given parameter value. // [thread-safe,lock-wait-free] - bool (*value_to_text)(struct clap_plugin * plugin, - int32_t param_index, - union clap_param_value plain_value, - char * display, - uint32_t size); - - bool (*text_to_value)(struct clap_plugin * plugin, - int32_t param_index, - const char * display, - union clap_param_value *plain_value); -}; - -struct clap_host_params { + bool (*value_to_text)(clap_plugin * plugin, + int32_t param_index, + clap_param_value plain_value, + char * display, + uint32_t size); + + bool (*text_to_value)(clap_plugin * plugin, + int32_t param_index, + const char * display, + clap_param_value *plain_value); +} clap_plugin_params; + +typedef struct clap_host_params { /* [main-thread] */ - void (*touch_begin)(struct clap_host * host, - struct clap_plugin *plugin, - int32_t index); + void (*touch_begin)(clap_host *host, clap_plugin *plugin, int32_t index); /* [main-thread] */ - void (*touch_end)(struct clap_host * host, - struct clap_plugin *plugin, - int32_t index); + void (*touch_end)(clap_host *host, clap_plugin *plugin, int32_t index); // If the plugin is activated, the host must send a parameter update // in the next process call to update the audio processor. // Only for value changes that happens in the gui. // [main-thread] - void (*changed)(struct clap_host * host, - struct clap_plugin * plugin, - int32_t index, - union clap_param_value plain_value); + void (*changed)(clap_host * host, + clap_plugin * plugin, + int32_t index, + clap_param_value plain_value); // [main-thread] - void (*rescan)(struct clap_host *host, struct clap_plugin *plugin); - void (*rescan_params)(struct clap_host * host, - struct clap_plugin *plugin, - const uint32_t * indexes, - uint32_t count); -}; + void (*rescan)(clap_host *host, clap_plugin *plugin); + void (*rescan_params)(clap_host * host, + clap_plugin * plugin, + const uint32_t *indexes, + uint32_t count); +} clap_host_params; #ifdef __cplusplus } diff --git a/include/clap/ext/render.h b/include/clap/ext/render.h @@ -8,21 +8,20 @@ extern "C" { #endif -enum clap_plugin_render_mode { +typedef enum clap_plugin_render_mode { /* 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; // The render extension is used to let the plugin know if it has "realtime" // pressure to process. -struct clap_plugin_render { +typedef struct clap_plugin_render { // [main-thread] - void (*set_render_mode)(struct clap_plugin * plugin, - enum clap_plugin_render_mode mode); -}; + void (*set_render_mode)(clap_plugin *plugin, clap_plugin_render_mode mode); +} clap_plugin_render; #ifdef __cplusplus } diff --git a/include/clap/ext/state.h b/include/clap/ext/state.h @@ -1,7 +1,7 @@ #pragma once #include "../clap.h" -#include "stream.h" +#include "../stream.h" #define CLAP_EXT_STATE "clap/state" @@ -9,21 +9,21 @@ extern "C" { #endif -struct clap_plugin_state { +typedef struct clap_plugin_state { /* Saves the plugin state into stream. * [main-thread] */ - bool (*save)(struct clap_plugin *plugin, struct clap_ostream *stream); + bool (*save)(clap_plugin *plugin, clap_ostream *stream); /* Loads the plugin state from stream. * [main-thread] */ - bool (*restore)(struct clap_plugin *plugin, struct clap_istream *stream); -}; + bool (*restore)(clap_plugin *plugin, clap_istream *stream); +} clap_plugin_state; -struct clap_host_state { +typedef struct clap_host_state { /* Tell the host that the plugin state has changed. * [thread-safe] */ - void (*set_dirty)(struct clap_host *host, struct clap_plugin *plugin); -}; + void (*set_dirty)(clap_host *host, clap_plugin *plugin); +} clap_host_state; #ifdef __cplusplus } diff --git a/include/clap/ext/stream.h b/include/clap/ext/stream.h @@ -1,30 +0,0 @@ -#pragma once - -#include <stdint.h> - -#ifdef __cplusplus -extern "C" { -#endif - -struct clap_istream { - void *ctx; - - /* returns the number of bytes read. - * 0 for end of file. - * -1 on error. */ - int64_t (*read)(struct clap_istream *stream, void *buffer, uint64_t size); -}; - -struct clap_ostream { - void *ctx; - - /* returns the number of bytes written. - * -1 on error. */ - int64_t (*write)(struct clap_istream *stream, - const void * buffer, - uint64_t size); -}; - -#ifdef __cplusplus -} -#endif -\ No newline at end of file diff --git a/include/clap/stream.h b/include/clap/stream.h @@ -0,0 +1,28 @@ +#pragma once + +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct clap_istream { + void *ctx; + + /* returns the number of bytes read. + * 0 for end of file. + * -1 on error. */ + int64_t (*read)(clap_istream *stream, void *buffer, uint64_t size); +} clap_istream; + +typedef struct clap_ostream { + void *ctx; + + /* returns the number of bytes written. + * -1 on error. */ + int64_t (*write)(clap_istream *stream, const void *buffer, uint64_t size); +} clap_ostream; + +#ifdef __cplusplus +} +#endif +\ No newline at end of file