summaryrefslogtreecommitdiff
path: root/libs/ardour/midi_port.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2013-08-13 12:53:28 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2013-08-13 12:53:28 -0400
commita5a75d5e0d4fb9f2c7db7cf3747da2314c2f9586 (patch)
tree7a00e05e90a8ada96eaba94aaa655e7391e90fe9 /libs/ardour/midi_port.cc
parenta5a3f713d596fd3d0157017263d6207b5427d133 (diff)
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.
Diffstat (limited to 'libs/ardour/midi_port.cc')
-rw-r--r--libs/ardour/midi_port.cc29
1 files changed, 27 insertions, 2 deletions
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;
+}