From 38b5d887950e72a65341d616bf40195657228271 Mon Sep 17 00:00:00 2001 From: nick_m Date: Wed, 1 Mar 2017 01:58:53 +1100 Subject: allow continuation of tempo via right-click 'Continue' where appropriate. - this is the opposite of 'Ramp to Next'. it removes discontinuities between the last end tempo and the current by altering the current one. --- libs/ardour/ardour/tempo.h | 1 + libs/ardour/tempo.cc | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) (limited to 'libs') diff --git a/libs/ardour/ardour/tempo.h b/libs/ardour/ardour/tempo.h index 1426801f24..b1c2dc6428 100644 --- a/libs/ardour/ardour/tempo.h +++ b/libs/ardour/ardour/tempo.h @@ -367,6 +367,7 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible const MeterSection& meter_section_at_frame (framepos_t frame) const; const MeterSection& meter_section_at_beat (double beat) const; + TempoSection* previous_tempo_section (TempoSection*) const; TempoSection* next_tempo_section (TempoSection*) const; /** add a tempo section locked to pls. ignored values will be set in recompute_tempi() diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc index 345d09b8bf..e11d28bd98 100644 --- a/libs/ardour/tempo.cc +++ b/libs/ardour/tempo.cc @@ -4285,6 +4285,43 @@ TempoMap::tempo_section_at_beat_locked (const Metrics& metrics, const double& be return *prev_t; } +TempoSection* +TempoMap::previous_tempo_section (TempoSection* ts) const +{ + if (!ts) { + return 0; + } + + Glib::Threads::RWLock::ReaderLock lm (lock); + + TempoSection* prev = 0; + + for (Metrics::const_iterator i = _metrics.begin(); i != _metrics.end(); ++i) { + + if ((*i)->is_tempo()) { + TempoSection* t = static_cast (*i); + + if (!t->active()) { + continue; + } + + if (prev && t == ts) { + + return prev; + } + + prev = t; + } + } + + if (prev == 0) { + fatal << endmsg; + abort(); /*NOTREACHED*/ + } + + return 0; +} + TempoSection* TempoMap::next_tempo_section (TempoSection* ts) const { -- cgit v1.2.3