From 3ccaaf1ea5213263c28cb20e2509cd5902a0a813 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 20 Aug 2019 04:53:00 +0200 Subject: [PATCH] There's always a previous tempo/meter section --- libs/ardour/tempo.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc index ce629df3e0..e24d21ef6b 100644 --- a/libs/ardour/tempo.cc +++ b/libs/ardour/tempo.cc @@ -1630,6 +1630,8 @@ TempoMap::beat_at_minute_locked (const Metrics& metrics, const double& minute) c } } + assert (prev_m); + const double beat = prev_m->beat() + (ts.pulse_at_minute (minute) - prev_m->pulse()) * prev_m->note_divisor(); /* audio locked meters fake their beat */ @@ -1730,6 +1732,7 @@ TempoMap::tempo_at_minute_locked (const Metrics& metrics, const double& minute) } } + assert (prev_t); return Tempo (prev_t->note_types_per_minute(), prev_t->note_type(), prev_t->end_note_types_per_minute()); } @@ -1783,6 +1786,7 @@ TempoMap::minute_at_tempo_locked (const Metrics& metrics, const Tempo& tempo) co } } + assert (prev_t); return prev_t->minute(); } @@ -1807,6 +1811,7 @@ TempoMap::tempo_at_pulse_locked (const Metrics& metrics, const double& pulse) co } } + assert (prev_t); return Tempo (prev_t->note_types_per_minute(), prev_t->note_type(), prev_t->end_note_types_per_minute()); } @@ -1844,6 +1849,7 @@ TempoMap::pulse_at_tempo_locked (const Metrics& metrics, const Tempo& tempo) con } } + assert (prev_t); return prev_t->pulse(); } @@ -1945,6 +1951,8 @@ TempoMap::pulse_at_minute_locked (const Metrics& metrics, const double& minute) } } + assert (prev_t); + /* treated as constant for this ts */ const double pulses_in_section = ((minute - prev_t->minute()) * prev_t->note_types_per_minute()) / prev_t->note_type(); @@ -1974,6 +1982,9 @@ TempoMap::minute_at_pulse_locked (const Metrics& metrics, const double& pulse) c prev_t = t; } } + + assert (prev_t); + /* must be treated as constant, irrespective of _type */ double const dtime = ((pulse - prev_t->pulse()) * prev_t->note_type()) / prev_t->note_types_per_minute(); @@ -2018,6 +2029,8 @@ TempoMap::beat_at_bbt_locked (const Metrics& metrics, const Timecode::BBT_Time& } } + assert (prev_m); + const double remaining_bars = bbt.bars - prev_m->bbt().bars; const double remaining_bars_in_beats = remaining_bars * prev_m->divisions_per_bar(); const double ret = remaining_bars_in_beats + prev_m->beat() + (bbt.beats - 1) + (bbt.ticks / BBT_Time::ticks_per_beat); @@ -2142,6 +2155,8 @@ TempoMap::pulse_at_bbt_locked (const Metrics& metrics, const Timecode::BBT_Time& } } + assert (prev_m); + const double remaining_bars = bbt.bars - prev_m->bbt().bars; const double remaining_pulses = remaining_bars * prev_m->divisions_per_bar() / prev_m->note_divisor(); const double ret = remaining_pulses + prev_m->pulse() + (((bbt.beats - 1) + (bbt.ticks / BBT_Time::ticks_per_beat)) / prev_m->note_divisor()); @@ -2296,6 +2311,8 @@ TempoMap::bbt_at_minute_locked (const Metrics& metrics, const double& minute) co } } + assert (prev_m); + double beat = prev_m->beat() + (ts.pulse_at_minute (minute) - prev_m->pulse()) * prev_m->note_divisor(); /* handle sample before first meter */ @@ -3026,6 +3043,7 @@ TempoMap::solve_map_bbt (Metrics& imaginary, MeterSection* section, const BBT_Ti } if (!section_prev) { + assert (prev_m); const double beats = (when.bars - prev_m->bbt().bars) * prev_m->divisions_per_bar(); const double pulse = (beats / prev_m->note_divisor()) + prev_m->pulse();