+ port_engine.midi_event_get (timestamp, size, &buf, buffer, i);
+
+ if (buf[0] == 0xfe) {
+ /* throw away active sensing */
+ continue;
+ }
+
+ timestamp = floor (timestamp * _speed_ratio);
+
+ /* check that the event is in the acceptable time range */
+ if ((timestamp < (_global_port_buffer_offset)) ||
+ (timestamp >= (_global_port_buffer_offset + nframes))) {
+ // XXX this is normal after a split cycles:
+ // The engine buffer contains the data for the complete cycle, but
+ // only the part after _global_port_buffer_offset is needed.
+#ifndef NDEBUG
+ cerr << "Dropping incoming MIDI at time " << timestamp << "; offset="
+ << _global_port_buffer_offset << " limit="
+ << (_global_port_buffer_offset + nframes)
+ << " = (" << _global_port_buffer_offset
+ << " + " << nframes
+ << ")\n";
+#endif
+ continue;
+ }
+
+ 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 {
+ _buffer->push_back (timestamp, size, buf);
+ }