From: Michael Fisher Date: Thu, 1 Aug 2013 15:07:18 +0000 (-0500) Subject: WIP - Experimenting with an alternative clock generating algo X-Git-Tag: 3.4~65 X-Git-Url: https://main.carlh.net/gitweb/?p=ardour.git;a=commitdiff_plain;h=18490878b402d3f86b48c3f4e3c45c7fdeb1c9a3 WIP - Experimenting with an alternative clock generating algo - Transport debug output (tracing where transport_frame is updated --- diff --git a/libs/ardour/session_transport.cc b/libs/ardour/session_transport.cc index b98a044d89..51d8d2c369 100644 --- a/libs/ardour/session_transport.cc +++ b/libs/ardour/session_transport.cc @@ -384,6 +384,7 @@ Session::butler_transport_work () g_atomic_int_dec_and_test (&_butler->should_do_transport_work); DEBUG_TRACE (DEBUG::Transport, X_("Butler transport work all done\n")); + DEBUG_TRACE (DEBUG::Transport, X_(string_compose ("Frame %1\n", _transport_frame))); } void @@ -1007,6 +1008,7 @@ Session::locate (framepos_t target_frame, bool with_roll, bool with_flush, bool send_mmc_locate (_transport_frame); } + _last_roll_location = _last_roll_or_reversal_location = _transport_frame; Located (); /* EMIT SIGNAL */ } diff --git a/libs/ardour/ticker.cc b/libs/ardour/ticker.cc index c252bc6cf7..c74f40c78e 100644 --- a/libs/ardour/ticker.cc +++ b/libs/ardour/ticker.cc @@ -126,6 +126,8 @@ MidiClockTicker::set_session (Session* s) } } +static bool need_reset = false; + void MidiClockTicker::session_located() { @@ -136,6 +138,7 @@ MidiClockTicker::session_located() } _last_tick = _pos->frame; + need_reset = true; if (_pos->speed == 0.0f && Config->get_send_midi_clock()) { uint32_t where = std::floor (_pos->midi_beats); @@ -253,34 +256,37 @@ MidiClockTicker::transport_looped() void MidiClockTicker::tick (const framepos_t& transport_frame) { - if (!Config->get_send_midi_clock() || _session == 0 || _session->transport_speed() != 1.0f || _midi_port == 0) { return; } + double iter = _last_tick; + double clock_delta = one_ppqn_in_frames (transport_frame); + while (true) { - double next_tick = _last_tick + one_ppqn_in_frames (transport_frame); + double next_tick = iter + clock_delta; frameoffset_t next_tick_offset = llrint (next_tick) - transport_frame; - MIDI::JackMIDIPort* mp = dynamic_cast (_midi_port); - DEBUG_TRACE (PBD::DEBUG::MidiClock, string_compose ("Transport: %1, last tick time: %2, next tick time: %3, offset: %4, cycle length: %5\n", transport_frame, _last_tick, next_tick, next_tick_offset, mp ? mp->nframes_this_cycle() : 0)); if (!mp || (next_tick_offset >= mp->nframes_this_cycle())) { - break; + return; } if (next_tick_offset >= 0) { send_midi_clock_event (next_tick_offset); + _last_tick += clock_delta; } - _pos->frame = _last_tick = next_tick; + iter = next_tick; } + + _pos->frame = _last_tick; } double