aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jalv.c34
-rw-r--r--src/jalv_internal.h10
-rw-r--r--src/presets.c10
3 files changed, 32 insertions, 22 deletions
diff --git a/src/jalv.c b/src/jalv.c
index e957579..e56c8eb 100644
--- a/src/jalv.c
+++ b/src/jalv.c
@@ -50,16 +50,6 @@
sem_t exit_sem; /**< Exit semaphore */
-/**
- Control change event, sent through ring buffers for UI updates.
-*/
-typedef struct {
- uint32_t index;
- uint32_t protocol;
- uint32_t size;
- uint8_t body[];
-} ControlChange;
-
LV2_URID
map_uri(LV2_URID_Map_Handle handle,
const char* uri)
@@ -370,7 +360,6 @@ jack_process_cb(jack_nframes_t nframes, void* data)
}
}
-
/* Run plugin for this cycle */
lilv_instance_run(host->instance, nframes);
@@ -384,16 +373,17 @@ jack_process_cb(jack_nframes_t nframes, void* data)
/* Deliver MIDI output and UI events */
for (uint32_t p = 0; p < host->num_ports; ++p) {
- if (host->ports[p].jack_port
- && !host->ports[p].flow == FLOW_INPUT
- && host->ports[p].type == TYPE_EVENT) {
+ struct Port* const port = &host->ports[p];
+ if (port->jack_port
+ && !port->flow == FLOW_INPUT
+ && port->type == TYPE_EVENT) {
- void* buf = jack_port_get_buffer(host->ports[p].jack_port,
+ void* buf = jack_port_get_buffer(port->jack_port,
nframes);
jack_midi_clear_buffer(buf);
- LV2_Evbuf_Iterator iter = lv2_evbuf_begin(host->ports[p].evbuf);
+ LV2_Evbuf_Iterator iter = lv2_evbuf_begin(port->evbuf);
const uint32_t event_count = lv2_evbuf_get_event_count(iter.evbuf);
for (uint32_t i = 0; i < event_count; ++i) {
uint32_t frames, subframes, type, size;
@@ -404,14 +394,14 @@ jack_process_cb(jack_nframes_t nframes, void* data)
iter = lv2_evbuf_next(iter);
}
} else if (send_ui_updates
- && !host->ports[p].flow == FLOW_INPUT
- && host->ports[p].type == TYPE_CONTROL) {
+ && port->flow != FLOW_INPUT
+ && port->type == TYPE_CONTROL) {
char buf[sizeof(ControlChange) + sizeof(float)];
ControlChange* ev = (ControlChange*)buf;
ev->index = p;
ev->protocol = 0;
ev->size = sizeof(float);
- *(float*)ev->body = host->ports[p].control;
+ *(float*)ev->body = port->control;
jack_ringbuffer_write(host->plugin_events, buf, sizeof(buf));
}
}
@@ -492,15 +482,15 @@ jalv_ui_write(SuilController controller,
bool
jalv_emit_ui_events(Jalv* host)
{
- #if 0
ControlChange ev;
size_t ev_read_size = jack_ringbuffer_read_space(host->plugin_events);
for (size_t i = 0; i < ev_read_size; i += sizeof(ev) + ev.size) {
jack_ringbuffer_read(host->plugin_events, (char*)&ev, sizeof(ev));
+ char buf[ev.size];
+ jack_ringbuffer_read(host->plugin_events, buf, ev.size);
suil_instance_port_event(host->ui_instance, ev.index,
- sizeof(float), 0, &ev.value);
+ ev.size, ev.protocol, buf);
}
- #endif
return true;
}
diff --git a/src/jalv_internal.h b/src/jalv_internal.h
index 95bc659..43a5c9c 100644
--- a/src/jalv_internal.h
+++ b/src/jalv_internal.h
@@ -67,6 +67,16 @@ struct Property {
SerdNode datatype;
};
+/**
+ Control change event, sent through ring buffers for UI updates.
+*/
+typedef struct {
+ uint32_t index;
+ uint32_t protocol;
+ uint32_t size;
+ uint8_t body[];
+} ControlChange;
+
typedef struct {
char* uuid;
char* load;
diff --git a/src/presets.c b/src/presets.c
index 1963e87..a7cd967 100644
--- a/src/presets.c
+++ b/src/presets.c
@@ -86,7 +86,17 @@ jalv_apply_preset(Jalv* jalv, const LilvNode* preset)
struct Port* p = jalv_port_by_symbol(jalv, sym);
if (p) {
const float fvalue = lilv_node_as_float(value);
+ // Send value to plugin
jalv_ui_write(jalv, p->index, sizeof(float), 0, &fvalue);
+
+ // Update UI
+ char buf[sizeof(ControlChange) + sizeof(float)];
+ ControlChange* ev = (ControlChange*)buf;
+ ev->index = p->index;
+ ev->protocol = 0;
+ ev->size = sizeof(float);
+ *(float*)ev->body = fvalue;
+ jack_ringbuffer_write(jalv->plugin_events, buf, sizeof(buf));
} else {
fprintf(stderr, "error: Preset port `%s' is missing\n", sym);
}