From a5a75d5e0d4fb9f2c7db7cf3747da2314c2f9586 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 13 Aug 2013 12:53:28 -0400 Subject: fixes to get MTC (and probably MIDI clock) slaving working again incoming MIDI data has to be parsed EVERY process cycle, not just when Slave::speed_and_position() is called. The private MIDI::Parser owned by the MTC and MClck slaves was irrelevant, since the port has its own. See comments in midi_port.h on the strangled inheritance heirarchy. --- libs/ardour/midi_port.cc | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'libs/ardour/midi_port.cc') diff --git a/libs/ardour/midi_port.cc b/libs/ardour/midi_port.cc index 1816ddcb6f..eb6759f308 100644 --- a/libs/ardour/midi_port.cc +++ b/libs/ardour/midi_port.cc @@ -33,6 +33,7 @@ MidiPort::MidiPort (const std::string& name, PortFlags flags) , _has_been_mixed_down (false) , _resolve_required (false) , _input_active (true) + , _always_parse (false) { _buffer = new MidiBuffer (AudioEngine::instance()->raw_buffer_size (DataType::MIDI)); } @@ -45,6 +46,8 @@ MidiPort::~MidiPort() void MidiPort::cycle_start (pframes_t nframes) { + framepos_t now = AudioEngine::instance()->sample_time_at_cycle_start(); + Port::cycle_start (nframes); _buffer->clear (); @@ -52,6 +55,24 @@ MidiPort::cycle_start (pframes_t nframes) if (sends_output ()) { port_engine.midi_clear (port_engine.get_buffer (_port_handle, nframes)); } + + if (_always_parse) { + MidiBuffer& mb (get_midi_buffer (nframes)); + + /* dump incoming MIDI to parser */ + + for (MidiBuffer::iterator b = mb.begin(); b != mb.end(); ++b) { + uint8_t* buf = (*b).buffer(); + + _self_parser.set_timestamp (now + (*b).time()); + + uint32_t limit = (*b).size(); + + for (size_t n = 0; n < limit; ++n) { + _self_parser.scanner (buf[n]); + } + } + } } MidiBuffer & @@ -72,8 +93,6 @@ MidiPort::get_midi_buffer (pframes_t nframes) into our MidiBuffer */ - cerr << "grabbing " << event_count << " events\n"; - for (pframes_t i = 0; i < event_count; ++i) { pframes_t timestamp; @@ -217,3 +236,9 @@ MidiPort::set_input_active (bool yn) { _input_active = yn; } + +void +MidiPort::set_always_parse (bool yn) +{ + _always_parse = yn; +} -- cgit v1.2.3