Skip to content

Commit 361a2a4

Browse files
committed
Implement connect_matching command
Signed-off-by: falkTX <falktx@falktx.com>
1 parent bd00c4d commit 361a2a4

File tree

5 files changed

+90
-59
lines changed

5 files changed

+90
-59
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ The commands supported by mod-host are:
143143
* connect two jack ports
144144
e.g.: connect "system:capture_1" "effect_0:in"
145145

146+
connect_matching <matching_port> <destination_port>
147+
* connect the same connected ports of a port to another, so they match.
148+
e.g.: connect "effect_0:in" "effect_1:in"
149+
146150
disconnect <origin_port> <destination_port>
147151
* disconnect two jack ports
148152
e.g.: disconnect "system:capture_1" "effect_0:in"

src/effects.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6784,6 +6784,23 @@ int effects_connect(const char *portA, const char *portB)
67846784
return ret;
67856785
}
67866786

6787+
int effects_connect_matching(const char *matching, const char *port)
6788+
{
6789+
const jack_port_t *jport = jack_port_by_name(g_jack_global_client, matching);
6790+
if (!jport)
6791+
return ERR_JACK_PORT_CONNECTION;
6792+
6793+
const char **jports = jack_port_get_connections(jport);
6794+
if (jports)
6795+
{
6796+
for (int i = 0; jports[i]; ++i)
6797+
jack_connect(g_jack_global_client, jports[i], port);
6798+
jack_free(jports);
6799+
}
6800+
6801+
return SUCCESS;
6802+
}
6803+
67876804
int effects_disconnect(const char *portA, const char *portB)
67886805
{
67896806
int ret;

src/effects.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ int effects_preset_load(int effect_id, const char *uri);
150150
int effects_preset_save(int effect_id, const char *dir, const char *file_name, const char *label);
151151
int effects_preset_show(const char *uri, char **state_str);
152152
int effects_connect(const char *portA, const char *portB);
153+
int effects_connect_matching(const char *matching, const char *port);
153154
int effects_disconnect(const char *portA, const char *portB);
154155
int effects_disconnect_all(const char *port);
155156
int effects_set_parameter(int effect_id, const char *control_symbol, float value);

src/mod-host.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,13 @@ static void effects_connect_cb(proto_t *proto)
196196
protocol_response_int(resp, proto);
197197
}
198198

199+
static void effects_connect_matching_cb(proto_t *proto)
200+
{
201+
int resp;
202+
resp = effects_connect_matching(proto->list[1], proto->list[2]);
203+
protocol_response_int(resp, proto);
204+
}
205+
199206
static void effects_disconnect_cb(proto_t *proto)
200207
{
201208
int resp;
@@ -1003,6 +1010,7 @@ static int mod_host_init(jack_client_t* client, int socket_port, int feedback_po
10031010
protocol_add_command(EFFECT_PRESET_SAVE, effects_preset_save_cb);
10041011
protocol_add_command(EFFECT_PRESET_SHOW, effects_preset_show_cb);
10051012
protocol_add_command(EFFECT_CONNECT, effects_connect_cb);
1013+
protocol_add_command(EFFECT_CONNECT_MATCHING, effects_connect_matching_cb);
10061014
protocol_add_command(EFFECT_DISCONNECT, effects_disconnect_cb);
10071015
protocol_add_command(EFFECT_DISCONNECT_ALL, effects_disconnect_all_cb);
10081016
protocol_add_command(EFFECT_BYPASS, effects_bypass_cb);

src/mod-host.h

Lines changed: 60 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -51,65 +51,66 @@
5151
#define SOCKET_MSG_BUFFER_SIZE 1024
5252

5353
/* Protocol commands definition */
54-
#define EFFECT_ADD "add %s %i"
55-
#define EFFECT_REMOVE "remove %i"
56-
#define EFFECT_ACTIVATE "activate %i %i"
57-
#define EFFECT_PRELOAD "preload %s %i"
58-
#define EFFECT_PRESET_LOAD "preset_load %i %s"
59-
#define EFFECT_PRESET_SAVE "preset_save %i %s %s %s"
60-
#define EFFECT_PRESET_SHOW "preset_show %s"
61-
#define EFFECT_CONNECT "connect %s %s"
62-
#define EFFECT_DISCONNECT "disconnect %s %s"
63-
#define EFFECT_DISCONNECT_ALL "disconnect_all %s"
64-
#define EFFECT_BYPASS "bypass %i %i"
65-
#define EFFECT_PARAM_SET "param_set %i %s %f"
66-
#define EFFECT_PARAM_GET "param_get %i %s"
67-
#define EFFECT_PARAM_MON "param_monitor %i %s %s %f"
68-
#define EFFECT_PARAMS_FLUSH "params_flush %i %i %i ..."
69-
#define EFFECT_PATCH_GET "patch_get %i %s"
70-
#define EFFECT_PATCH_SET "patch_set %i %s %s"
71-
#define EFFECT_LICENSEE "licensee %i"
72-
#define EFFECT_SET_BPM "set_bpm %f"
73-
#define EFFECT_SET_BPB "set_bpb %f"
74-
#define MONITOR_ADDR_SET "monitor %s %i %i"
75-
#define MONITOR_OUTPUT "monitor_output %i %s"
76-
#define MONITOR_OUTPUT_OFF "monitor_output_off %i %s"
77-
#define MONITOR_AUDIO_LEVELS "monitor_audio_levels %i %s"
78-
#define MONITOR_MIDI_CONTROL "monitor_midi_control %i %i"
79-
#define MONITOR_MIDI_PROGRAM "monitor_midi_program %i %i"
80-
#define MIDI_LEARN "midi_learn %i %s %f %f"
81-
#define MIDI_MAP "midi_map %i %s %i %i %f %f"
82-
#define MIDI_UNMAP "midi_unmap %i %s"
83-
#define CC_MAP "cc_map %i %s %i %i %s %f %f %f %i %i %s %i ..."
84-
#define CC_VALUE_SET "cc_value_set %i %s %f"
85-
#define CC_UNMAP "cc_unmap %i %s"
86-
#define CV_MAP "cv_map %i %s %s %f %f %s"
87-
#define CV_UNMAP "cv_unmap %i %s"
88-
#define HMI_MAP "hmi_map %i %s %i %i %i %i %i %s %f %f %i"
89-
#define HMI_UNMAP "hmi_unmap %i %s"
90-
#define CPU_LOAD "cpu_load"
91-
#define MAX_CPU_LOAD "max_cpu_load"
92-
#define LOAD_COMMANDS "load %s"
93-
#define SAVE_COMMANDS "save %s"
94-
#define BUNDLE_ADD "bundle_add %s"
95-
#define BUNDLE_REMOVE "bundle_remove %s %s"
96-
#define STATE_LOAD "state_load %s"
97-
#define STATE_SAVE "state_save %s"
98-
#define STATE_TMPDIR "state_tmpdir %s"
99-
#define FEATURE_ENABLE "feature_enable %s %i"
100-
#define TRANSPORT "transport %i %f %f"
101-
#define TRANSPORT_SYNC "transport_sync %s"
102-
#define SHOW_EXTERNAL_UI "show_external_ui %i"
103-
#define OUTPUT_DATA_READY "output_data_ready"
104-
#define MULTI_ADD "multi_add %i ..."
105-
#define MULTI_REMOVE "multi_remove %i ..."
106-
#define MULTI_ACTIVATE "multi_activate %i %i ..."
107-
#define MULTI_PRELOAD "multi_preload %i ..."
108-
#define MULTI_BYPASS "multi_bypass %i %i ..."
109-
#define MULTI_PARAM_SET "multi_param_set %s %f %i ..."
110-
#define MULTI_PARAMS_FLUSH "multi_params_flush %i %i ... %i ..."
111-
#define HELP "help"
112-
#define QUIT "quit"
54+
#define EFFECT_ADD "add %s %i"
55+
#define EFFECT_REMOVE "remove %i"
56+
#define EFFECT_ACTIVATE "activate %i %i"
57+
#define EFFECT_PRELOAD "preload %s %i"
58+
#define EFFECT_PRESET_LOAD "preset_load %i %s"
59+
#define EFFECT_PRESET_SAVE "preset_save %i %s %s %s"
60+
#define EFFECT_PRESET_SHOW "preset_show %s"
61+
#define EFFECT_CONNECT "connect %s %s"
62+
#define EFFECT_CONNECT_MATCHING "connect_matching %s %s"
63+
#define EFFECT_DISCONNECT "disconnect %s %s"
64+
#define EFFECT_DISCONNECT_ALL "disconnect_all %s"
65+
#define EFFECT_BYPASS "bypass %i %i"
66+
#define EFFECT_PARAM_SET "param_set %i %s %f"
67+
#define EFFECT_PARAM_GET "param_get %i %s"
68+
#define EFFECT_PARAM_MON "param_monitor %i %s %s %f"
69+
#define EFFECT_PARAMS_FLUSH "params_flush %i %i %i ..."
70+
#define EFFECT_PATCH_GET "patch_get %i %s"
71+
#define EFFECT_PATCH_SET "patch_set %i %s %s"
72+
#define EFFECT_LICENSEE "licensee %i"
73+
#define EFFECT_SET_BPM "set_bpm %f"
74+
#define EFFECT_SET_BPB "set_bpb %f"
75+
#define MONITOR_ADDR_SET "monitor %s %i %i"
76+
#define MONITOR_OUTPUT "monitor_output %i %s"
77+
#define MONITOR_OUTPUT_OFF "monitor_output_off %i %s"
78+
#define MONITOR_AUDIO_LEVELS "monitor_audio_levels %i %s"
79+
#define MONITOR_MIDI_CONTROL "monitor_midi_control %i %i"
80+
#define MONITOR_MIDI_PROGRAM "monitor_midi_program %i %i"
81+
#define MIDI_LEARN "midi_learn %i %s %f %f"
82+
#define MIDI_MAP "midi_map %i %s %i %i %f %f"
83+
#define MIDI_UNMAP "midi_unmap %i %s"
84+
#define CC_MAP "cc_map %i %s %i %i %s %f %f %f %i %i %s %i ..."
85+
#define CC_VALUE_SET "cc_value_set %i %s %f"
86+
#define CC_UNMAP "cc_unmap %i %s"
87+
#define CV_MAP "cv_map %i %s %s %f %f %s"
88+
#define CV_UNMAP "cv_unmap %i %s"
89+
#define HMI_MAP "hmi_map %i %s %i %i %i %i %i %s %f %f %i"
90+
#define HMI_UNMAP "hmi_unmap %i %s"
91+
#define CPU_LOAD "cpu_load"
92+
#define MAX_CPU_LOAD "max_cpu_load"
93+
#define LOAD_COMMANDS "load %s"
94+
#define SAVE_COMMANDS "save %s"
95+
#define BUNDLE_ADD "bundle_add %s"
96+
#define BUNDLE_REMOVE "bundle_remove %s %s"
97+
#define STATE_LOAD "state_load %s"
98+
#define STATE_SAVE "state_save %s"
99+
#define STATE_TMPDIR "state_tmpdir %s"
100+
#define FEATURE_ENABLE "feature_enable %s %i"
101+
#define TRANSPORT "transport %i %f %f"
102+
#define TRANSPORT_SYNC "transport_sync %s"
103+
#define SHOW_EXTERNAL_UI "show_external_ui %i"
104+
#define OUTPUT_DATA_READY "output_data_ready"
105+
#define MULTI_ADD "multi_add %i ..."
106+
#define MULTI_REMOVE "multi_remove %i ..."
107+
#define MULTI_ACTIVATE "multi_activate %i %i ..."
108+
#define MULTI_PRELOAD "multi_preload %i ..."
109+
#define MULTI_BYPASS "multi_bypass %i %i ..."
110+
#define MULTI_PARAM_SET "multi_param_set %s %f %i ..."
111+
#define MULTI_PARAMS_FLUSH "multi_params_flush %i %i ... %i ..."
112+
#define HELP "help"
113+
#define QUIT "quit"
113114

114115

115116
/*

0 commit comments

Comments
 (0)