From 4273093d4021f7de8b8a5c769200091ba03240b4 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 4 Jan 2011 03:35:10 +0000 Subject: [PATCH] Send full MTC messages every 1/4 of a second when quarter-frame messages are suspended (due to out-of-range transport speed) git-svn-id: svn://localhost/ardour2/branches/3.0@8429 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/session.h | 4 ++++ libs/ardour/session_midi.cc | 1 + libs/ardour/session_process.cc | 32 ++++++++++++++++++++++---------- libs/ardour/session_state.cc | 1 + 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 38ee8688f0..a056c7a2f2 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -960,6 +960,10 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi std::string _name; bool _is_new; bool _send_qf_mtc; + /** Number of process frames since the last MTC output (when sending MTC); used to + * know when to send full MTC messages every so often. + */ + pframes_t _pframes_since_last_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 f09722f31c..f4aef76adc 100644 --- a/libs/ardour/session_midi.cc +++ b/libs/ardour/session_midi.cc @@ -400,6 +400,7 @@ Session::send_full_time_code (framepos_t const t) return -1; } + _pframes_since_last_mtc = 0; return 0; } diff --git a/libs/ardour/session_process.cc b/libs/ardour/session_process.cc index d67744dbe7..9902e5a1e3 100644 --- a/libs/ardour/session_process.cc +++ b/libs/ardour/session_process.cc @@ -270,17 +270,29 @@ Session::process_with_events (pframes_t nframes) 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; + if (_transport_speed != 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; + } + + if (Config->get_send_mtc() && !_send_qf_mtc && _pframes_since_last_mtc > (frame_rate () / 4)) { + /* we're sending MTC, but we're not sending QF MTC at the moment, and it's been + a quarter of a second since we sent anything at all, so send a full MTC update + this cycle. + */ + _send_timecode_update = true; + } + + _pframes_since_last_mtc += nframes; } - + /* 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 diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index ed94e20c2a..cd9cb7b9b2 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -207,6 +207,7 @@ Session::first_stage_init (string fullpath, string snapshot_name) _was_seamless = Config->get_seamless_loop (); _slave = 0; _send_qf_mtc = false; + _pframes_since_last_mtc = 0; g_atomic_int_set (&_playback_load, 100); g_atomic_int_set (&_capture_load, 100); _play_range = false;