summaryrefslogtreecommitdiff
path: root/libs/ardour/midi_port.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2019-12-17 05:56:49 +0100
committerRobin Gareus <robin@gareus.org>2019-12-17 05:56:49 +0100
commit37c9a7beb103d4b0eca93b717621b35a6ab6cbb3 (patch)
treeb4cdbaea40dde60e3121f377447a708faac64ee9 /libs/ardour/midi_port.cc
parent7fe9fb1f4e127e312a9475cb75c9fa0cab6e5523 (diff)
Fix MIDI port i/o when vari-speeding
Diffstat (limited to 'libs/ardour/midi_port.cc')
-rw-r--r--libs/ardour/midi_port.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/libs/ardour/midi_port.cc b/libs/ardour/midi_port.cc
index 1a34b032b8..f5068d7f02 100644
--- a/libs/ardour/midi_port.cc
+++ b/libs/ardour/midi_port.cc
@@ -101,6 +101,7 @@ MidiPort::get_midi_buffer (pframes_t nframes)
}
if (receives_input () && _input_active) {
+ _buffer->clear ();
void* buffer = port_engine.get_buffer (_port_handle, nframes);
const pframes_t event_count = port_engine.get_midi_event_count (buffer);
@@ -154,6 +155,8 @@ MidiPort::get_midi_buffer (pframes_t nframes)
continue;
}
+ timestamp -= _global_port_buffer_offset;
+
if ((buf[0] & 0xF0) == 0x90 && buf[2] == 0) {
/* normalize note on with velocity 0 to proper note off */
uint8_t ev[3];
@@ -288,7 +291,7 @@ MidiPort::flush_buffers (pframes_t nframes)
uint8_t const * const buf = ev.buffer();
const samplepos_t now = AudioEngine::instance()->sample_time_at_cycle_start();
- _trace_parser->set_timestamp (now + adjusted_time);
+ _trace_parser->set_timestamp (now + adjusted_time / _speed_ratio);
uint32_t limit = ev.size();
@@ -327,7 +330,9 @@ MidiPort::flush_buffers (pframes_t nframes)
cerr << "write failed, dropped event, time " << adjusted_time << '/' << ev.time() << endl;
}
} else {
- cerr << "Dropped outgoing MIDI event. time " << adjusted_time << '/' << ev.time()
+ pframes_t tme = floor (adjusted_time / _speed_ratio);
+ cerr << "Dropped outgoing MIDI event. time " << adjusted_time
+ << " (" << ev.time() << ") @" << _speed_ratio << " = " << tme
<< " out of range [" << _global_port_buffer_offset
<< " .. " << _global_port_buffer_offset + nframes
<< "]";