From 3c39954f75f22c9bd73dfdf1ea3864362968cbc5 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Wed, 25 Jul 2018 13:03:38 +0300 Subject: [PATCH] Add new commands: + list_uris => List current effect instances URIs + list_bundles => List current effect instances bundle names + preset_list %i => List Presets URIs for a given effect instance ID + param_info %i %s => Get range info for a given instance's parameter Update README.md --- README.md | 28 ++++++++++++ src/effects.c | 36 ++++++++++++++- src/effects.h | 2 + src/mod-host.c | 119 ++++++++++++++++++++++++++++++++++++++++++++++++- src/mod-host.h | 4 ++ 5 files changed, 187 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 72c50c6..77da86a 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,18 @@ The commands supported by mod-host are: * show the preset information of requested instance / URI e.g.: preset_show 0 http://drobilla.net/plugins/mda/presets#EPiano-bright + list_uris + * list current effect instances with its URIs + + list_bundles + * list current effect instances with its bundle names + + list_uris + * list current effect instances with its URIs + + list_bundles + * list current effect instances with its bundle names + connect * connect two effect audio ports e.g.: connect system:capture_1 effect_0:in @@ -122,6 +134,14 @@ The commands supported by mod-host are: if bypass_value = 1 bypass effect if bypass_value = 0 process effect + preset_list + * show the preset list of requested instance + e.g.: preset_list 0 + + preset_list + * show the preset list of requested instance + e.g.: preset_list 0 + param_set * set a value to given control e.g.: param_set 0 gain 2.50 @@ -130,6 +150,14 @@ The commands supported by mod-host are: * get the value of the request control e.g.: param_get 0 gain + param_info + * get range info and scale points for a given instance's parameter + e.g.: param_info 0 gain + + param_info + * get range info and scale points for a given instance's parameter + e.g.: param_info 0 gain + param_monitor * do monitoring a effect instance control port according given condition e.g: param_monitor 0 gain > 2.50 diff --git a/src/effects.c b/src/effects.c index c7ed9d5..42d76e7 100644 --- a/src/effects.c +++ b/src/effects.c @@ -3633,6 +3633,40 @@ int effects_disconnect(const char *portA, const char *portB) return ret; } +int effects_list_uris(int *instances, const char **effects) +{ + int i; + int n=0; + for (i=0;ipresets_count; } int effects_get_parameter_info(int effect_id, const char *control_symbol, float **range, const char **scale_points) diff --git a/src/effects.h b/src/effects.h index c2f8509..3c84722 100644 --- a/src/effects.h +++ b/src/effects.h @@ -128,6 +128,8 @@ int effects_preset_save(int effect_id, const char *dir, const char *file_name, c int effects_preset_show(const char *uri, char **state_str); int effects_connect(const char *portA, const char *portB); int effects_disconnect(const char *portA, const char *portB); +int effects_list_uris(int *instances, const char **effects); +int effects_list_bundles(int *instances, const char **effects); int effects_set_parameter(int effect_id, const char *control_symbol, float value); int effects_set_property(int effect_id, const char *label, const char *value); int effects_get_parameter(int effect_id, const char *control_symbol, float *value); diff --git a/src/mod-host.c b/src/mod-host.c index 9c81395..7780991 100644 --- a/src/mod-host.c +++ b/src/mod-host.c @@ -144,6 +144,58 @@ static void effects_remove_cb(proto_t *proto) protocol_response(buffer, proto); } +static void effects_list_uris_cb(proto_t *proto) +{ + int resp; + const char **effects = (const char **) calloc(MAX_INSTANCES, sizeof(char *)); + int *instances = (int *) malloc(MAX_INSTANCES*sizeof(int)); + char *buffer = NULL; + + resp = effects_list_uris(instances, effects); + if (resp >0) { + uint32_t i; + buffer = (char *) malloc(resp*128*sizeof(char)); + sprintf(buffer, "resp %i", resp); + for (i = 0; effects[i]; i++) { + sprintf(buffer+strlen(buffer), " %d:%s", instances[i], effects[i]); + if (effects[i+1]) sprintf(buffer+strlen(buffer), ","); + } + } else { + buffer = (char *) malloc(128*sizeof(char)); + sprintf(buffer, "resp %i", resp); + } + protocol_response(buffer, proto); + + free(effects); + free(buffer); +} + +static void effects_list_bundles_cb(proto_t *proto) +{ + int resp; + const char **effects = (const char **) calloc(MAX_INSTANCES, sizeof(char *)); + int *instances = (int *) malloc(MAX_INSTANCES*sizeof(int)); + char *buffer = NULL; + + resp = effects_list_bundles(instances, effects); + if (resp >0) { + uint32_t i; + buffer = (char *) malloc(resp*128*sizeof(char)); + sprintf(buffer, "resp %i", resp); + for (i = 0; effects[i]; i++) { + sprintf(buffer+strlen(buffer), " %d:%s", instances[i], effects[i]); + if (effects[i+1]) sprintf(buffer+strlen(buffer), ","); + } + } else { + buffer = (char *) malloc(128*sizeof(char)); + sprintf(buffer, "resp %i", resp); + } + protocol_response(buffer, proto); + + free(effects); + free(buffer); +} + static void effects_preset_save_cb(proto_t *proto) { int resp; @@ -179,6 +231,31 @@ static void effects_preset_show_cb(proto_t *proto) protocol_response("", proto); } +static void effects_preset_list_cb(proto_t *proto) +{ + int resp; + char **presets = (char **) calloc(32*128, sizeof(char *)); + char *buffer = NULL; + + resp = effects_get_presets_uris(atoi(proto->list[1]), presets); + if (resp>0) { + uint32_t i; + buffer = (char *) malloc(resp*128*sizeof(char)); + sprintf(buffer, "resp %i", resp); + for (i = 0; presets[i]; i++) { + sprintf(buffer+strlen(buffer)," %s", presets[i]); + if (presets[i+1]) sprintf(buffer+strlen(buffer),","); + } + } else { + buffer = (char *) malloc(128*sizeof(char)); + sprintf(buffer, "resp %i", resp); + } + protocol_response(buffer, proto); + + free(presets); + free(buffer); +} + static void effects_connect_cb(proto_t *proto) { int resp; @@ -238,6 +315,43 @@ static void effects_get_param_cb(proto_t *proto) protocol_response(buffer, proto); } +static void effects_get_param_info_cb(proto_t *proto) +{ + int resp; + /* Create a array of strings for scale points */ + const char **scale_points = (const char **) calloc(256, sizeof(char *)); + /* Allocates memory to parameter range */ + float **param_range = (float **) calloc(4, sizeof(float *)); + param_range[0] = (float *) malloc(sizeof(float)); + param_range[1] = (float *) malloc(sizeof(float)); + param_range[2] = (float *) malloc(sizeof(float)); + param_range[3] = (float *) malloc(sizeof(float)); + + resp = effects_get_parameter_info(atoi(proto->list[1]), proto->list[2], param_range, scale_points); + char buffer[1024]; + if (resp >= 0) { + sprintf(buffer, "resp %i def: %.03f, min: %.03f, max: %.03f, curr: %.03f", + resp, *param_range[0], *param_range[1], *param_range[2], *param_range[3]); + if (scale_points[0]) { + uint32_t i; + sprintf(buffer,", scale points: "); + for (i = 0; scale_points[i]; i+=2) { + sprintf(buffer,"(%s: %s)", scale_points[i], scale_points[i+1]); + } + } + } else { + sprintf(buffer, "resp %i", resp); + } + protocol_response(buffer, proto); + + /*Free memory*/ + free(scale_points); + free(param_range[0]); + free(param_range[1]); + free(param_range[2]); + free(param_range[3]); +} + static void effects_monitor_param_cb(proto_t *proto) { int resp; @@ -578,14 +692,18 @@ static int mod_host_init(jack_client_t* client, int socket_port, int feedback_po /* Setup the protocol */ protocol_add_command(EFFECT_ADD, effects_add_cb); protocol_add_command(EFFECT_REMOVE, effects_remove_cb); + protocol_add_command(EFFECT_LIST_URIS, effects_list_uris_cb); + protocol_add_command(EFFECT_LIST_BUNDLES, effects_list_bundles_cb); protocol_add_command(EFFECT_PRESET_LOAD, effects_preset_load_cb); protocol_add_command(EFFECT_PRESET_SAVE, effects_preset_save_cb); protocol_add_command(EFFECT_PRESET_SHOW, effects_preset_show_cb); + protocol_add_command(EFFECT_PRESET_LIST, effects_preset_list_cb); protocol_add_command(EFFECT_CONNECT, effects_connect_cb); protocol_add_command(EFFECT_DISCONNECT, effects_disconnect_cb); protocol_add_command(EFFECT_BYPASS, effects_bypass_cb); protocol_add_command(EFFECT_PARAM_SET, effects_set_param_cb); protocol_add_command(EFFECT_PARAM_GET, effects_get_param_cb); + protocol_add_command(EFFECT_PARAM_INFO, effects_get_param_info_cb); protocol_add_command(EFFECT_PARAM_MON, effects_monitor_param_cb); protocol_add_command(EFFECT_LICENSEE, effects_licensee_cb); protocol_add_command(MONITOR_ADDR_SET, monitor_addr_set_cb); @@ -635,7 +753,6 @@ static void* intclient_socket_run(void* ptr) (void)ptr; } - /* ************************************************************************************************************************ * MAIN FUNCTION diff --git a/src/mod-host.h b/src/mod-host.h index 52b35a5..f796b2a 100644 --- a/src/mod-host.h +++ b/src/mod-host.h @@ -53,14 +53,18 @@ /* Protocol commands definition */ #define EFFECT_ADD "add %s %i" #define EFFECT_REMOVE "remove %i" +#define EFFECT_LIST_URIS "list_uris" +#define EFFECT_LIST_BUNDLES "list_bundles" #define EFFECT_PRESET_LOAD "preset_load %i %s" #define EFFECT_PRESET_SAVE "preset_save %i %s %s %s" #define EFFECT_PRESET_SHOW "preset_show %s" +#define EFFECT_PRESET_LIST "preset_list %i" #define EFFECT_CONNECT "connect %s %s" #define EFFECT_DISCONNECT "disconnect %s %s" #define EFFECT_BYPASS "bypass %i %i" #define EFFECT_PARAM_SET "param_set %i %s %s" #define EFFECT_PARAM_GET "param_get %i %s" +#define EFFECT_PARAM_INFO "param_info %i %s" #define EFFECT_PARAM_MON "param_monitor %i %s %s %f" #define EFFECT_LICENSEE "licensee %i" #define MONITOR_ADDR_SET "monitor %s %i %i"