+void
+MachineControl::enable_send (bool yn)
+{
+ _enable_send = yn;
+}
+
+/** Send a MMC command to a the MMC port.
+ * @param c command.
+ */
+void
+MachineControl::send (MachineControlCommand const & c)
+{
+ if (_output_port == 0 || !_enable_send) {
+ // cerr << "Not delivering MMC " << _mmc->port() << " - " << session_send_mmc << endl;
+ return;
+ }
+
+ MIDI::byte buffer[32];
+ MIDI::byte* b = c.fill_buffer (this, buffer);
+
+ if (_output_port->midimsg (buffer, b - buffer, 0)) {
+ error << "MMC: cannot send command" << endmsg;
+ }
+}
+
+void
+MachineControl::spp_start ()
+{
+ SPPStart (); /* EMIT SIGNAL */
+}
+
+void
+MachineControl::spp_continue ()
+{
+ SPPContinue (); /* EMIT SIGNAL */
+}
+
+void
+MachineControl::spp_stop ()
+{
+ SPPStop (); /* EMIT SIGNAL */
+}
+
+MachineControlCommand::MachineControlCommand (MachineControl::Command c)
+ : _command (c)
+{
+
+}
+
+MachineControlCommand::MachineControlCommand (Timecode::Time t)
+ : _command (MachineControl::cmdLocate)
+ , _time (t)
+{
+
+}
+
+MIDI::byte *
+MachineControlCommand::fill_buffer (MachineControl* mmc, MIDI::byte* b) const
+{
+ *b++ = 0xf0; // SysEx
+ *b++ = 0x7f; // Real-time SysEx ID for MMC
+ *b++ = mmc->send_device_id();
+ *b++ = 0x6; // MMC command
+
+ *b++ = _command;
+
+ if (_command == MachineControl::cmdLocate) {
+ *b++ = 0x6; // byte count
+ *b++ = 0x1; // "TARGET" subcommand
+ *b++ = _time.hours;
+ *b++ = _time.minutes;
+ *b++ = _time.seconds;
+ *b++ = _time.frames;
+ *b++ = _time.subframes;
+ }
+
+ *b++ = 0xf7;
+
+ return b;
+}
+