fix for storing 14 bit MIDI controller values
[ardour.git] / libs / midi++2 / mmc.cc
index 0a71463721ff47e638aa8807fca1a874b233d091..b92e686ce6b753bca71bea99b2b2be0b5fa70c98 100644 (file)
 #include <map>
 
 #include "timecode/time.h"
+#include "timecode/bbt_time.h"
 
 #include "pbd/error.h"
 
 #include "midi++/mmc.h"
 #include "midi++/port.h"
-#include "midi++/jack_midi_port.h"
 #include "midi++/parser.h"
-#include "midi++/manager.h"
+
+#ifndef __INT_MAX__   // 'ssize_t' won't be defined yet
+typedef long ssize_t;
+#endif
 
 using namespace std;
 using namespace MIDI;
 using namespace PBD;
 
+/**
+ * As libtimecode is linked statically to libmidi++ this
+ * is necessary to pull in all the symbols from libtimecode
+ * so they are exported for other users of libtimecode.
+ */
+double tmp = Timecode::BBT_Time::ticks_per_beat;
+
 static std::map<int,string> mmc_cmd_map;
 static void build_mmc_cmd_map ()
 {
@@ -197,16 +207,21 @@ static void build_mmc_cmd_map ()
        mmc_cmd_map.insert (newpair);
 }
 
-
-MachineControl::MachineControl (Manager* m, ARDOUR::PortEngine& pengine)
+MachineControl::MachineControl ()
 {
        build_mmc_cmd_map ();
 
        _receive_device_id = 0x7f;
        _send_device_id = 0x7f;
+}
+
+void
+MachineControl::set_ports (MIDI::Port* ip, MIDI::Port* op)
+{
+       port_connections.drop_connections ();
 
-       _input_port = m->add_port (new JackMIDIPort ("MMC in", Port::IsInput, pengine));
-       _output_port = m->add_port (new JackMIDIPort ("MMC out", Port::IsOutput, pengine));
+       _input_port = ip;
+       _output_port = op;
 
        _input_port->parser()->mmc.connect_same_thread (port_connections, boost::bind (&MachineControl::process_mmc_message, this, _1, _2, _3));
        _input_port->parser()->start.connect_same_thread (port_connections, boost::bind (&MachineControl::spp_start, this));
@@ -215,19 +230,19 @@ MachineControl::MachineControl (Manager* m, ARDOUR::PortEngine& pengine)
 }
 
 void
-MachineControl::set_receive_device_id (byte id)
+MachineControl::set_receive_device_id (MIDI::byte id)
 {
        _receive_device_id = id & 0x7f;
 }
 
 void
-MachineControl::set_send_device_id (byte id)
+MachineControl::set_send_device_id (MIDI::byte id)
 {
        _send_device_id = id & 0x7f;
 }
 
 bool
-MachineControl::is_mmc (byte *sysex_buf, size_t len)
+MachineControl::is_mmc (MIDI::byte *sysex_buf, size_t len)
 {
        if (len < 4 || len > 48) {
                return false;
@@ -246,7 +261,7 @@ MachineControl::is_mmc (byte *sysex_buf, size_t len)
 }
 
 void
-MachineControl::process_mmc_message (Parser &, byte *msg, size_t len)
+MachineControl::process_mmc_message (Parser &, MIDI::byte *msg, size_t len)
 {
        size_t skiplen;
        byte *mmc_msg;
@@ -453,7 +468,7 @@ MachineControl::process_mmc_message (Parser &, byte *msg, size_t len)
 }              
 
 int
-MachineControl::do_masked_write (byte *msg, size_t len)
+MachineControl::do_masked_write (MIDI::byte *msg, size_t len)
 {
        /* return the number of bytes "consumed" */
 
@@ -479,7 +494,7 @@ MachineControl::do_masked_write (byte *msg, size_t len)
 }
 
 void
-MachineControl::write_track_status (byte *msg, size_t /*len*/, byte reg)
+MachineControl::write_track_status (MIDI::byte *msg, size_t /*len*/, MIDI::byte reg)
 {
        size_t n;
        ssize_t base_track;
@@ -568,7 +583,7 @@ MachineControl::write_track_status (byte *msg, size_t /*len*/, byte reg)
 }
 
 int
-MachineControl::do_locate (byte *msg, size_t /*msglen*/)
+MachineControl::do_locate (MIDI::byte *msg, size_t /*msglen*/)
 {
        if (msg[2] == 0) {
                warning << "MIDI::MMC: locate [I/F] command not supported"
@@ -583,7 +598,7 @@ MachineControl::do_locate (byte *msg, size_t /*msglen*/)
 }
 
 int
-MachineControl::do_step (byte *msg, size_t /*msglen*/)
+MachineControl::do_step (MIDI::byte *msg, size_t /*msglen*/)
 {
        int steps = msg[2] & 0x3f;
 
@@ -596,7 +611,7 @@ MachineControl::do_step (byte *msg, size_t /*msglen*/)
 }
 
 int
-MachineControl::do_shuttle (byte *msg, size_t /*msglen*/)
+MachineControl::do_shuttle (MIDI::byte *msg, size_t /*msglen*/)
 {
        size_t forward;
        byte sh = msg[2];