diff options
author | nick_m <mainsbridge@gmail.com> | 2017-02-27 02:21:05 +1100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2017-02-27 20:16:10 +0100 |
commit | d06e7104026140f5921f03d640afec80f84f1e7d (patch) | |
tree | 463bdf24b661c90b032e17985c5ef49b57849cf2 /libs/ardour/tempo.cc | |
parent | 393f095d95ab1bf6a22fe8953e733e2d67f355bd (diff) |
add TempoMap::next_tempo_section()
Diffstat (limited to 'libs/ardour/tempo.cc')
-rw-r--r-- | libs/ardour/tempo.cc | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc index dbc0457f8a..c3ae1533dc 100644 --- a/libs/ardour/tempo.cc +++ b/libs/ardour/tempo.cc @@ -1816,9 +1816,9 @@ TempoMap::minute_at_tempo_locked (const Metrics& metrics, const Tempo& tempo) co if (prev_t) { const double prev_t_bpm = prev_t->note_types_per_minute(); const double prev_t_end_bpm = prev_t->end_note_types_per_minute(); - if (prev_t_bpm > tempo_bpm && prev_t_end_bpm < tempo_bpm - || prev_t_bpm < tempo_bpm && prev_t_end_bpm > tempo_bpm - || prev_t_end_bpm == tempo_bpm) { + if ((prev_t_bpm > tempo_bpm && prev_t_end_bpm < tempo_bpm) + || (prev_t_bpm < tempo_bpm && prev_t_end_bpm > tempo_bpm) + || (prev_t_end_bpm == tempo_bpm)) { return prev_t->minute_at_ntpm (tempo_bpm, t->pulse()); } @@ -4274,6 +4274,38 @@ TempoMap::tempo_section_at_beat_locked (const Metrics& metrics, const double& be return *prev_t; } +TempoSection* +TempoMap::next_tempo_section (TempoSection* ts) const +{ + 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<TempoSection*> (*i); + + if (!t->active()) { + continue; + } + + if (prev && prev == ts) { + + return t; + } + + prev = t; + } + } + + if (prev == 0) { + fatal << endmsg; + abort(); /*NOTREACHED*/ + } + + return 0; +} /* don't use this to calculate length (the tempo is only correct for this frame). do that stuff based on the beat_at_frame and frame_at_beat api */ |