using namespace std;
using namespace ARDOUR;
-//using namespace sigc;
+using namespace PBD;
using namespace MIDI;
MachineControl::CommandSignature MMC_CommandSignature;
MTC, MMC, etc.
**********************************************************************/
-void
-Session::set_mmc_control (bool yn)
-{
- if (mmc_control == yn) {
- return;
- }
-
- mmc_control = yn;
- set_dirty();
- poke_midi_thread ();
-
- ControlChanged (MMCControl); /* EMIT SIGNAL */
-}
-
-void
-Session::set_midi_control (bool yn)
-{
- if (midi_control == yn) {
- return;
- }
-
- midi_control = yn;
- set_dirty();
- poke_midi_thread ();
-
- if (_midi_port) {
- Glib::RWLock::ReaderLock guard (route_lock);
- for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) {
- (*i)->reset_midi_control (_midi_port, midi_control);
- }
- }
-
- ControlChanged (MidiControl); /* EMIT SIGNAL */
-}
-
-void
-Session::set_send_mtc (bool yn)
-{
- /* set the persistent option value regardless */
-
- send_midi_timecode = yn;
- set_dirty();
-
- /* only set the internal flag if we have
- a port.
- */
-
- if (_mtc_port == 0 || send_mtc == yn) {
- return;
- }
-
- send_mtc = yn;
- ControlChanged (SendMTC); /* EMIT SIGNAL */
-}
-
-void
-Session::set_send_mmc (bool yn)
-{
- if (_mmc_port == 0) {
- return;
- }
-
- if (send_midi_machine_control == yn) {
- return;
- }
-
- /* only set the internal flag if we have
- a port.
- */
-
- if (_mmc_port) {
- send_mmc = yn;
- }
-
- /* set the persistent option value regardless */
-
- send_midi_machine_control = yn;
- set_dirty();
-
- ControlChanged (SendMMC); /* EMIT SIGNAL */
-}
-
-void
-Session::set_midi_feedback (bool yn)
-{
-}
-
-bool
-Session::get_midi_feedback () const
-{
- return false;
-}
-
-bool
-Session::get_send_mtc () const
-{
- return send_mtc;
-}
-
-bool
-Session::get_send_mmc () const
-{
- return send_mmc;
-}
-
int
Session::set_mtc_port (string port_tag)
{
if (_mmc_port != 0) {
- send_mmc = send_midi_machine_control;
+ Config->set_send_mmc (session_send_mmc);
} else {
mmc = 0;
- send_mmc = false;
+ session_send_mmc = false;
}
if (_mtc_port != 0) {
- send_mtc = send_midi_timecode;
+ Config->set_send_mtc (session_send_mtc);
} else {
-
- send_mtc = false;
+ session_send_mtc = false;
}
}
void
Session::spp_start (Parser& ignored)
{
- if (mmc_control && (_slave_type != MTC)) {
+ if (Config->get_mmc_control() && (Config->get_slave_source() != MTC)) {
request_transport_speed (1.0);
}
}
void
Session::spp_stop (Parser& ignored)
{
- if (mmc_control) {
+ if (Config->get_mmc_control()) {
request_stop ();
}
}
void
Session::mmc_deferred_play (MIDI::MachineControl &mmc)
{
- if (mmc_control && (_slave_type != MTC)) {
+ if (Config->get_mmc_control() && (Config->get_slave_source() != MTC)) {
request_transport_speed (1.0);
}
}
void
Session::mmc_record_pause (MIDI::MachineControl &mmc)
{
- if (mmc_control) {
+ if (Config->get_mmc_control()) {
maybe_enable_record();
}
}
void
Session::mmc_record_strobe (MIDI::MachineControl &mmc)
{
- if (!mmc_control)
+ if (!Config->get_mmc_control())
return;
/* record strobe does an implicit "Play" command */
void
Session::mmc_record_exit (MIDI::MachineControl &mmc)
{
- if (mmc_control) {
+ if (Config->get_mmc_control()) {
disable_record (false);
}
}
void
Session::mmc_stop (MIDI::MachineControl &mmc)
{
- if (mmc_control) {
+ if (Config->get_mmc_control()) {
request_stop ();
}
}
void
Session::mmc_pause (MIDI::MachineControl &mmc)
{
- if (mmc_control) {
+ if (Config->get_mmc_control()) {
/* We support RECORD_PAUSE, so the spec says that
we must interpret PAUSE like RECORD_PAUSE if
Session::mmc_step (MIDI::MachineControl &mmc, int steps)
{
- if (!mmc_control) {
+ if (!Config->get_mmc_control()) {
return;
}
}
double diff_secs = diff.tv_sec + (diff.tv_usec / 1000000.0);
- double cur_speed = (((steps * 0.5) * smpte_frames_per_second) / diff_secs) / smpte_frames_per_second;
+ double cur_speed = (((steps * 0.5) * Config->get_smpte_frames_per_second()) / diff_secs) / Config->get_smpte_frames_per_second();
if (_transport_speed == 0 || cur_speed * _transport_speed < 0) {
/* change direction */
void
Session::mmc_rewind (MIDI::MachineControl &mmc)
{
- if (mmc_control) {
+ if (Config->get_mmc_control()) {
request_transport_speed(-8.0f);
}
}
void
Session::mmc_fast_forward (MIDI::MachineControl &mmc)
{
- if (mmc_control) {
+ if (Config->get_mmc_control()) {
request_transport_speed(8.0f);
}
}
void
Session::mmc_locate (MIDI::MachineControl &mmc, const MIDI::byte* mmc_tc)
{
- if (!mmc_control) {
+ if (!Config->get_mmc_control()) {
return;
}
- jack_nframes_t target_frame;
+ nframes_t target_frame;
SMPTE::Time smpte;
smpte.hours = mmc_tc[0] & 0xf;
void
Session::mmc_shuttle (MIDI::MachineControl &mmc, float speed, bool forw)
{
- cerr << "MMC shuttle, speed = " << speed << endl;
-
- if (!mmc_control) {
+ if (!Config->get_mmc_control()) {
return;
}
- if (shuttle_speed_threshold >= 0 && speed > shuttle_speed_threshold) {
- speed *= shuttle_speed_factor;
+ if (Config->get_shuttle_speed_threshold() >= 0 && speed > Config->get_shuttle_speed_threshold()) {
+ speed *= Config->get_shuttle_speed_factor();
}
- cerr << "requested MMC control speed = " << speed << endl;
-
if (forw) {
request_transport_speed (speed);
} else {
void
Session::mmc_record_enable (MIDI::MachineControl &mmc, size_t trk, bool enabled)
{
- if (mmc_control) {
+ if (Config->get_mmc_control()) {
RouteList::iterator i;
- Glib::RWLock::ReaderLock guard (route_lock);
+ boost::shared_ptr<RouteList> r = routes.reader();
- for (i = routes.begin(); i != routes.end(); ++i) {
+ for (i = r->begin(); i != r->end(); ++i) {
AudioTrack *at;
- if ((at = dynamic_cast<AudioTrack*>(*i)) != 0) {
+ if ((at = dynamic_cast<AudioTrack*>((*i).get())) != 0) {
if (trk == at->remote_control_id()) {
at->set_record_enable (enabled, &mmc);
break;
void
Session::send_time_code_in_another_thread (bool full)
{
- jack_nframes_t two_smpte_frames_duration;
- jack_nframes_t quarter_frame_duration;
+ nframes_t two_smpte_frames_duration;
+ nframes_t quarter_frame_duration;
/* Duration of two smpte frames */
two_smpte_frames_duration = ((long) _frames_per_smpte_frame) << 1;
MIDI::byte msg[10];
SMPTE::Time smpte;
- if (_mtc_port == 0 || !send_mtc) {
+ if (_mtc_port == 0 || !session_send_mtc) {
return 0;
}
if (((mtc_smpte_bits >> 5) != MIDI::MTC_25_FPS) && (transmitting_smpte_time.frames % 2)) {
// start MTC quarter frame transmission on an even frame
SMPTE::increment( transmitting_smpte_time );
- outbound_mtc_smpte_frame += (jack_nframes_t) _frames_per_smpte_frame;
+ outbound_mtc_smpte_frame += (nframes_t) _frames_per_smpte_frame;
}
}
int
Session::send_midi_time_code ()
{
- if (_mtc_port == 0 || !send_mtc || transmitting_smpte_time.negative || (next_quarter_frame_to_send < 0) ) {
+ if (_mtc_port == 0 || !session_send_mtc || transmitting_smpte_time.negative || (next_quarter_frame_to_send < 0) ) {
return 0;
}
- jack_nframes_t two_smpte_frames_duration;
- jack_nframes_t quarter_frame_duration;
+ nframes_t two_smpte_frames_duration;
+ nframes_t quarter_frame_duration;
/* Duration of two smpte frames */
two_smpte_frames_duration = ((long) _frames_per_smpte_frame) << 1;
**********************************************************************/
void
-Session::send_mmc_in_another_thread (MIDI::MachineControl::Command cmd, jack_nframes_t target_frame)
+Session::send_mmc_in_another_thread (MIDI::MachineControl::Command cmd, nframes_t target_frame)
{
MIDIRequest* request;
- if (_mtc_port == 0 || !send_mmc) {
+ if (_mtc_port == 0 || !session_send_mmc) {
return;
}
}
void
-Session::deliver_mmc (MIDI::MachineControl::Command cmd, jack_nframes_t where)
+Session::deliver_mmc (MIDI::MachineControl::Command cmd, nframes_t where)
{
using namespace MIDI;
int nbytes = 4;
SMPTE::Time smpte;
- if (_mmc_port == 0 || !send_mmc) {
+ if (_mmc_port == 0 || !session_send_mmc) {
return;
}
void
Session::poke_midi_thread ()
{
- char c;
+ static char c = 0;
if (write (midi_request_pipe[1], &c, 1) != 1) {
error << string_compose(_("cannot send signal to midi thread! (%1)"), strerror (errno)) << endmsg;
on the appropriate port.
*/
- if (mmc_control && _mmc_port && _mmc_port->selectable() >= 0) {
+ if (Config->get_mmc_control() && _mmc_port && _mmc_port->selectable() >= 0) {
pfd[nfds].fd = _mmc_port->selectable();
pfd[nfds].events = POLLIN|POLLHUP|POLLERR;
ports[nfds] = _mmc_port;
the relevant port.
*/
- if (_mtc_port && (_mtc_port != _mmc_port || !mmc_control) && _mtc_port->selectable() >= 0) {
+ if (_mtc_port && (_mtc_port != _mmc_port || !Config->get_mmc_control()) && _mtc_port->selectable() >= 0) {
pfd[nfds].fd = _mtc_port->selectable();
pfd[nfds].events = POLLIN|POLLHUP|POLLERR;
ports[nfds] = _mtc_port;
nfds++;
}
- if (_midi_port && (_midi_port != _mmc_port || !mmc_control) && (_midi_port != _mtc_port) && _midi_port->selectable() >= 0) {
+ if (_midi_port && (_midi_port != _mmc_port || !Config->get_mmc_control()) && (_midi_port != _mtc_port) && _midi_port->selectable() >= 0) {
pfd[nfds].fd = _midi_port->selectable();
pfd[nfds].events = POLLIN|POLLHUP|POLLERR;
ports[nfds] = _midi_port;
}
}
-bool
-Session::get_mmc_control () const
-{
- return mmc_control;
-}
-
-bool
-Session::get_midi_control () const
-{
- return midi_control;
-}