diff --git a/README.md b/README.md index 2f1bd65..9d5143b 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,10 @@ 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 + param_list + * list the available controls for an instance + e.g.: param_list 0 + param_set * set a value to given control e.g.: param_set 0 gain 2.50 diff --git a/doc/mod-host.1 b/doc/mod-host.1 index d89896e..81696c9 100644 --- a/doc/mod-host.1 +++ b/doc/mod-host.1 @@ -113,6 +113,9 @@ preset_save preset_show * show the preset information of requested instance / URI e.g.: preset_show 0 http://drobilla.net/plugins/mda/presets#EPiano\-bright +param_list + * list the available controls for an instance + e.g.: param_list 0 param_set * set a value to given control e.g.: param_set 0 gain 2.50 diff --git a/src/completer.c b/src/completer.c index cf2d485..73a199d 100644 --- a/src/completer.c +++ b/src/completer.c @@ -55,6 +55,7 @@ static char *g_commands[] = { "connect", "disconnect", "bypass", + "param_list", "param_set", "param_get", "param_monitor", @@ -256,6 +257,13 @@ static char **completion(const char *text, int start, int end) get_instances = 1; } } + else if (strcmp(cmd[0], "param_list") == 0) + { + if (count == 1) + { + get_instances = 1; + } + } else if (strcmp(cmd[0], "param_get") == 0) { if (count == 1) diff --git a/src/mod-host.c b/src/mod-host.c index 0f1b750..61c5ebe 100644 --- a/src/mod-host.c +++ b/src/mod-host.c @@ -211,6 +211,44 @@ static void effects_bypass_cb(proto_t *proto) protocol_response(buffer, proto); } +static void effects_list_param_cb(proto_t *proto) +{ + char ** symbols = (char **) calloc(128, sizeof(char *)); + + int resp = effects_get_parameter_symbols(atoi(proto->list[1]), symbols); + + if (resp != SUCCESS) + { + char buffer[128]; + sprintf(buffer, "resp %i ", resp); + protocol_response(buffer, proto); + } + else + { + int length = 0; + char *name = NULL; + for (int i = 0; (name = symbols[i]) != NULL; i++) + { + length += strlen(name) + 1; + } + + char buffer[length]; + char *bufferIndex = &buffer[0]; + for (int i = 0; (name = symbols[i]) != NULL; i++) + { + strcpy(bufferIndex, name); + bufferIndex += strlen(name); + + *bufferIndex = ' '; + bufferIndex++; + } + *(bufferIndex - 1) = '\0'; + protocol_response(buffer, proto); + } + + free (symbols); +} + static void effects_set_param_cb(proto_t *proto) { int resp; @@ -463,6 +501,7 @@ static int mod_host_init(jack_client_t* client, int socket_port) 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_LIST, effects_list_param_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_MON, effects_monitor_param_cb); diff --git a/src/mod-host.h b/src/mod-host.h index ff10a97..d6a0f11 100644 --- a/src/mod-host.h +++ b/src/mod-host.h @@ -59,6 +59,7 @@ #define EFFECT_CONNECT "connect %s %s" #define EFFECT_DISCONNECT "disconnect %s %s" #define EFFECT_BYPASS "bypass %i %i" +#define EFFECT_PARAM_LIST "param_list %i" #define EFFECT_PARAM_SET "param_set %i %s %s" #define EFFECT_PARAM_GET "param_get %i %s" #define EFFECT_PARAM_MON "param_monitor %i %s %s %f" diff --git a/src/protocol.h b/src/protocol.h index 4273f29..7b7f83c 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -48,7 +48,7 @@ ************************************************************************************************************************ */ -#define PROTOCOL_MAX_COMMANDS 24 +#define PROTOCOL_MAX_COMMANDS 25 // error messages configuration #define MESSAGE_COMMAND_NOT_FOUND "not found"