13
0

There's always a previous tempo/meter section

This commit is contained in:
Robin Gareus 2019-08-20 04:53:00 +02:00
parent 0972e9a513
commit 3ccaaf1ea5
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -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(); const double beat = prev_m->beat() + (ts.pulse_at_minute (minute) - prev_m->pulse()) * prev_m->note_divisor();
/* audio locked meters fake their beat */ /* 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()); 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(); 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()); 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(); 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 */ /* 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(); 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; prev_t = t;
} }
} }
assert (prev_t);
/* must be treated as constant, irrespective of _type */ /* 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(); 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 = bbt.bars - prev_m->bbt().bars;
const double remaining_bars_in_beats = remaining_bars * prev_m->divisions_per_bar(); 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); 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_bars = bbt.bars - prev_m->bbt().bars;
const double remaining_pulses = remaining_bars * prev_m->divisions_per_bar() / prev_m->note_divisor(); 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()); 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(); double beat = prev_m->beat() + (ts.pulse_at_minute (minute) - prev_m->pulse()) * prev_m->note_divisor();
/* handle sample before first meter */ /* handle sample before first meter */
@ -3026,6 +3043,7 @@ TempoMap::solve_map_bbt (Metrics& imaginary, MeterSection* section, const BBT_Ti
} }
if (!section_prev) { if (!section_prev) {
assert (prev_m);
const double beats = (when.bars - prev_m->bbt().bars) * prev_m->divisions_per_bar(); 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(); const double pulse = (beats / prev_m->note_divisor()) + prev_m->pulse();