From d795980546156b5094a23b465f68c9c9472818b7 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 3 Jan 2011 23:55:00 +0000 Subject: Stop QF messages when transport speed is out of range, and re-start them properly. git-svn-id: svn://localhost/ardour2/branches/3.0@8423 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/rc_configuration_vars.h | 1 + libs/ardour/ardour/session.h | 2 +- libs/ardour/session_midi.cc | 5 ++--- libs/ardour/session_process.cc | 24 +++++++++++++++++++++--- libs/ardour/session_state.cc | 5 ++--- 5 files changed, 27 insertions(+), 10 deletions(-) (limited to 'libs/ardour') diff --git a/libs/ardour/ardour/rc_configuration_vars.h b/libs/ardour/ardour/rc_configuration_vars.h index f8bdab0a82..1c57c2d59b 100644 --- a/libs/ardour/ardour/rc_configuration_vars.h +++ b/libs/ardour/ardour/rc_configuration_vars.h @@ -35,6 +35,7 @@ CONFIG_VARIABLE (bool, midi_feedback, "midi-feedback", false) CONFIG_VARIABLE (uint8_t, mmc_receive_device_id, "mmc-receive-device-id", 0x7f) CONFIG_VARIABLE (uint8_t, mmc_send_device_id, "mmc-send-device-id", 0) CONFIG_VARIABLE (int32_t, initial_program_change, "initial-program-change", -1) +CONFIG_VARIABLE (int, mtc_qf_speed_tolerance, "mtc_qf_speed_tolerance", 5) /* control surfaces */ diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index f18436837f..38ee8688f0 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -959,7 +959,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi std::string _path; std::string _name; bool _is_new; - bool session_send_mtc; + bool _send_qf_mtc; bool session_midi_feedback; bool play_loop; bool loop_changing; diff --git a/libs/ardour/session_midi.cc b/libs/ardour/session_midi.cc index 31e4e9ca47..f09722f31c 100644 --- a/libs/ardour/session_midi.cc +++ b/libs/ardour/session_midi.cc @@ -360,7 +360,7 @@ Session::send_full_time_code (framepos_t const t) _send_timecode_update = false; - if (!session_send_mtc || _slave) { + if (!Config->get_send_mtc() || _slave) { return 0; } @@ -413,7 +413,7 @@ Session::send_full_time_code (framepos_t const t) int Session::send_midi_time_code_for_cycle (framepos_t start_frame, framepos_t end_frame, pframes_t nframes) { - if (_slave || !session_send_mtc || transmitting_timecode_time.negative || (next_quarter_frame_to_send < 0)) { + if (_slave || !_send_qf_mtc || transmitting_timecode_time.negative || (next_quarter_frame_to_send < 0)) { // cerr << "(MTC) Not sending MTC\n"; return 0; } @@ -462,7 +462,6 @@ Session::send_midi_time_code_for_cycle (framepos_t start_frame, framepos_t end_f } const framepos_t msg_time = outbound_mtc_timecode_frame + (quarter_frame_duration * next_quarter_frame_to_send); - cout << " " << msg_time << "\n"; // This message must fall within this block or something is broken assert (msg_time >= start_frame); diff --git a/libs/ardour/session_process.cc b/libs/ardour/session_process.cc index 65930ca2aa..d67744dbe7 100644 --- a/libs/ardour/session_process.cc +++ b/libs/ardour/session_process.cc @@ -265,9 +265,27 @@ Session::process_with_events (pframes_t nframes) process_event (ev); } - /* Events caused a transport change, send an MTC Full Frame (Timecode) message. - * This is sent whether rolling or not, to give slaves an idea of ardour time - * on locates (and allow slow slaves to position and prepare for rolling) + /* Decide on what to do with quarter-frame MTC during this cycle */ + + bool const was_sending_qf_mtc = _send_qf_mtc; + double const tolerance = Config->get_mtc_qf_speed_tolerance() / 100.0; + + _send_qf_mtc = ( + Config->get_send_mtc () && + _transport_speed >= (1 - tolerance) && + _transport_speed <= (1 + tolerance) + ); + + if (_send_qf_mtc && !was_sending_qf_mtc) { + /* we will re-start quarter-frame MTC this cycle, so send a full update to set things up */ + _send_timecode_update = true; + } + + /* Events caused a transport change (or we re-started sending + * MTC), so send an MTC Full Frame (Timecode) message. This + * is sent whether rolling or not, to give slaves an idea of + * ardour time on locates (and allow slow slaves to position + * and prepare for rolling) */ if (_send_timecode_update) { send_full_time_code (_transport_frame); diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 115d451023..ed94e20c2a 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -206,7 +206,7 @@ Session::first_stage_init (string fullpath, string snapshot_name) _state_of_the_state = StateOfTheState(CannotSave|InitialConnecting|Loading); _was_seamless = Config->get_seamless_loop (); _slave = 0; - session_send_mtc = false; + _send_qf_mtc = false; g_atomic_int_set (&_playback_load, 100); g_atomic_int_set (&_capture_load, 100); _play_range = false; @@ -3358,8 +3358,7 @@ Session::config_changed (std::string p, bool ours) } else if (p == "send-mtc") { - session_send_mtc = Config->get_send_mtc(); - if (session_send_mtc) { + if (Config->get_send_mtc ()) { /* mark us ready to send */ next_quarter_frame_to_send = 0; } -- cgit v1.2.3