if (g_atomic_int_get (&_record_status) != Recording) {
g_atomic_int_set (&_record_status, Recording);
_last_record_location = _transport_frame;
- if (_mmc) {
- _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdRecordStrobe));
- }
+ _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdRecordStrobe));
if (Config->get_monitoring_model() == HardwareMonitoring && config.get_auto_input()) {
if ((!Config->get_latched_record_enable () && !play_loop) || force) {
g_atomic_int_set (&_record_status, Disabled);
- if (_mmc) {
- _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdRecordExit));
- }
+ _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdRecordExit));
} else {
if (rs == Recording) {
g_atomic_int_set (&_record_status, Enabled);
enable_record ();
}
} else {
- if (_mmc) {
- _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdRecordPause));
- }
+ _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdRecordPause));
RecordStateChanged (); /* EMIT SIGNAL */
}
{
string port_name;
+ if (default_mmc_port) {
+ _mmc->set_port (default_mmc_port);
+ }
+
if (default_mtc_port) {
set_mtc_port (default_mtc_port->name());
} else {
}
} else {
- if (_mmc && _mmc->port()) {
+ if (_mmc->port()) {
if ((input_parser = _mmc->port()->input()) != 0) {
input_parser->trace (yn, &cout, "input: ");
}
}
- if (_mtc_port && (!_mmc || (_mtc_port != _mmc->port()))) {
+ if (_mtc_port && _mtc_port != _mmc->port()) {
if ((input_parser = _mtc_port->input()) != 0) {
input_parser->trace (yn, &cout, "input: ");
}
}
- if (_midi_port && (!_mmc || (_midi_port != _mmc->port())) && _midi_port != _mtc_port ) {
+ if (_midi_port && _midi_port != _mmc->port() && _midi_port != _mtc_port) {
if ((input_parser = _midi_port->input()) != 0) {
input_parser->trace (yn, &cout, "input: ");
}
}
if (_midi_clock_port
- && (!_mmc || (_midi_clock_port != _mmc->port()))
+ && _midi_clock_port != _mmc->port()
&& _midi_clock_port != _mtc_port
&& _midi_clock_port != _midi_port) {
if ((input_parser = _midi_clock_port->input()) != 0) {
output_parser->trace (yn, &cout, "output: ");
}
} else {
- if (_mmc && _mmc->port()) {
+ if (_mmc->port()) {
if ((output_parser = _mmc->port()->output()) != 0) {
output_parser->trace (yn, &cout, "output: ");
}
}
}
- if (_midi_port && (!_mmc || (_midi_port != _mmc->port())) && _midi_port != _mtc_port ) {
+ if (_midi_port && _midi_port != _mmc->port() && _midi_port != _mtc_port) {
if ((output_parser = _midi_port->output()) != 0) {
output_parser->trace (yn, &cout, "output: ");
}
}
}
else {
- if (_mmc && _mmc->port()) {
+ if (_mmc->port()) {
if ((input_parser = _mmc->port()->input()) != 0) {
return input_parser->tracing();
}
}
}
else {
- if (_mmc && _mmc->port()) {
+ if (_mmc->port()) {
if ((output_parser = _mmc->port()->output()) != 0) {
return output_parser->tracing();
}
}
}
- if (_mmc) {
- _mmc->flush_pending ();
- }
+ _mmc->flush_pending ();
_engine.main_thread()->get_buffers ();
send_full_time_code (0);
_engine.transport_locate (0);
- if (_mmc) {
- _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdMmcReset));
- _mmc->send (MIDI::MachineControlCommand (Timecode::Time ()));
- }
+ _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdMmcReset));
+ _mmc->send (MIDI::MachineControlCommand (Timecode::Time ()));
MidiClockTicker::instance().set_session (this);
MIDI::Name::MidiPatchManager::instance().set_session (this);
error << _("Session: XML state has no options section") << endmsg;
}
- setup_midi_machine_control ();
-
- if (use_config_midi_ports ()) {
- }
+ use_config_midi_ports ();
if (version >= 3000) {
if ((child = find_named_node (node, "Metadata")) == 0) {
} else if (p == "mmc-device-id" || p == "mmc-receive-id") {
- if (_mmc) {
- _mmc->set_receive_device_id (Config->get_mmc_receive_device_id());
- }
+ _mmc->set_receive_device_id (Config->get_mmc_receive_device_id());
} else if (p == "mmc-send-id") {
- if (_mmc) {
- _mmc->set_send_device_id (Config->get_mmc_send_device_id());
- }
+ _mmc->set_send_device_id (Config->get_mmc_send_device_id());
} else if (p == "midi-control") {
} else if (p == "send-mmc") {
- if (_mmc) {
- _mmc->enable_send (Config->get_send_mmc ());
- }
+ _mmc->enable_send (Config->get_send_mmc ());
} else if (p == "midi-feedback") {
sync_order_keys ("session");
} else if (p == "initial-program-change") {
- if (_mmc && _mmc->port() && Config->get_initial_program_change() >= 0) {
+ if (_mmc->port() && Config->get_initial_program_change() >= 0) {
MIDI::byte buf[2];
buf[0] = MIDI::program; // channel zero by default
}
} else if (p == "initial-program-change") {
- if (_mmc && _mmc->port() && Config->get_initial_program_change() >= 0) {
+ if (_mmc->port() && Config->get_initial_program_change() >= 0) {
MIDI::byte* buf = new MIDI::byte[2];
buf[0] = MIDI::program; // channel zero by default
void
Session::setup_midi_machine_control ()
{
- if (!default_mmc_port) {
- return;
- }
-
_mmc = new MIDI::MachineControl;
- _mmc->set_port (default_mmc_port);
-
+
_mmc->Play.connect_same_thread (*this, boost::bind (&Session::mmc_deferred_play, this, _1));
_mmc->DeferredPlay.connect_same_thread (*this, boost::bind (&Session::mmc_deferred_play, this, _1));
_mmc->Stop.connect_same_thread (*this, boost::bind (&Session::mmc_stop, this, _1));
/* also handle MIDI SPP because its so common */
- _mmc->port()->input()->start.connect_same_thread (*this, boost::bind (&Session::spp_start, this, _1, _2));
- _mmc->port()->input()->contineu.connect_same_thread (*this, boost::bind (&Session::spp_continue, this, _1, _2));
- _mmc->port()->input()->stop.connect_same_thread (*this, boost::bind (&Session::spp_stop, this, _1, _2));
+ _mmc->SPPStart.connect_same_thread (*this, boost::bind (&Session::spp_start, this, _1, _2));
+ _mmc->SPPContinue.connect_same_thread (*this, boost::bind (&Session::spp_continue, this, _1, _2));
+ _mmc->SPPStop.connect_same_thread (*this, boost::bind (&Session::spp_stop, this, _1, _2));
}
// FIXME: where should this really be? [DR]
//send_full_time_code();
- if (_mmc) {
- Timecode::Time time;
- timecode_time_subframes (_transport_frame, time);
-
- _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdStop));
- _mmc->send (MIDI::MachineControlCommand (time));
- }
+ Timecode::Time time;
+ timecode_time_subframes (_transport_frame, time);
+
+ _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdStop));
+ _mmc->send (MIDI::MachineControlCommand (time));
if (_transport_speed < 0.0f) {
todo = (PostTransportWork (todo | PostTransportStop | PostTransportReverse));
_send_timecode_update = true;
- if (with_mmc && _mmc) {
+ if (with_mmc) {
Timecode::Time time;
timecode_time_subframes (_transport_frame, time);
_mmc->send (MIDI::MachineControlCommand (time));
}
}
- if (_mmc) {
- Timecode::Time time;
- timecode_time_subframes (_transport_frame, time);
- _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdDeferredPlay));
- }
+ Timecode::Time time;
+ timecode_time_subframes (_transport_frame, time);
+ _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdDeferredPlay));
TransportStateChange (); /* EMIT SIGNAL */
}
#include "pbd/signals.h"
#include "pbd/ringbuffer.h"
#include "midi++/types.h"
+#include "midi++/parser.h"
namespace MIDI {
class Port;
class Parser;
-class MachineControlCommand;
+class MachineControlCommand;
/** Class to handle incoming and outgoing MIDI machine control messages */
class MachineControl
MMCSignal Wait;
MMCSignal Resume;
+ TimestampedSignal SPPStart;
+ TimestampedSignal SPPContinue;
+ TimestampedSignal SPPStop;
+
/* The second argument is the shuttle speed, the third is
true if the direction is "forwards", false for "reverse"
*/
static pthread_t _sending_thread;
void process_mmc_message (Parser &p, byte *, size_t len);
- PBD::ScopedConnection mmc_connection; ///< connection to our parser for incoming data
+ PBD::ScopedConnectionList port_connections; ///< connections to our parser for incoming data
int do_masked_write (byte *, size_t len);
int do_locate (byte *, size_t len);
void send_immediately (MachineControlCommand const &);
void write_track_status (byte *, size_t len, byte reg);
+ void spp_start (Parser&, nframes_t);
+ void spp_continue (Parser&, nframes_t);
+ void spp_stop (Parser&, nframes_t);
};
/** Class to describe a MIDI machine control command to be sent.
{
_port = p;
- mmc_connection.disconnect ();
+ port_connections.drop_connections ();
if (_port->input()) {
- _port->input()->mmc.connect_same_thread (mmc_connection, boost::bind (&MachineControl::process_mmc_message, this, _1, _2, _3));
+ _port->input()->mmc.connect_same_thread (port_connections, boost::bind (&MachineControl::process_mmc_message, this, _1, _2, _3));
+ _port->input()->start.connect_same_thread (port_connections, boost::bind (&MachineControl::spp_start, this, _1, _2));
+ _port->input()->contineu.connect_same_thread (port_connections, boost::bind (&MachineControl::spp_continue, this, _1, _2));
+ _port->input()->stop.connect_same_thread (port_connections, boost::bind (&MachineControl::spp_stop, this, _1, _2));
} else {
warning << "MMC connected to a non-input port: useless!" << endmsg;
}
_sending_thread = t;
}
+void
+MachineControl::spp_start (Parser& parser, nframes_t timestamp)
+{
+ SPPStart (parser, timestamp); /* EMIT SIGNAL */
+}
+
+void
+MachineControl::spp_continue (Parser& parser, nframes_t timestamp)
+{
+ SPPContinue (parser, timestamp); /* EMIT SIGNAL */
+}
+
+void
+MachineControl::spp_stop (Parser& parser, nframes_t timestamp)
+{
+ SPPStop (parser, timestamp); /* EMIT SIGNAL */
+}
+
MachineControlCommand::MachineControlCommand (MachineControl::Command c)
: _command (c)
{
return b;
}
+