clap

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

commit 684637631358bf4dcdad8abf61d97f6f170b2037
parent fea5fce72c160426870520cbc2da0a7de4f8edb4
Author: Alexandre BIQUE <bique.alexandre@gmail.com>
Date:   Mon, 17 May 2021 23:29:32 +0200

Clean up and work on plugin file reference

Diffstat:
Minclude/clap/all.h | 8++++----
Minclude/clap/events.h | 4+++-
Dinclude/clap/ext/draft/event-loop.h | 52----------------------------------------------------
Ainclude/clap/ext/draft/file-reference.h | 39+++++++++++++++++++++++++++++++++++++++
Dinclude/clap/ext/draft/thread-check.h | 26--------------------------
Ainclude/clap/ext/event-loop.h | 52++++++++++++++++++++++++++++++++++++++++++++++++++++
Ainclude/clap/ext/thread-check.h | 26++++++++++++++++++++++++++
Minclude/clap/string-sizes.h | 1+
8 files changed, 125 insertions(+), 83 deletions(-)

diff --git a/include/clap/all.h b/include/clap/all.h @@ -13,15 +13,16 @@ #include "ext/render.h" #include "ext/state.h" #include "ext/latency.h" +#include "ext/thread-check.h" +#include "ext/event-loop.h" #include "ext/draft/event-filter.h" -#include "ext/draft/event-loop.h" #include "ext/draft/key-name.h" #include "ext/draft/preset-load.h" #include "ext/draft/remote-controls.h" -#include "ext/draft/thread-check.h" #include "ext/draft/thread-pool.h" #include "ext/draft/track-info.h" #include "ext/draft/tuning.h" +#include "ext/draft/file-reference.h" #include "ext/draft/vst2-convert.h" -#include "ext/draft/vst3-convert.h" -\ No newline at end of file +#include "ext/draft/vst3-convert.h" diff --git a/include/clap/events.h b/include/clap/events.h @@ -68,9 +68,11 @@ typedef union clap_param_value { typedef struct clap_event_param { int32_t key; int32_t channel; - clap_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_param_value modulated_value; + double modulation_ramp; } clap_event_param; typedef struct clap_event_transport { diff --git a/include/clap/ext/draft/event-loop.h b/include/clap/ext/draft/event-loop.h @@ -1,51 +0,0 @@ -#pragma once - -#include <stddef.h> -#ifdef __cplusplus -extern "C" { -#endif - -#include "../../clap.h" - -#define CLAP_EXT_EVENT_LOOP "clap/draft/event-loop" - -#ifdef _WIN32 -typedef void *clap_fd; -#else -typedef int clap_fd; -#endif - -enum { - CLAP_FD_READ = 1 << 0, - CLAP_FD_WRITE = 1 << 1, - CLAP_FD_ERROR = 1 << 2, -}; - -typedef struct clap_plugin_event_loop { - // [main-thread] - void (*on_timer)(clap_plugin *plugin, clap_id timer_id); - - // [main-thread] - void (*on_fd)(clap_plugin *plugin, clap_fd fd, uint32_t flags); -} clap_plugin_event_loop; - -typedef struct clap_host_event_loop { - // [main-thread] - bool (*register_timer)(clap_host *host, uint32_t period_ms, clap_id *timer_id); - - // [main-thread] - bool (*unregister_timer)(clap_host *host, clap_id timer_id); - - // [main-thread] - bool (*register_fd)(clap_host *host, clap_fd fd, uint32_t flags); - - // [main-thread] - bool (*modify_fd)(clap_host *host, clap_fd fd, uint32_t flags); - - // [main-thread] - bool (*unregister_fd)(clap_host *host, clap_fd fd); -} clap_host_event_loop; - -#ifdef __cplusplus -} -#endif -\ No newline at end of file diff --git a/include/clap/ext/draft/file-reference.h b/include/clap/ext/draft/file-reference.h @@ -0,0 +1,39 @@ +#pragma once + +#include "../../clap.h" + +#define CLAP_EXT_FILE_REFERENCE "clap/file-reference" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct clap_file_reference { + clap_id resource_id; + char path[CLAP_PATH_SIZE]; +} clap_file_reference; + +typedef struct clap_plugin_file_reference { + // returns the number of file reference this plugin has + // [main-thread] + uint32_t (*count)(clap_plugin *plugin); + + // gets the file reference at index + // returns true on success + // [main-thread] + bool (*get)(clap_plugin *plugin, uint32_t index, clap_file_reference *file_reference); + + // updates the path to a file reference + // [main-thread] + bool (*set)(clap_plugin *plugin, clap_id resource_id, const char *path); +} clap_plugin_file_reference; + +typedef struct clap_host_file_reference { + // informs the host that the file references have changed, the host should schedule a full rescan + // [main-thread] + void (*changed)(clap_host *host); +} clap_host_file_reference; + +#ifdef __cplusplus +} +#endif diff --git a/include/clap/ext/draft/thread-check.h b/include/clap/ext/draft/thread-check.h @@ -1,25 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include "../../clap.h" - -#define CLAP_EXT_THREAD_CHECK "clap/draft/thread-check" - -// This interface is useful to do runtime checks and make -// sure that the functions are called on the correct threads. -typedef struct clap_host_thread_check { - // Returns true if the "this" thread is the main thread. - // [thread-safe] - 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)(clap_host *host); -} clap_host_thread_check; - -#ifdef __cplusplus -} -#endif -\ No newline at end of file diff --git a/include/clap/ext/event-loop.h b/include/clap/ext/event-loop.h @@ -0,0 +1,51 @@ +#pragma once + +#include <stddef.h> +#ifdef __cplusplus +extern "C" { +#endif + +#include "../clap.h" + +#define CLAP_EXT_EVENT_LOOP "clap/event-loop" + +#ifdef _WIN32 +typedef void *clap_fd; +#else +typedef int clap_fd; +#endif + +enum { + CLAP_FD_READ = 1 << 0, + CLAP_FD_WRITE = 1 << 1, + CLAP_FD_ERROR = 1 << 2, +}; + +typedef struct clap_plugin_event_loop { + // [main-thread] + void (*on_timer)(clap_plugin *plugin, clap_id timer_id); + + // [main-thread] + void (*on_fd)(clap_plugin *plugin, clap_fd fd, uint32_t flags); +} clap_plugin_event_loop; + +typedef struct clap_host_event_loop { + // [main-thread] + bool (*register_timer)(clap_host *host, uint32_t period_ms, clap_id *timer_id); + + // [main-thread] + bool (*unregister_timer)(clap_host *host, clap_id timer_id); + + // [main-thread] + bool (*register_fd)(clap_host *host, clap_fd fd, uint32_t flags); + + // [main-thread] + bool (*modify_fd)(clap_host *host, clap_fd fd, uint32_t flags); + + // [main-thread] + bool (*unregister_fd)(clap_host *host, clap_fd fd); +} clap_host_event_loop; + +#ifdef __cplusplus +} +#endif +\ No newline at end of file diff --git a/include/clap/ext/thread-check.h b/include/clap/ext/thread-check.h @@ -0,0 +1,25 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "../clap.h" + +#define CLAP_EXT_THREAD_CHECK "clap/thread-check" + +// This interface is useful to do runtime checks and make +// sure that the functions are called on the correct threads. +typedef struct clap_host_thread_check { + // Returns true if the "this" thread is the main thread. + // [thread-safe] + 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)(clap_host *host); +} clap_host_thread_check; + +#ifdef __cplusplus +} +#endif +\ No newline at end of file diff --git a/include/clap/string-sizes.h b/include/clap/string-sizes.h @@ -10,6 +10,7 @@ enum { CLAP_NAME_SIZE = 64, CLAP_MODULE_SIZE = 128, CLAP_KEYWORDS_SIZE = 128, + CLAP_PATH_SIZE = 4096, }; #ifdef __cplusplus