mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-12 01:26:31 +01:00
infrastructure to allow tracing of all MIDI ports
This commit is contained in:
parent
266ac60941
commit
eddcd7128f
2 changed files with 28 additions and 2 deletions
|
|
@ -56,6 +56,8 @@ class LIBARDOUR_API MidiPort : public Port {
|
||||||
MidiBuffer& get_midi_buffer (pframes_t nframes);
|
MidiBuffer& get_midi_buffer (pframes_t nframes);
|
||||||
|
|
||||||
void set_always_parse (bool yn);
|
void set_always_parse (bool yn);
|
||||||
|
void set_trace_on (bool yn);
|
||||||
|
|
||||||
MIDI::Parser& self_parser() { return _self_parser; }
|
MIDI::Parser& self_parser() { return _self_parser; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -69,7 +71,8 @@ class LIBARDOUR_API MidiPort : public Port {
|
||||||
bool _resolve_required;
|
bool _resolve_required;
|
||||||
bool _input_active;
|
bool _input_active;
|
||||||
bool _always_parse;
|
bool _always_parse;
|
||||||
|
bool _trace_on;
|
||||||
|
|
||||||
/* Naming this is tricky. AsyncMIDIPort inherits (for now, aug 2013) from
|
/* Naming this is tricky. AsyncMIDIPort inherits (for now, aug 2013) from
|
||||||
* both MIDI::Port, which has _parser, and this (ARDOUR::MidiPort). We
|
* both MIDI::Port, which has _parser, and this (ARDOUR::MidiPort). We
|
||||||
* need parsing support in this object, independently of what the
|
* need parsing support in this object, independently of what the
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ MidiPort::MidiPort (const std::string& name, PortFlags flags)
|
||||||
, _resolve_required (false)
|
, _resolve_required (false)
|
||||||
, _input_active (true)
|
, _input_active (true)
|
||||||
, _always_parse (false)
|
, _always_parse (false)
|
||||||
|
, _trace_on (false)
|
||||||
{
|
{
|
||||||
_buffer = new MidiBuffer (AudioEngine::instance()->raw_buffer_size (DataType::MIDI));
|
_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));
|
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));
|
MidiBuffer& mb (get_midi_buffer (nframes));
|
||||||
|
|
||||||
/* dump incoming MIDI to parser */
|
/* dump incoming MIDI to parser */
|
||||||
|
|
@ -203,10 +204,26 @@ MidiPort::flush_buffers (pframes_t nframes)
|
||||||
port_buffer = port_engine.get_buffer (_port_handle, nframes);
|
port_buffer = port_engine.get_buffer (_port_handle, nframes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (MidiBuffer::iterator i = _buffer->begin(); i != _buffer->end(); ++i) {
|
for (MidiBuffer::iterator i = _buffer->begin(); i != _buffer->end(); ++i) {
|
||||||
|
|
||||||
const Evoral::MIDIEvent<MidiBuffer::TimeType> ev (*i, false);
|
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
|
// event times are in frames, relative to cycle start
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
|
@ -287,3 +304,9 @@ MidiPort::set_always_parse (bool yn)
|
||||||
{
|
{
|
||||||
_always_parse = yn;
|
_always_parse = yn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MidiPort::set_trace_on (bool yn)
|
||||||
|
{
|
||||||
|
_trace_on = yn;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue