summaryrefslogtreecommitdiff
path: root/libs/ardour/midi_clock_slave.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2013-08-07 22:22:11 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2013-08-07 22:22:11 -0400
commit1ab61b8564f9934c533d1c1a229888bc7e2fd557 (patch)
treebaa1b05b50c018ca0edbda936b35de58adb29d94 /libs/ardour/midi_clock_slave.cc
parent83a0c30c24ce6bb6e3e718c267a82fbaffc33b4b (diff)
major redesign of MIDI port heirarchy and management (part 2)
Diffstat (limited to 'libs/ardour/midi_clock_slave.cc')
-rw-r--r--libs/ardour/midi_clock_slave.cc44
1 files changed, 33 insertions, 11 deletions
diff --git a/libs/ardour/midi_clock_slave.cc b/libs/ardour/midi_clock_slave.cc
index 6f54d17d02..752644e9f4 100644
--- a/libs/ardour/midi_clock_slave.cc
+++ b/libs/ardour/midi_clock_slave.cc
@@ -31,6 +31,8 @@
#include "midi++/port.h"
#include "ardour/debug.h"
+#include "ardour/midi_buffer.h"
+#include "ardour/midi_port.h"
#include "ardour/slave.h"
#include "ardour/tempo.h"
@@ -41,13 +43,20 @@ using namespace ARDOUR;
using namespace MIDI;
using namespace PBD;
-MIDIClock_Slave::MIDIClock_Slave (Session& s, MIDI::Port& p, int ppqn)
+MIDIClock_Slave::MIDIClock_Slave (Session& s, MidiPort& p, int ppqn)
: ppqn (ppqn)
, bandwidth (10.0 / 60.0) // 1 BpM = 1 / 60 Hz
{
session = (ISlaveSessionProxy *) new SlaveSessionProxy(s);
rebind (p);
reset ();
+
+ parser.timing.connect_same_thread (port_connections, boost::bind (&MIDIClock_Slave::update_midi_clock, this, _1, _2));
+ parser.start.connect_same_thread (port_connections, boost::bind (&MIDIClock_Slave::start, this, _1, _2));
+ parser.contineu.connect_same_thread (port_connections, boost::bind (&MIDIClock_Slave::contineu, this, _1, _2));
+ parser.stop.connect_same_thread (port_connections, boost::bind (&MIDIClock_Slave::stop, this, _1, _2));
+ parser.position.connect_same_thread (port_connections, boost::bind (&MIDIClock_Slave::position, this, _1, _2, 3));
+
}
MIDIClock_Slave::MIDIClock_Slave (ISlaveSessionProxy* session_proxy, int ppqn)
@@ -63,20 +72,33 @@ MIDIClock_Slave::~MIDIClock_Slave()
delete session;
}
-void
-MIDIClock_Slave::rebind (MIDI::Port& p)
+int
+MIDIClock_Slave::process (pframes_t nframes)
{
- port_connections.drop_connections();
+ MidiBuffer& mb (port->get_midi_buffer (nframes));
- port = &p;
+ /* dump incoming MIDI to parser */
- DEBUG_TRACE (DEBUG::MidiClock, string_compose ("MIDIClock_Slave: connecting to port %1\n", port->name()));
+ for (MidiBuffer::iterator b = mb.begin(); b != mb.end(); ++b) {
+ uint8_t* buf = (*b).buffer();
+
+ parser.set_timestamp ((*b).time());
- port->parser()->timing.connect_same_thread (port_connections, boost::bind (&MIDIClock_Slave::update_midi_clock, this, _1, _2));
- port->parser()->start.connect_same_thread (port_connections, boost::bind (&MIDIClock_Slave::start, this, _1, _2));
- port->parser()->contineu.connect_same_thread (port_connections, boost::bind (&MIDIClock_Slave::contineu, this, _1, _2));
- port->parser()->stop.connect_same_thread (port_connections, boost::bind (&MIDIClock_Slave::stop, this, _1, _2));
- port->parser()->position.connect_same_thread (port_connections, boost::bind (&MIDIClock_Slave::position, this, _1, _2, 3));
+ uint32_t limit = (*b).size();
+
+ for (size_t n = 0; n < limit; ++n) {
+ parser.scanner (buf[n]);
+ }
+ }
+
+ return 0;
+}
+
+void
+MIDIClock_Slave::rebind (MidiPort& p)
+{
+ port = &p;
+ DEBUG_TRACE (DEBUG::MidiClock, string_compose ("MIDIClock_Slave: connecting to port %1\n", port->name()));
}
void