Skip to content

Add new param_list method #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <instance_number>
* list the available controls for an instance
e.g.: param_list 0

param_set <instance_number> <param_symbol> <param_value>
* set a value to given control
e.g.: param_set 0 gain 2.50
Expand Down
3 changes: 3 additions & 0 deletions doc/mod-host.1
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ preset_save <instance_number> <preset_name> <dir> <file_name>
preset_show <instance_number> <preset_uri>
* show the preset information of requested instance / URI
e.g.: preset_show 0 http://drobilla.net/plugins/mda/presets#EPiano\-bright
param_list <instance_number>
* list the available controls for an instance
e.g.: param_list 0
param_set <instance_number> <param_symbol> <param_value>
* set a value to given control
e.g.: param_set 0 gain 2.50
Expand Down
8 changes: 8 additions & 0 deletions src/completer.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ static char *g_commands[] = {
"connect",
"disconnect",
"bypass",
"param_list",
"param_set",
"param_get",
"param_monitor",
Expand Down Expand Up @@ -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)
Expand Down
39 changes: 39 additions & 0 deletions src/mod-host.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/mod-host.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
************************************************************************************************************************
*/

#define PROTOCOL_MAX_COMMANDS 24
#define PROTOCOL_MAX_COMMANDS 25

// error messages configuration
#define MESSAGE_COMMAND_NOT_FOUND "not found"
Expand Down