diff options
author | nick_m <mainsbridge@gmail.com> | 2016-04-17 06:48:49 +1000 |
---|---|---|
committer | nick_m <mainsbridge@gmail.com> | 2016-05-27 23:38:15 +1000 |
commit | 7b9eec567801c36198b7c10cf9be7fd9a162861e (patch) | |
tree | 46ff704215b58857d5b0c001fac6c20d39815f14 /libs | |
parent | 8b0a2897b97b2ff61fa5ba5ce112d015645a000b (diff) |
Tempo ramps - fix mucally-snapped dragging across the 'no time' gap (audio-locked meters).
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/tempo.cc | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc index 22e8eaf809..a21ec43aee 100644 --- a/libs/ardour/tempo.cc +++ b/libs/ardour/tempo.cc @@ -1540,12 +1540,30 @@ TempoMap::frame_at_pulse (const double& pulse) const double TempoMap::beat_at_frame_locked (const Metrics& metrics, const framecnt_t& frame) const { - const MeterSection& prev_m = meter_section_at_locked (metrics, frame); const TempoSection& ts = tempo_section_at_locked (metrics, frame); - if (frame < prev_m.frame()) { + MeterSection* prev_m = 0; + MeterSection* next_m = 0; + + for (Metrics::const_iterator i = metrics.begin(); i != metrics.end(); ++i) { + MeterSection* m; + if ((m = dynamic_cast<MeterSection*> (*i)) != 0) { + if (prev_m && m->frame() > frame) { + next_m = m; + break; + } + prev_m = m; + } + } + if (frame < prev_m->frame()) { return 0.0; } - return prev_m.beat() + (ts.pulse_at_frame (frame, _frame_rate) - prev_m.pulse()) * prev_m.note_divisor(); + const double beat = prev_m->beat() + (ts.pulse_at_frame (frame, _frame_rate) - prev_m->pulse()) * prev_m->note_divisor(); + + if (next_m && next_m->beat() < beat) { + return next_m->beat(); + } + + return beat; } double |