X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fmidi%2B%2B2%2Fmmc.cc;h=d722a816eef104932a99669b875aed6bfd09de0b;hb=fb8bc4e8c97b4977b9698ba92b9ff7a8b9c54a5c;hp=1b8de40358914048cf2995253c2d03a048b0fc77;hpb=c98fcb62fb7daf5f52098dfe5ad4e68e71ddfe70;p=ardour.git diff --git a/libs/midi++2/mmc.cc b/libs/midi++2/mmc.cc index 1b8de40358..d722a816ee 100644 --- a/libs/midi++2/mmc.cc +++ b/libs/midi++2/mmc.cc @@ -22,12 +22,13 @@ #include #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; @@ -37,6 +38,13 @@ 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 mmc_cmd_map; static void build_mmc_cmd_map () { @@ -199,16 +207,21 @@ static void build_mmc_cmd_map () mmc_cmd_map.insert (newpair); } - -MachineControl::MachineControl (Manager* m, jack_client_t* jack) +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, jack)); - _output_port = m->add_port (new JackMIDIPort ("MMC out", Port::IsOutput, jack)); + _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)); @@ -271,7 +284,7 @@ MachineControl::process_mmc_message (Parser &, MIDI::byte *msg, size_t len) cerr << endl; #endif - if (msg[1] != 0x7f && msg[1] != _receive_device_id) { + if (_receive_device_id != 0x7f && msg[1] != 0x7f && msg[1] != _receive_device_id) { return; } @@ -638,7 +651,7 @@ MachineControl::enable_send (bool yn) * @param c command. */ void -MachineControl::send (MachineControlCommand const & c) +MachineControl::send (MachineControlCommand const & c, timestamp_t when) { if (_output_port == 0 || !_enable_send) { // cerr << "Not delivering MMC " << _mmc->port() << " - " << session_send_mmc << endl; @@ -648,7 +661,7 @@ MachineControl::send (MachineControlCommand const & c) MIDI::byte buffer[32]; MIDI::byte* b = c.fill_buffer (this, buffer); - if (_output_port->midimsg (buffer, b - buffer, 0)) { + if (_output_port->midimsg (buffer, b - buffer, when)) { error << "MMC: cannot send command" << endmsg; } } @@ -697,7 +710,7 @@ MachineControlCommand::fill_buffer (MachineControl* mmc, MIDI::byte* b) const if (_command == MachineControl::cmdLocate) { *b++ = 0x6; // byte count *b++ = 0x1; // "TARGET" subcommand - *b++ = _time.hours; + *b++ = _time.hours % 24; *b++ = _time.minutes; *b++ = _time.seconds; *b++ = _time.frames;