commit 78b8b40d965df1107fbdbd34910d63e86c76f61e
parent 1dd8297410d160be007e387eccfc4fe8c3f5bb44
Author: Alexandre Bique <bique.alexandre@gmail.com>
Date: Wed, 7 Jan 2015 01:30:30 +0100
Improve clap-info and thyns
Diffstat:
3 files changed, 87 insertions(+), 33 deletions(-)
diff --git a/examples/thyns/plugin.c b/examples/thyns/plugin.c
@@ -101,32 +101,45 @@ thyns_params_get(struct clap_plugin *plugin,
struct thyns_plugin *p = plugin->plugin_data;
uint32_t i = 0;
- if (index < i + THYNS_OSC_PARAM_COUNT)
+ param->index = index;
+ param->parent = -1;
+
+ if (index < i + THYNS_OSC_PARAM_COUNT) {
thyns_osc_param_info(index - i, p->thyns.params.osc1[index - i],
"osc1:", param);
+ return true;
+ }
i += THYNS_OSC_PARAM_COUNT;
- if (index < i + THYNS_OSC_PARAM_COUNT)
+ if (index < i + THYNS_OSC_PARAM_COUNT) {
thyns_osc_param_info(index - i, p->thyns.params.osc2[index - i],
"osc2:", param);
+ return true;
+ }
i += THYNS_OSC_PARAM_COUNT;
- if (index < i + THYNS_FILT_PARAM_COUNT)
+ if (index < i + THYNS_FILT_PARAM_COUNT) {
thyns_filt_param_info(index - i, p->thyns.params.filt[index - i],
"filt:", param);
+ return true;
+ }
i += THYNS_FILT_PARAM_COUNT;
- if (index < i + THYNS_ENV_PARAM_COUNT)
+ if (index < i + THYNS_ENV_PARAM_COUNT) {
thyns_env_param_info(index - i, p->thyns.params.amp_env[index - i],
"amp_env:", param);
+ return true;
+ }
i += THYNS_ENV_PARAM_COUNT;
- if (index < i + THYNS_ENV_PARAM_COUNT)
+ if (index < i + THYNS_ENV_PARAM_COUNT) {
thyns_env_param_info(index - i, p->thyns.params.filt_env[index - i],
"filt_env:", param);
+ return true;
+ }
i += THYNS_ENV_PARAM_COUNT;
- return true;
+ return false;
}
struct thyns_plugin *
diff --git a/examples/thyns/voice.h b/examples/thyns/voice.h
@@ -102,26 +102,31 @@ thyns_voice_use_param(struct thyns_voice *voice,
if (index < i + THYNS_OSC_PARAM_COUNT) {
voice->osc1.values[index - i] = params->values + index;
+ return;
}
i += THYNS_OSC_PARAM_COUNT;
if (index < i + THYNS_OSC_PARAM_COUNT) {
voice->osc2.values[index - i] = params->values + index;
+ return;
}
i += THYNS_OSC_PARAM_COUNT;
if (index < i + THYNS_FILT_PARAM_COUNT) {
voice->filt.values[index - i] = params->values + index;
+ return;
}
i += THYNS_FILT_PARAM_COUNT;
if (index < i + THYNS_ENV_PARAM_COUNT) {
voice->amp_env.values[index - i] = params->values + index;
+ return;
}
i += THYNS_ENV_PARAM_COUNT;
if (index < i + THYNS_ENV_PARAM_COUNT) {
voice->filt_env.values[index - i] = params->values + index;
+ return;
}
i += THYNS_ENV_PARAM_COUNT;
}
diff --git a/tools/clap-info/clap-info.c b/tools/clap-info/clap-info.c
@@ -2,6 +2,7 @@
#include <dlfcn.h>
#include <clap/clap.h>
+#include <clap/ext/params.h>
static void host_events(struct clap_host *host,
struct clap_plugin *plugin,
@@ -27,6 +28,66 @@ static void initialize_host(struct clap_host *host)
host->extension = host_extension;
}
+static void print_attr(struct clap_plugin *plugin)
+{
+ char buffer[256];
+
+#define prt_attr(Attr) \
+ do { \
+ int size = plugin->get_attribute( \
+ plugin, CLAP_ATTR_##Attr, buffer, sizeof (buffer)); \
+ if (size > 0) \
+ fprintf(stdout, " %s: %s\n", CLAP_ATTR_##Attr, buffer); \
+ } while (0)
+
+ fprintf(stdout, "Attributes:\n");
+ prt_attr(ID);
+ prt_attr(NAME);
+ prt_attr(DESCRIPTION);
+ prt_attr(MANUFACTURER);
+ prt_attr(VERSION);
+ prt_attr(URL);
+ prt_attr(SUPPORT);
+ prt_attr(LICENSE);
+ prt_attr(CATEGORIES);
+ prt_attr(TYPE);
+ prt_attr(CHUNK_SIZE);
+ prt_attr(LATENCY);
+ prt_attr(SUPPORTS_TUNING);
+ prt_attr(SUPPORTS_IN_PLACE_PROCESSING);
+ prt_attr(IS_REMOTE_PROCESSING);
+
+ fprintf(stdout, "-------------------\n");
+
+#undef print_attr
+}
+
+static void print_params(struct clap_plugin *plugin)
+{
+ struct clap_plugin_params *params = plugin->extension(plugin, CLAP_EXT_PARAMS);
+
+ if (!params) {
+ fprintf(stdout, "no parameter extension\n");
+ return;
+ }
+
+ uint32_t count = params->count(plugin);
+ fprintf(stdout, "parameters count: %d\n", count);
+
+ struct clap_param param;
+ for (uint32_t i = 0; i < count; ++i) {
+ if (!params->get(plugin, i, ¶m))
+ continue;
+
+ fprintf(stdout, " => {id: %s, name: %s, desc: %s, display: %s, type: %d, "
+ "is_per_note: %d, is_used: %d, is_periodic: %d}\n",
+ param.id, param.name, param.desc, param.display, param.type,
+ param.is_per_note, param.is_used, param.is_periodic);
+ }
+
+ fprintf(stdout, "-------------------\n");
+}
+
int main(int argc, char **argv)
{
struct clap_host host;
@@ -59,33 +120,8 @@ int main(int argc, char **argv)
continue;
}
- char buffer[256];
-
-#define print_attr(Attr) \
- do { \
- int size = plugin->get_attribute( \
- plugin, CLAP_ATTR_##Attr, buffer, sizeof (buffer)); \
- if (size > 0) \
- fprintf(stdout, " %s: %s\n", CLAP_ATTR_##Attr, buffer); \
- } while (0)
-
- print_attr(ID);
- print_attr(NAME);
- print_attr(DESCRIPTION);
- print_attr(MANUFACTURER);
- print_attr(VERSION);
- print_attr(URL);
- print_attr(SUPPORT);
- print_attr(LICENSE);
- print_attr(CATEGORIES);
- print_attr(TYPE);
- print_attr(CHUNK_SIZE);
- print_attr(LATENCY);
- print_attr(SUPPORTS_TUNING);
- print_attr(SUPPORTS_IN_PLACE_PROCESSING);
- print_attr(IS_REMOTE_PROCESSING);
-
-#undef print_attr
+ print_attr(plugin);
+ print_params(plugin);
// destroy the plugin
plugin->destroy(plugin);