From eddcd7128f955e70e636b857a45da3e6258a0a8d Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 10 Feb 2015 19:48:01 -0500 Subject: infrastructure to allow tracing of all MIDI ports --- libs/ardour/midi_port.cc | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'libs/ardour/midi_port.cc') diff --git a/libs/ardour/midi_port.cc b/libs/ardour/midi_port.cc index 8dcf4d42fc..b12999cc9f 100644 --- a/libs/ardour/midi_port.cc +++ b/libs/ardour/midi_port.cc @@ -40,6 +40,7 @@ MidiPort::MidiPort (const std::string& name, PortFlags flags) , _resolve_required (false) , _input_active (true) , _always_parse (false) + , _trace_on (false) { _buffer = new MidiBuffer (AudioEngine::instance()->raw_buffer_size (DataType::MIDI)); } @@ -62,7 +63,7 @@ MidiPort::cycle_start (pframes_t nframes) 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 */ @@ -203,10 +204,26 @@ MidiPort::flush_buffers (pframes_t nframes) port_buffer = port_engine.get_buffer (_port_handle, nframes); } + for (MidiBuffer::iterator i = _buffer->begin(); i != _buffer->end(); ++i) { const Evoral::MIDIEvent 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 @@ -287,3 +304,9 @@ MidiPort::set_always_parse (bool yn) { _always_parse = yn; } + +void +MidiPort::set_trace_on (bool yn) +{ + _trace_on = yn; +} -- cgit v1.2.3