diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2015-02-10 19:48:01 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2015-02-10 19:48:47 -0500 |
commit | eddcd7128f955e70e636b857a45da3e6258a0a8d (patch) | |
tree | 87673d12a486621778ecc9d5684998d08fbcc6c7 /libs | |
parent | 266ac609419b7d659ac9ef01ae7f092298e9ab12 (diff) |
infrastructure to allow tracing of all MIDI ports
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/midi_port.h | 5 | ||||
-rw-r--r-- | libs/ardour/midi_port.cc | 25 |
2 files changed, 28 insertions, 2 deletions
diff --git a/libs/ardour/ardour/midi_port.h b/libs/ardour/ardour/midi_port.h index 0053a4dc72..b410f3d5af 100644 --- a/libs/ardour/ardour/midi_port.h +++ b/libs/ardour/ardour/midi_port.h @@ -56,6 +56,8 @@ class LIBARDOUR_API MidiPort : public Port { MidiBuffer& get_midi_buffer (pframes_t nframes); void set_always_parse (bool yn); + void set_trace_on (bool yn); + MIDI::Parser& self_parser() { return _self_parser; } protected: @@ -69,7 +71,8 @@ class LIBARDOUR_API MidiPort : public Port { bool _resolve_required; bool _input_active; bool _always_parse; - + bool _trace_on; + /* Naming this is tricky. AsyncMIDIPort inherits (for now, aug 2013) from * both MIDI::Port, which has _parser, and this (ARDOUR::MidiPort). We * need parsing support in this object, independently of what the 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<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 @@ -287,3 +304,9 @@ MidiPort::set_always_parse (bool yn) { _always_parse = yn; } + +void +MidiPort::set_trace_on (bool yn) +{ + _trace_on = yn; +} |