From d703079f1095a2cf767ef51ca325f8e85121a115 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 21 May 2021 18:30:35 +0200 Subject: [PATCH] ace-fluidsynth: add bypass (ignore notes, but retain reverb) --- libs/plugins/a-fluidsynth.lv2/a-fluidsynth.cc | 10 +++++++++- libs/plugins/a-fluidsynth.lv2/a-fluidsynth.ttl.in | 11 +++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/libs/plugins/a-fluidsynth.lv2/a-fluidsynth.cc b/libs/plugins/a-fluidsynth.lv2/a-fluidsynth.cc index 0ab1e10c45..04b3c3d849 100644 --- a/libs/plugins/a-fluidsynth.lv2/a-fluidsynth.cc +++ b/libs/plugins/a-fluidsynth.lv2/a-fluidsynth.cc @@ -72,6 +72,7 @@ enum { FS_CHR_DEPTH, FS_CHR_LEVEL, FS_CHR_TYPE, + FS_PORT_ENABLE, FS_PORT_LAST }; @@ -524,6 +525,13 @@ run (LV2_Handle instance, uint32_t n_samples) lv2_atom_forge_set_buffer (&self->forge, (uint8_t*)self->notify, capacity); lv2_atom_forge_sequence_head (&self->forge, &self->frame, 0); + const bool enabled = *self->p_ports[FS_PORT_ENABLE] > 0; + if (self->v_ports[FS_PORT_ENABLE] != *self->p_ports[FS_PORT_ENABLE]) { + if (self->initialized && !self->reinit_in_progress) { + fluid_synth_all_notes_off (self->synth, -1); + } + } + if (!self->initialized || self->reinit_in_progress) { memset (self->p_ports[FS_PORT_OUT_L], 0, n_samples * sizeof (float)); memset (self->p_ports[FS_PORT_OUT_R], 0, n_samples * sizeof (float)); @@ -602,7 +610,7 @@ run (LV2_Handle instance, uint32_t n_samples) } } } else if (ev->body.type == self->midi_MidiEvent) { - if (ev->time.frames >= n_samples || self->reinit_in_progress) { + if (ev->time.frames >= n_samples || self->reinit_in_progress || !enabled) { continue; } if (ev->body.size > 3) { diff --git a/libs/plugins/a-fluidsynth.lv2/a-fluidsynth.ttl.in b/libs/plugins/a-fluidsynth.lv2/a-fluidsynth.ttl.in index 98b6ea9327..75812e81d8 100644 --- a/libs/plugins/a-fluidsynth.lv2/a-fluidsynth.ttl.in +++ b/libs/plugins/a-fluidsynth.lv2/a-fluidsynth.ttl.in @@ -172,4 +172,15 @@ lv2:portProperty lv2:integer, lv2:enumeration; lv2:scalePoint [ rdfs:label "Sine"; rdf:value 0.0 ; ] ; lv2:scalePoint [ rdfs:label "Triangle"; rdf:value 1.0 ; ] ; + ] , + [ + a lv2:InputPort, lv2:ControlPort ; + lv2:index 16 ; + lv2:name "Enable" ; + lv2:symbol "enable" ; + lv2:default 1 ; + lv2:minimum 0 ; + lv2:maximum 1 ; + lv2:portProperty lv2:integer, lv2:toggled ; + lv2:designation lv2:enabled; ] .