From 5ada17eba0195d90f0685776251b384efdf5168e Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 30 Sep 2017 05:25:27 +0200 Subject: [PATCH] Fix MIDI port offsets. AudioPort::get_audio_buffer() can offset the buffer simply by offsetting a pointer. This allows to get an offset buffer for a given port. For MIDI there's no such concept. A method writing to a MIDI buffer which is backed by a Port can at best offset it by the global port-buffer offset (static Port::port_offset), but not by the individual target port's offset. --- libs/ardour/midi_port.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libs/ardour/midi_port.cc b/libs/ardour/midi_port.cc index a728ce2a44..4a6cc3a3af 100644 --- a/libs/ardour/midi_port.cc +++ b/libs/ardour/midi_port.cc @@ -272,12 +272,13 @@ MidiPort::flush_buffers (pframes_t nframes) } #endif - assert (ev.time() < (nframes + _global_port_buffer_offset + _port_buffer_offset)); + assert (ev.time() < (nframes + _global_port_buffer_offset)); - if (ev.time() >= _global_port_buffer_offset + _port_buffer_offset) { - if (port_engine.midi_event_put (port_buffer, (pframes_t) ev.time(), ev.buffer(), ev.size()) != 0) { - cerr << "write failed, drop flushed note off on the floor, time " - << ev.time() << " > " << _global_port_buffer_offset + _port_buffer_offset << endl; + if (ev.time() >= _global_port_buffer_offset) { + if (port_engine.midi_event_put (port_buffer, (pframes_t) ev.time() + _port_buffer_offset, ev.buffer(), ev.size()) != 0) { + cerr << "write failed, dropped event, time " + << ev.time() << " + " << _port_buffer_offset + << " > " << _global_port_buffer_offset << endl; } } else { cerr << "drop flushed event on the floor, time " << ev.time()