Skip to content

9897 - fix ticker.cc loop range end wrap #966

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion libs/ardour/ticker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ MidiClockTicker::tick (samplepos_t start_sample, samplepos_t end_sample, pframes

double speed = (end_sample - start_sample) / (double)n_samples;

Location* loop = _session.locations()->auto_loop_location();
bool is_loop_wrap = loop && end_sample < start_sample;
if (is_loop_wrap) {
samplecnt_t loop_end_length = loop->end_sample() - start_sample;
samplecnt_t loop_start_length = end_sample - loop->start_sample();
speed = (loop_end_length + loop_start_length) / (double)n_samples;
}

if (!Config->get_send_midi_clock () /*|| !TransportMasterManager::instance().current()*/) {
if (_rolling) {
send_stop_event (0, n_samples);
Expand Down Expand Up @@ -197,7 +205,8 @@ MidiClockTicker::tick (samplepos_t start_sample, samplepos_t end_sample, pframes

assert (_rolling);

while (_next_tick >= start_sample && _next_tick < end_sample) {
while ((_next_tick >= start_sample && _next_tick < end_sample)
|| (is_loop_wrap && (_next_tick >= start_sample || _next_tick < end_sample))) {
DEBUG_TRACE (DEBUG::MidiClock, string_compose ("Tick @ %1 cycle: %2 .. %3 nsamples: %4, ticker-pos: %5\n",
_next_tick, start_sample, end_sample, n_samples, _transport_pos));
send_midi_clock_event (_next_tick - start_sample, n_samples);
Expand All @@ -206,6 +215,13 @@ MidiClockTicker::tick (samplepos_t start_sample, samplepos_t end_sample, pframes
++_beat_pos;
}
_next_tick += one_ppqn_in_samples (llrint (_next_tick));

if (is_loop_wrap) {
samplecnt_t loop_end_delta = _next_tick - loop->end_sample();
if (loop_end_delta >= 0) {
_next_tick = loop->start_sample() + loop_end_delta;
}
}
}

_transport_pos = end_sample;
Expand Down