clap

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

commit e0dc930e0c8fc760e57fe0c37b42e6d5dd5700e5
parent 342ce290208deeb2b51cbf68740b57f33b20f789
Author: Alexandre BIQUE <bique.alexandre@gmail.com>
Date:   Sat, 24 Apr 2021 21:29:41 +0200

more work

Diffstat:
Minclude/clap/clap.h | 4+++-
Minclude/clap/ext/audio-ports.h | 17+++++++++++------
Minclude/clap/ext/draft/ev-loop.h | 2+-
Minclude/clap/ext/draft/key-name.h | 20++++++++++----------
Minclude/clap/ext/draft/log.h | 3+++
Ainclude/clap/ext/draft/tuning.h | 29+++++++++++++++++++++++++++++
Ainclude/clap/ext/draft/vst2-convert.h | 48++++++++++++++++++++++++++++++++++++++++++++++++
Ainclude/clap/ext/draft/vst3-convert.h | 46++++++++++++++++++++++++++++++++++++++++++++++
Minclude/clap/ext/gui.h | 5+++++
Minclude/clap/ext/params.h | 27+++++++++++++++------------
10 files changed, 171 insertions(+), 30 deletions(-)

diff --git a/include/clap/clap.h b/include/clap/clap.h @@ -47,7 +47,7 @@ extern "C" { # define CLAP_EXPORT __declspec(dllexport) # endif #else -# if __GNUC__ >= 4 +# if __GNUC__ >= 4 || defined (__clang__) # define CLAP_EXPORT __attribute__((visibility("default"))) # else # define CLAP_EXPORT @@ -204,6 +204,8 @@ struct clap_audio_buffer { }; struct clap_transport { + bool is_free_running; // free running host, no info provided + bool is_playing; bool is_recording; bool is_looping; diff --git a/include/clap/ext/audio-ports.h b/include/clap/ext/audio-ports.h @@ -21,12 +21,17 @@ enum clap_audio_port_channel_mapping { }; struct clap_audio_port_info { - char name[CLAP_NAME_SIZE]; // useful in the debugger - bool is_input; - bool is_main; - bool is_cv; // control voltage - bool supports_64_bits; // 32 bit support is mandatory, the host chooses between 32 and 64. - int32_t channel_count; + char name[CLAP_NAME_SIZE]; // displayable name + bool is_input; + bool is_main; + 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 + int32_t in_place_pair; // index to the buffer that correspond to this one for + // in-place processing. + int32_t channel_count; enum clap_audio_port_channel_mapping channel_mapping; }; diff --git a/include/clap/ext/draft/ev-loop.h b/include/clap/ext/draft/ev-loop.h @@ -29,7 +29,7 @@ struct clap_host_ev_loop { // [main-thread] bool (*unregister_timer)(struct clap_host * host, struct clap_plugin *plugin, - uint64_t * timer_id); + uint64_t timer_id); // [main-thread] bool (*register_fd)(struct clap_host * host, diff --git a/include/clap/ext/draft/key-name.h b/include/clap/ext/draft/key-name.h @@ -6,28 +6,28 @@ extern "C" { #include "../../clap.h" -#define CLAP_EXT_KEY_NAME "clap/draft/key-name" +#define CLAP_EXT_NOTE_NAME "clap/draft/note-name" -struct clap_key_name { +struct clap_note_name { char name[CLAP_NAME_SIZE]; int8_t key; int8_t channel; // -1 for every channels }; -struct clap_plugin_key_name { - // Return the number of key names +struct clap_plugin_note_name { + // Return the number of note names // [main-thread] int (*count)(struct clap_plugin *plugin); - // Returns true on success and stores the result into key_name + // Returns true on success and stores the result into note_name // [main-thread] - bool (*get)(struct clap_plugin * plugin, - int index, - struct clap_key_name *key_name); + bool (*get)(struct clap_plugin * plugin, + int index, + struct clap_note_name *note_name); }; -struct clap_host_key_name { - // Informs the host that the drum map has changed. +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); }; diff --git a/include/clap/ext/draft/log.h b/include/clap/ext/draft/log.h @@ -14,6 +14,9 @@ enum clap_log_severity { CLAP_LOG_WARNING = 2, CLAP_LOG_ERROR = 3, CLAP_LOG_FATAL = 4, + + // This severity should be used to report misbehaviour of the host + CLAP_LOG_HOST_MISBEHAVING = 5, }; struct clap_host_log { diff --git a/include/clap/ext/draft/tuning.h b/include/clap/ext/draft/tuning.h @@ -0,0 +1,28 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "../../clap.h" + +#define CLAP_EXT_IDLE "clap/draft/tuning" + +// This extension is to providet a dynamic tuning table to the plugin. +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); +}; + +#ifdef __cplusplus +} +#endif +\ No newline at end of file diff --git a/include/clap/ext/draft/vst2-convert.h b/include/clap/ext/draft/vst2-convert.h @@ -0,0 +1,47 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "../../clap.h" + +#define CLAP_EXT_VST2_CONVERT "clap/draft/vst2-convert" + +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); + + // Loads the plugin state from stream using the VST2 chunk. + // [main-thread] + bool (*restore_vst2_state)(struct clap_plugin * plugin, + struct 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); + + // 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); +}; + +#ifdef __cplusplus +} +#endif +\ No newline at end of file diff --git a/include/clap/ext/draft/vst3-convert.h b/include/clap/ext/draft/vst3-convert.h @@ -0,0 +1,45 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "../../clap.h" + +#define CLAP_EXT_VST3_CONVERT "clap/draft/vst3-convert" + +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, + 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); + + // 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, + uint32_t vst3_param_id, + double vst3_normalized_value, + uint32_t * clap_param_id, + union 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, + uint32_t vst3_param_index, + double vst3_plain_value, + uint32_t * clap_param_index, + union clap_param_value *clap_plain_value); +}; + +#ifdef __cplusplus +} +#endif +\ No newline at end of file diff --git a/include/clap/ext/gui.h b/include/clap/ext/gui.h @@ -10,12 +10,17 @@ extern "C" { #endif struct clap_plugin_gui { + void (*open)(struct clap_plugin *plugin); + // Get the size of the plugin UI. // [main-thread] void (*get_size)(struct clap_plugin *plugin, int32_t * width, int32_t * height); + void (*show)(struct clap_plugin *plugin); + void (*hide)(struct clap_plugin *plugin); + // [main-thread] void (*close)(struct clap_plugin *plugin); }; diff --git a/include/clap/ext/params.h b/include/clap/ext/params.h @@ -72,16 +72,16 @@ struct clap_plugin_params { // Formats the display text for the given parameter value. // [thread-safe,lock-wait-free] - bool (*get_param_display)(struct clap_plugin * plugin, - int32_t param_index, - union clap_param_value plain_value, - char * display, - uint32_t size); - - bool (*get_param_value_from_display)(struct clap_plugin * plugin, - int32_t param_index, - const char * display, - union clap_param_value *plain_value); + 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 { @@ -102,11 +102,14 @@ struct clap_host_params { void (*changed)(struct clap_host * host, struct clap_plugin * plugin, int32_t index, - union clap_param_value plain_value, - bool is_recordable); + union 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); }; #ifdef __cplusplus