summaryrefslogtreecommitdiff
path: root/libs/ardour/midi_port.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2017-08-05 15:04:05 +0200
committerRobin Gareus <robin@gareus.org>2017-08-05 15:36:36 +0200
commit2b7c585dbae9c989d35e2884060aad4b0270f90e (patch)
tree37e0f7fe263ad221ad29f4497383bea6ce0946f2 /libs/ardour/midi_port.cc
parentf9aff37623ba17a80371572fcba38515ea9b78ca (diff)
Update backend API: read-only MIDI input buffers
Diffstat (limited to 'libs/ardour/midi_port.cc')
-rw-r--r--libs/ardour/midi_port.cc27
1 files changed, 16 insertions, 11 deletions
diff --git a/libs/ardour/midi_port.cc b/libs/ardour/midi_port.cc
index 9a52aef3c6..7a87c4c273 100644
--- a/libs/ardour/midi_port.cc
+++ b/libs/ardour/midi_port.cc
@@ -129,28 +129,33 @@ MidiPort::get_midi_buffer (pframes_t nframes)
pframes_t timestamp;
size_t size;
- uint8_t* buf;
+ uint8_t const* buf;
port_engine.midi_event_get (timestamp, size, &buf, buffer, i);
if (buf[0] == 0xfe) {
/* throw away active sensing */
continue;
- } else if ((buf[0] & 0xF0) == 0x90 && buf[2] == 0) {
- /* normalize note on with velocity 0 to proper note off */
- buf[0] = 0x80 | (buf[0] & 0x0F); /* note off */
- buf[2] = 0x40; /* default velocity */
}
/* check that the event is in the acceptable time range */
+ if ((timestamp < (_global_port_buffer_offset + _port_buffer_offset)) ||
+ (timestamp >= (_global_port_buffer_offset + _port_buffer_offset + nframes))) {
+ cerr << "Dropping incoming MIDI at time " << timestamp << "; offset="
+ << _global_port_buffer_offset << " limit="
+ << (_global_port_buffer_offset + _port_buffer_offset + nframes) << "\n";
+ continue;
+ }
- if ((timestamp >= (_global_port_buffer_offset + _port_buffer_offset)) &&
- (timestamp < (_global_port_buffer_offset + _port_buffer_offset + nframes))) {
- _buffer->push_back (timestamp, size, buf);
+ if ((buf[0] & 0xF0) == 0x90 && buf[2] == 0) {
+ /* normalize note on with velocity 0 to proper note off */
+ uint8_t ev[3];
+ ev[0] = 0x80 | (buf[0] & 0x0F); /* note off */
+ ev[1] = buf[1];
+ ev[2] = 0x40; /* default velocity */
+ _buffer->push_back (timestamp, size, ev);
} else {
- cerr << "Dropping incoming MIDI at time " << timestamp << "; offset="
- << _global_port_buffer_offset << " limit="
- << (_global_port_buffer_offset + _port_buffer_offset + nframes) << "\n";
+ _buffer->push_back (timestamp, size, buf);
}
}