clap

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

commit 2f679331cf23420e8980c36a2b60c139e50e0ceb
parent 13b06a1bf7a028dc99b482b0ebafc89401d08dda
Author: Alexandre Bique <bique.alexandre@gmail.com>
Date:   Fri, 24 Oct 2014 19:35:30 +0200

Use the attribute system

Diffstat:
Mexamples/clap-info/clap-info.c | 22+++++-----------------
Mexamples/thyns/plugin.c | 31++++++++++++++++---------------
Minclude/clap/clap.h | 43++++++++++++++++++++++---------------------
3 files changed, 43 insertions(+), 53 deletions(-)

diff --git a/examples/clap-info/clap-info.c b/examples/clap-info/clap-info.c @@ -25,9 +25,6 @@ static void initialize_host(struct clap_host *host) host->events = host_events; host->steady_time = host_steady_time; host->extension = host_extension; - snprintf(host->name, sizeof (host->name), "clap-info"); - snprintf(host->manufacturer, sizeof (host->manufacturer), "clap"); - snprintf(host->version, sizeof (host->version), "1.0"); } int main(int argc, char **argv) @@ -80,23 +77,14 @@ int main(int argc, char **argv) print_attr(SUPPORT); print_attr(LICENSE); print_attr(CATEGORIES); + print_attr(TYPE); + print_attr(CHUNK_SIZE); + print_attr(LATENCY); + print_attr(HAS_GUI); + print_attr(SUPPORTS_TUNING); #undef print_attr - fprintf(stdout, " type:"); - if (plugin->type & CLAP_PLUGIN_INSTRUMENT) - fprintf(stdout, " instrument"); - if (plugin->type & CLAP_PLUGIN_EFFECT) - fprintf(stdout, " effect"); - if (plugin->type & CLAP_PLUGIN_EVENT_EFFECT) - fprintf(stdout, " event_effect"); - if (plugin->type & CLAP_PLUGIN_ANALYZER) - fprintf(stdout, " analyzer"); - fprintf(stdout, "\n"); - fprintf(stdout, " chunk_size: %d\n", plugin->chunk_size); - fprintf(stdout, " has_gui: %d\n", plugin->has_gui); - fprintf(stdout, " supports_tunning: %d\n", plugin->supports_tuning); - // destroy the plugin plugin->destroy(plugin); } diff --git a/examples/thyns/plugin.c b/examples/thyns/plugin.c @@ -30,21 +30,27 @@ thyns_plugin_get_attribute(struct clap_plugin *plugin, { #define attr(Attr, Value) \ do { \ - if (!strcmp(Attr, attr)) { \ + if (!strcmp(CLAP_ATTR_##Attr, attr)) { \ snprintf(buffer, size, "%s", Value); \ return sizeof (Value) - 1; \ } \ } while (0) - attr(CLAP_ATTR_ID, "clap/thyns"); - attr(CLAP_ATTR_NAME, "Thyns"); - attr(CLAP_ATTR_DESCRIPTION, "Clap demo synth"); - attr(CLAP_ATTR_VERSION, "0.0.1"); - attr(CLAP_ATTR_MANUFACTURER, "Clap"); - attr(CLAP_ATTR_URL, "https://github.com/abique/clap"); - attr(CLAP_ATTR_SUPPORT, "https://github.com/abique/clap"); - attr(CLAP_ATTR_LICENSE, "MIT"); - attr(CLAP_ATTR_CATEGORIES, ""); + attr(ID, "clap/thyns"); + attr(NAME, "Thyns"); + attr(DESCRIPTION, "Clap demo synth"); + attr(VERSION, "0.0.1"); + attr(MANUFACTURER, "Clap"); + attr(URL, "https://github.com/abique/clap"); + attr(SUPPORT, "https://github.com/abique/clap"); + attr(LICENSE, "MIT"); + attr(CATEGORIES, ""); + attr(TYPE, "instrument"); + attr(CHUNK_SIZE, "1"); + attr(HAS_GUI, "0"); + attr(SUPPORTS_TUNING, "1"); + attr(LATENCY, "0"); + return 0; #undef attr @@ -218,11 +224,6 @@ thyns_plugin_create(struct clap_host *host, p->plugin.clap_version = CLAP_VERSION; p->plugin.destroy = thyns_plugin_destroy; p->plugin.plugin_data = p; - p->plugin.type = CLAP_PLUGIN_INSTRUMENT; - p->plugin.chunk_size = 1; - p->plugin.has_gui = false; - p->plugin.supports_tuning = true; - p->plugin.latency = 0; p->plugin.get_attribute = thyns_plugin_get_attribute; p->plugin.get_ports_configs_count = thyns_plugin_get_ports_configs_count; p->plugin.get_ports_config = thyns_plugin_get_ports_config; diff --git a/include/clap/clap.h b/include/clap/clap.h @@ -67,15 +67,20 @@ enum clap_log_severity CLAP_LOG_FATAL = 4, }; -# define CLAP_ATTR_ID "clap/id" -# define CLAP_ATTR_NAME "clap/name" -# define CLAP_ATTR_DESCRIPTION "clap/description" -# define CLAP_ATTR_VERSION "clap/version" -# define CLAP_ATTR_MANUFACTURER "clap/manufacturer" -# define CLAP_ATTR_URL "clap/url" -# define CLAP_ATTR_SUPPORT "clap/support" -# define CLAP_ATTR_LICENSE "clap/license" -# define CLAP_ATTR_CATEGORIES "clap/categories" +# define CLAP_ATTR_ID "clap/id" +# define CLAP_ATTR_NAME "clap/name" +# define CLAP_ATTR_DESCRIPTION "clap/description" +# define CLAP_ATTR_VERSION "clap/version" +# define CLAP_ATTR_MANUFACTURER "clap/manufacturer" +# define CLAP_ATTR_URL "clap/url" +# define CLAP_ATTR_SUPPORT "clap/support" +# define CLAP_ATTR_LICENSE "clap/license" +# define CLAP_ATTR_CATEGORIES "clap/categories" +# define CLAP_ATTR_TYPE "clap/type" +# define CLAP_ATTR_CHUNK_SIZE "clap/chunk_size" +# define CLAP_ATTR_LATENCY "clap/latency" +# define CLAP_ATTR_HAS_GUI "clap/has_gui" +# define CLAP_ATTR_SUPPORTS_TUNING "clap/supports_tuning" /////////// // PORTS // @@ -270,7 +275,9 @@ struct clap_process uint32_t samples_count; /* feedback loops */ - void (*feedback)(struct clap_process *process, uint32_t stream_id, uint32_t nb_samples); + void (*feedback)(struct clap_process *process, + uint32_t stream_id, + uint32_t nb_samples); uint32_t feedback_chunk_size; /* process info */ @@ -294,10 +301,11 @@ struct clap_host { uint32_t clap_version; // initialized to CLAP_VERSION - /* host info */ - char name[CLAP_NAME_SIZE]; - char manufacturer[CLAP_NAME_SIZE]; - char version[CLAP_NAME_SIZE]; + /* returns the size of the original string, 0 if not string */ + uint32_t (*get_attribute)(struct clap_plugin *plugin, + const char *attr, + char *buffer, + uint32_t size); /* for events generated by the plugin. */ void (*events)(struct clap_host *host, @@ -338,13 +346,6 @@ struct clap_plugin void *host_data; // reserved pointer for the host void *plugin_data; // reserved pointer for the plugin - uint32_t type; // clap_plugin_type bitfield - uint32_t chunk_size; - uint32_t latency; // latency in samples - - bool has_gui; - bool supports_tuning; - /* free plugin's resources */ void (*destroy)(struct clap_plugin *plugin);