diff options
author | Timothy Krause <tmkrs4482@gmail.com> | 2021-11-30 06:26:10 -0700 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-08-07 21:21:01 -0400 |
commit | 906deeb65880163de93027cd804c596f3bc2936e (patch) | |
tree | ba7b93dc887c11113a86bce2b2934a62a46f4f47 /plugins/eg-midigate.lv2/midigate.c | |
parent | df88fe0d9d954a7f4076a680fccb04c78ac80f11 (diff) | |
download | lv2-906deeb65880163de93027cd804c596f3bc2936e.tar.xz |
midigate: Fix output timing
Previously, the state was updated before writing the output (up to the current
time), so output "in the past" would be incorrectly written based on the
current state. This fixes that by switching things around, so the output is
first written up to the current time, then the state is updated (and the loop
continues).
This takes advantage of the fact that write_output() effectively does nothing
with a zero length.
Diffstat (limited to 'plugins/eg-midigate.lv2/midigate.c')
-rw-r--r-- | plugins/eg-midigate.lv2/midigate.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/plugins/eg-midigate.lv2/midigate.c b/plugins/eg-midigate.lv2/midigate.c index 7b77079..d98f670 100644 --- a/plugins/eg-midigate.lv2/midigate.c +++ b/plugins/eg-midigate.lv2/midigate.c @@ -160,6 +160,9 @@ run(LV2_Handle instance, uint32_t sample_count) uint32_t offset = 0; LV2_ATOM_SEQUENCE_FOREACH (self->control, ev) { + write_output(self, offset, (uint32_t)(ev->time.frames - offset)); + offset = (uint32_t)ev->time.frames; + if (ev->body.type == self->uris.midi_MidiEvent) { const uint8_t* const msg = (const uint8_t*)(ev + 1); switch (lv2_midi_message_type(msg)) { @@ -185,9 +188,6 @@ run(LV2_Handle instance, uint32_t sample_count) break; } } - - write_output(self, offset, (uint32_t)(ev->time.frames - offset)); - offset = (uint32_t)ev->time.frames; } write_output(self, offset, sample_count - offset); |