WIP - Experimenting with an alternative clock generating algo
authorMichael Fisher <mfisher31@gmail.com>
Thu, 1 Aug 2013 15:07:18 +0000 (10:07 -0500)
committerMichael Fisher <mfisher31@gmail.com>
Fri, 2 Aug 2013 13:59:32 +0000 (08:59 -0500)
    - Transport debug output (tracing where transport_frame
      is updated

libs/ardour/session_transport.cc
libs/ardour/ticker.cc

index b98a044d89aa9f6c5e8000a8e5ebf7b29f492668..51d8d2c369f57fb2131bf4c3960ba85c75412a16 100644 (file)
@@ -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 */
 }
 
index c252bc6cf78412a563422bcce1cfd9397801e967..c74f40c78eda724e3eb8b47c3b9f0fa39812c901 100644 (file)
@@ -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::JackMIDIPort*> (_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