#include "pbd/compose.h"
#include "pbd/debug.h"
-#include "ardour/midi_port.h"
-#include "ardour/data_type.h"
#include "ardour/audioengine.h"
+#include "ardour/data_type.h"
#include "ardour/debug.h"
+#include "ardour/midi_buffer.h"
+#include "ardour/midi_port.h"
using namespace std;
using namespace ARDOUR;
, _resolve_required (false)
, _input_active (true)
, _always_parse (false)
+ , _trace_on (false)
{
_buffer = new MidiBuffer (AudioEngine::instance()->raw_buffer_size (DataType::MIDI));
}
port_engine.midi_clear (port_engine.get_buffer (_port_handle, nframes));
}
- if (_always_parse) {
+ if (_always_parse || (receives_input() && _trace_on)) {
MidiBuffer& mb (get_midi_buffer (nframes));
/* dump incoming MIDI to parser */
}
}
+Buffer&
+MidiPort::get_buffer (pframes_t nframes)
+{
+ return get_midi_buffer (nframes);
+}
+
MidiBuffer &
MidiPort::get_midi_buffer (pframes_t nframes)
{
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 */
port_buffer = port_engine.get_buffer (_port_handle, nframes);
}
+
for (MidiBuffer::iterator i = _buffer->begin(); i != _buffer->end(); ++i) {
const Evoral::MIDIEvent<MidiBuffer::TimeType> ev (*i, false);
+
+ if (sends_output() && _trace_on) {
+ uint8_t const * const buf = ev.buffer();
+ const framepos_t now = AudioEngine::instance()->sample_time_at_cycle_start();
+
+ _self_parser.set_timestamp (now + ev.time());
+
+ uint32_t limit = ev.size();
+
+ for (size_t n = 0; n < limit; ++n) {
+ _self_parser.scanner (buf[n]);
+ }
+ }
+
+
// event times are in frames, relative to cycle start
#ifndef NDEBUG
{
_always_parse = yn;
}
+
+void
+MidiPort::set_trace_on (bool yn)
+{
+ _trace_on = yn;
+}