diff options
author | David Robillard <d@drobilla.net> | 2024-11-16 18:25:20 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2024-11-24 19:03:42 -0500 |
commit | d52d38ccdc9bc38fe5c62eb2458be30b3cf6ca59 (patch) | |
tree | 838e9d5251ad1a710c297e0c5f1252632ad03c76 /src | |
parent | 8e648abdcfefbf2a2e3774aa8827b5dcd6569e3b (diff) | |
download | jalv-d52d38ccdc9bc38fe5c62eb2458be30b3cf6ca59.tar.gz jalv-d52d38ccdc9bc38fe5c62eb2458be30b3cf6ca59.tar.bz2 jalv-d52d38ccdc9bc38fe5c62eb2458be30b3cf6ca59.zip |
Only send control messages to designated lv2:control ports
Diffstat (limited to 'src')
-rw-r--r-- | src/jack.c | 8 | ||||
-rw-r--r-- | src/jalv.c | 29 | ||||
-rw-r--r-- | src/port.h | 1 | ||||
-rw-r--r-- | src/portaudio.c | 3 |
4 files changed, 19 insertions, 22 deletions
@@ -191,15 +191,15 @@ jack_process_cb(jack_nframes_t nframes, void* data) jalv->instance, p, jack_port_get_buffer(port->sys_port, nframes)); } else if (port->type == TYPE_EVENT && port->flow == FLOW_INPUT) { lv2_evbuf_reset(port->evbuf, true); - - // Write transport change event if applicable LV2_Evbuf_Iterator iter = lv2_evbuf_begin(port->evbuf); - if (xport_changed) { + + if (port->is_primary && xport_changed) { + // Write new transport position lv2_evbuf_write( &iter, 0, 0, lv2_pos->type, lv2_pos->size, LV2_ATOM_BODY(lv2_pos)); } - if (jalv->request_update) { + if (port->is_primary && jalv->request_update) { // Plugin state has changed, request an update jalv_write_get_message(&iter, &jalv->urids); } @@ -221,6 +221,16 @@ create_port(Jalv* jalv, uint32_t port_index, float default_value) } lilv_node_free(min_size); + // Set primary flag for designated control port + if (port->type == TYPE_EVENT && + has_designation( + &jalv->nodes, jalv->plugin, port, jalv->nodes.lv2_control)) { + port->is_primary = true; + if (port->flow == FLOW_INPUT && jalv->control_in == UINT32_MAX) { + jalv->control_in = port->index; + } + } + // Set reports_latency flag if (port->flow == FLOW_OUTPUT && port->type == TYPE_CONTROL && (lilv_port_has_property( @@ -245,19 +255,6 @@ jalv_create_ports(Jalv* jalv) create_port(jalv, i, default_values[i]); } - const LilvPort* control_input = lilv_plugin_get_port_by_designation( - jalv->plugin, jalv->nodes.lv2_InputPort, jalv->nodes.lv2_control); - if (control_input) { - const uint32_t index = lilv_port_get_index(jalv->plugin, control_input); - if (jalv->ports[index].type == TYPE_EVENT) { - jalv->control_in = index; - } else { - jalv_log(JALV_LOG_WARNING, - "Non-event port %u has lv2:control designation, ignored\n", - index); - } - } - free(default_values); } @@ -431,7 +428,7 @@ jalv_set_control(Jalv* jalv, if (control->type == PORT && type == jalv->forge.Float) { JalvPort* const port = &jalv->ports[control->index]; port->control = *(const float*)body; - } else if (control->type == PROPERTY) { + } else if (control->type == PROPERTY && jalv->control_in != UINT32_MAX) { // Copy forge since it is used by process thread LV2_Atom_Forge forge = jalv->forge; LV2_Atom_Forge_Frame frame; @@ -552,7 +549,7 @@ jalv_init_ui(Jalv* jalv) } } - if (jalv->control_in != (uint32_t)-1) { + if (jalv->control_in != UINT32_MAX) { // Send patch:Get message for initial parameters/etc LV2_Atom_Forge forge = jalv->forge; LV2_Atom_Forge_Frame frame; @@ -929,7 +926,7 @@ jalv_open(Jalv* const jalv, int* argc, char*** argv) jalv->msg_buf_size = 1024U; jalv->play_state = JALV_PAUSED; jalv->bpm = 120.0f; - jalv->control_in = (uint32_t)-1; + jalv->control_in = UINT32_MAX; jalv->log.urids = &jalv->urids; jalv->log.tracing = jalv->opts.trace; @@ -35,6 +35,7 @@ typedef struct { uint32_t index; ///< Port index float control; ///< For control ports, otherwise 0.0f bool reports_latency; ///< For control port outputs + bool is_primary; ///< True for main control/reponse channel } JalvPort; JALV_END_DECLS diff --git a/src/portaudio.c b/src/portaudio.c index d509d04..0a7fa5a 100644 --- a/src/portaudio.c +++ b/src/portaudio.c @@ -51,8 +51,7 @@ pa_process_cb(const void* inputs, } } else if (port->type == TYPE_EVENT && port->flow == FLOW_INPUT) { lv2_evbuf_reset(port->evbuf, true); - - if (jalv->request_update) { + if (port->is_primary && jalv->request_update) { // Plugin state has changed, request an update LV2_Evbuf_Iterator iter = lv2_evbuf_begin(port->evbuf); jalv_write_get_message(&iter, &jalv->urids); |