clap

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

commit 81c537b2010bb63c721a3c7b209c9482ccb068b5
parent 1b5b8438bdaa92fe056e9990b0df035f2d348371
Author: Alexandre BIQUE <bique.alexandre@gmail.com>
Date:   Sat,  1 May 2021 12:46:31 +0200

simplify a few things, the transport did a full circle, add a main.c to test that the headers compiles

Diffstat:
ACMakeLists.txt | 4++++
Ainclude/clap/all.h | 27+++++++++++++++++++++++++++
Ainclude/clap/channel-map.h | 21+++++++++++++++++++++
Minclude/clap/clap.h | 18+++++++++---------
Ainclude/clap/color.h | 19+++++++++++++++++++
Minclude/clap/events.h | 18+++++++++++-------
Minclude/clap/ext/audio-ports.h | 17+++--------------
Minclude/clap/ext/draft/track-info.h | 28+++++++++++-----------------
Minclude/clap/stream.h | 4++--
Asrc/main.c | 6++++++
10 files changed, 113 insertions(+), 49 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt @@ -0,0 +1,4 @@ +project(CLAP C) + +include_directories(include) +add_executable(clap-compile-test src/main.c) diff --git a/include/clap/all.h b/include/clap/all.h @@ -0,0 +1,26 @@ +#pragma once + +#include "clap.h" + +#include "ext/audio-ports.h" +#include "ext/gui.h" +#include "ext/gui-x11.h" +#include "ext/gui-win32.h" +#include "ext/gui-cocoa.h" +#include "ext/gui-free-standing.h" +#include "ext/idle.h" +#include "ext/log.h" +#include "ext/params.h" +#include "ext/render.h" +#include "ext/state.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/track-info.h" +#include "ext/draft/tuning.h" +#include "ext/draft/vst2-convert.h" +#include "ext/draft/vst3-convert.h" +\ No newline at end of file diff --git a/include/clap/channel-map.h b/include/clap/channel-map.h @@ -0,0 +1,21 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum clap_chmap { + CLAP_CHMAP_UNSPECIFIED = 0, + CLAP_CHMAP_MONO = 1, + + // left, right + CLAP_CHMAP_STEREO = 2, + + // front left, front right, center, low, surround left, surround right + // surround back left, surround back right + CLAP_CHMAP_SURROUND = 3, +} clap_chmap; + +#ifdef __cplusplus +} +#endif diff --git a/include/clap/clap.h b/include/clap/clap.h @@ -67,12 +67,12 @@ typedef struct clap_audio_buffer { } clap_audio_buffer; typedef struct clap_process { - int64_t steady_time; // a steady sample time counter, requiered - int32_t frames_count; // number of frame to process + int64_t steady_time; // a steady sample time counter, requiered + int32_t frames_count; // number of frame to process // time info at sample 0 // If null, then this is a free running host, no transport events will be provided - const clap_event_time_info *time_info; + const clap_event_transport *transport; // Audio buffers, they must have the same count as specified // by clap_plugin_audio_ports->get_count(). @@ -107,7 +107,7 @@ typedef struct clap_host { // Query an extension. // [thread-safe] - const void *(*extension)(clap_host *host, const char *extension_id); + const void *(*extension)(struct clap_host *host, const char *extension_id); } clap_host; //////////// @@ -167,20 +167,20 @@ typedef struct clap_plugin { /* Free the plugin and its resources. * It is not required to deactivate the plugin prior to this call. */ - void (*destroy)(clap_plugin *plugin); + void (*destroy)(struct clap_plugin *plugin); /* activation/deactivation * [main-thread] */ - bool (*activate)(clap_plugin *plugin, int sample_rate); - void (*deactivate)(clap_plugin *plugin); + bool (*activate)(struct clap_plugin *plugin, int sample_rate); + void (*deactivate)(struct clap_plugin *plugin); /* process audio, events, ... * [audio-thread] */ - clap_process_status (*process)(clap_plugin *plugin, const clap_process *process); + clap_process_status (*process)(struct clap_plugin *plugin, const clap_process *process); /* query an extension * [thread-safe] */ - const void *(*extension)(clap_plugin *plugin, const char *id); + const void *(*extension)(struct clap_plugin *plugin, const char *id); } clap_plugin; ///////////////// diff --git a/include/clap/color.h b/include/clap/color.h @@ -0,0 +1,18 @@ +#pragma once + +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct clap_color { + uint8_t red; + uint8_t green; + uint8_t blue; + uint8_t alpha; +} clap_color; + +#ifdef __cplusplus +} +#endif +\ No newline at end of file diff --git a/include/clap/events.h b/include/clap/events.h @@ -1,6 +1,7 @@ #pragma once #include <stdint.h> +#include <stdbool.h> #ifdef __cplusplus extern "C" { @@ -12,7 +13,7 @@ typedef enum clap_event_type { CLAP_EVENT_NOTE_EXPRESSION, // note_expression attribute CLAP_EVENT_CHOKE, // no attribute CLAP_EVENT_PARAM_SET, // param attribute - CLAP_EVENT_TIME_INFO, // time_info attribute + CLAP_EVENT_TRANSPORT, // transport attribute CLAP_EVENT_CHORD, // chord attribute CLAP_EVENT_MIDI, // midi attribute CLAP_EVENT_MIDI_SYSEX, // midi attribute @@ -65,7 +66,7 @@ typedef struct clap_event_param { double normalized_ramp; // valid until the end of the block or the next event } clap_event_param; -typedef struct clap_event_time_info { +typedef struct clap_event_transport { bool has_second_timeline; bool has_beats_timeline; bool has_time_signature; @@ -80,6 +81,9 @@ typedef struct clap_event_time_info { double bar_start; // start pos of the current bar int32_t bar_number; // bar at song pos 0 has the number 0 + bool is_playing; + bool is_recording; + bool is_loop_active; double loop_start_beats; double loop_end_beats; @@ -88,7 +92,7 @@ typedef struct clap_event_time_info { int16_t num; // time signature numerator int16_t denom; // time signature denominator -} clap_event_time_info; +} clap_event_transport; typedef struct clap_event_chord { // bitset of active keys: @@ -118,7 +122,7 @@ typedef struct clap_event { clap_event_note note; clap_event_note_expression note_expression; clap_event_param param; - clap_event_time_info time_info; + clap_event_transport time_info; clap_event_chord chord; clap_event_midi midi; clap_event_midi_sysex midi_sysex; @@ -128,13 +132,13 @@ typedef struct clap_event { typedef struct clap_event_list { void *ctx; // reserved pointer for the list - uint32_t (*size)(const clap_event_list *list); + uint32_t (*size)(const struct clap_event_list *list); // Don't free the return event, it belongs to the list - const clap_event *(*get)(const clap_event_list *list, uint32_t index); + const clap_event *(*get)(const struct clap_event_list *list, uint32_t index); // Makes a copy of the event - void (*push_back)(const clap_event_list *list, const clap_event *event); + void (*push_back)(const struct clap_event_list *list, const clap_event *event); } clap_event_list; #ifdef __cplusplus diff --git a/include/clap/ext/audio-ports.h b/include/clap/ext/audio-ports.h @@ -5,21 +5,10 @@ extern "C" { #endif #include "../clap.h" +#include "../channel-map.h" #define CLAP_EXT_AUDIO_PORTS "clap/audio-ports" -typedef enum clap_audio_port_channel_mapping { - CLAP_AUDIO_PORT_UNSPECIFIED = 0, - CLAP_AUDIO_PORT_MONO = 1, - - // left, right - CLAP_AUDIO_PORT_STEREO = 2, - - // 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; - typedef struct clap_audio_port_info { uint32_t id; // stable identifier char name[CLAP_NAME_SIZE]; // displayable name, i18n? @@ -29,8 +18,8 @@ typedef struct clap_audio_port_info { // 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; - clap_audio_port_channel_mapping channel_mapping; + int32_t channel_count; + clap_chmap channel_map; } clap_audio_port_info; // The audio ports scan has to be done while the plugin is deactivated. diff --git a/include/clap/ext/draft/track-info.h b/include/clap/ext/draft/track-info.h @@ -1,7 +1,8 @@ #pragma once +#include "../../channel-map.h" #include "../../clap.h" -#include "../audio-ports.h" +#include "../../color.h" #ifdef __cplusplus extern "C" { @@ -9,28 +10,21 @@ extern "C" { #define CLAP_EXT_TRACK_INFO "clap/draft/track-info" -typedef struct clap_color { - uint8_t red; - uint8_t green; - uint8_t blue; - uint8_t alpha; -} clap_color; - typedef struct clap_track_info { - uint32_t id; - char name[CLAP_NAME_SIZE]; - int32_t track_index; - char path[512]; // Like "/group1/group2/drum-machine/drum-pad" - int32_t audio_channel_count; - clap_audio_port_channel_mapping audio_channel_mapping; - clap_color color; - bool is_return_track; + uint32_t id; + char name[CLAP_NAME_SIZE]; + int32_t track_index; + char path[512]; // Like "/group1/group2/drum-machine/drum-pad" + int32_t channel_count; + clap_chmap channel_map; + clap_color color; + bool is_return_track; } clap_track_info; typedef struct clap_plugin_track_info { // [main-thread] int (*track_info_changed)(clap_plugin *plugin, const clap_track_info *info); -} clap_host_plugin_info; +} clap_plugin_track_info; typedef struct clap_host_track_info { // Informs the host that the note names has changed. diff --git a/include/clap/stream.h b/include/clap/stream.h @@ -12,7 +12,7 @@ typedef struct clap_istream { /* 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); + int64_t (*read)(struct clap_istream *stream, void *buffer, uint64_t size); } clap_istream; typedef struct clap_ostream { @@ -20,7 +20,7 @@ typedef struct clap_ostream { /* returns the number of bytes written. * -1 on error. */ - int64_t (*write)(clap_istream *stream, const void *buffer, uint64_t size); + int64_t (*write)(struct clap_istream *stream, const void *buffer, uint64_t size); } clap_ostream; #ifdef __cplusplus diff --git a/src/main.c b/src/main.c @@ -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