From: nick_m Date: Sun, 17 Apr 2016 19:23:06 +0000 (+1000) Subject: Tempo ramps - remove some code - should be a no-op. X-Git-Tag: 5.0-pre0~389 X-Git-Url: https://main.carlh.net/gitweb/?a=commitdiff_plain;h=5e2280eeada72923e9d3399a01742bd6ff2dca12;hp=1d7fd8d1bee959d66c84bbee2d6114a1f852347a;p=ardour.git Tempo ramps - remove some code - should be a no-op. --- diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc index a89a67b052..46761153b7 100644 --- a/libs/ardour/tempo.cc +++ b/libs/ardour/tempo.cc @@ -2082,14 +2082,8 @@ TempoMap::solve_map (Metrics& imaginary, MeterSection* section, const framepos_t MeterSection* m; if ((m = dynamic_cast (*i)) != 0) { if (m == section){ - /* - here we set the beat for this frame. - we set it 'incorrectly' to the next bar's first beat - and use the delta to find the meter's pulse. - */ double new_pulse = 0.0; - - if (section->movable()) { + if (prev_m && section->movable()) { const double beats = ((pulse_at_frame_locked (imaginary, frame) - prev_m->pulse()) * prev_m->note_divisor()); if (beats + prev_m->beat() < section->beat()) { /* disallow position change if it will alter our beat @@ -2101,7 +2095,7 @@ TempoMap::solve_map (Metrics& imaginary, MeterSection* section, const framepos_t new_pulse = ((section->beat() - prev_m->beat()) / prev_m->note_divisor()) + prev_m->pulse(); section->set_frame (frame_at_pulse_locked (imaginary, new_pulse)); section->set_pulse (new_pulse); - return; + break; } new_pulse = pulse_at_frame_locked (imaginary, frame); } else { @@ -2110,30 +2104,9 @@ TempoMap::solve_map (Metrics& imaginary, MeterSection* section, const framepos_t } section->set_frame (frame); section->set_pulse (new_pulse); - prev_m = m; - - continue; - } - if (prev_m) { - double new_pulse = 0.0; - if (m->position_lock_style() == MusicTime) { - new_pulse = prev_m->pulse() + ((m->bbt().bars - prev_m->bbt().bars) * prev_m->divisions_per_bar() / prev_m->note_divisor()); - m->set_frame (frame_at_pulse_locked (imaginary, new_pulse)); - if (m->frame() > section->frame()) { - /* moving 'section' will affect later meters' beat (but not bbt).*/ - pair new_beat (((new_pulse - prev_m->pulse()) * prev_m->note_divisor()) + prev_m->beat(), m->bbt()); - m->set_beat (new_beat); - } - } else { - if (m->movable()) { - new_pulse = pulse_at_frame_locked (imaginary, m->frame()); - } else { - pair b_bbt = make_pair (0.0, BBT_Time (1, 1, 0)); - m->set_beat (b_bbt); - } - } - m->set_pulse (new_pulse); + break; } + prev_m = m; } } @@ -2155,50 +2128,28 @@ void TempoMap::solve_map (Metrics& imaginary, MeterSection* section, const double& pulse) { MeterSection* prev_m = 0; - MeterSection* section_prev = 0; section->set_pulse (pulse); for (Metrics::iterator i = imaginary.begin(); i != imaginary.end(); ++i) { MeterSection* m; if ((m = dynamic_cast (*i)) != 0) { - if (m == section){ - section_prev = prev_m; - continue; - } - if (prev_m) { - double new_pulse = 0.0; - if (m->position_lock_style() == MusicTime) { - new_pulse = prev_m->pulse() + ((m->bbt().bars - prev_m->bbt().bars) * prev_m->divisions_per_bar() / prev_m->note_divisor()); - m->set_frame (frame_at_pulse_locked (imaginary, new_pulse)); - - if (new_pulse > section->pulse()) { - /* moving 'section' will affect later meters' beat (but not bbt).*/ - pair new_beat (((new_pulse - prev_m->pulse()) * prev_m->note_divisor()) + prev_m->beat(), m->bbt()); - m->set_beat (new_beat); - } - } else { - if (m->movable()) { - new_pulse = pulse_at_frame_locked (imaginary, m->frame()); - } else { - pair b_bbt = make_pair (0.0, BBT_Time (1, 1, 0)); - m->set_beat (b_bbt); - } - } - m->set_pulse (new_pulse); + if (prev_m && m == section){ + /* the first meter is always audio-locked, so prev_m should exist. + should we allow setting audio locked meters by pulse? + */ + const double beats = ((pulse - prev_m->pulse()) * prev_m->note_divisor()); + const int32_t bars = (beats + 1) / prev_m->divisions_per_bar(); + pair b_bbt = make_pair (beats + prev_m->beat(), BBT_Time (bars + prev_m->bbt().bars, 1, 0)); + section->set_beat (b_bbt); + section->set_frame (frame_at_pulse_locked (imaginary, pulse)); + break; } + prev_m = m; } } - if (section_prev) { - const double beats = ((pulse - section_prev->pulse()) * section_prev->note_divisor()); - const int32_t bars = (beats + 1) / section_prev->divisions_per_bar(); - pair b_bbt = make_pair (beats + section_prev->beat(), BBT_Time (bars + section_prev->bbt().bars, 1, 0)); - section->set_beat (b_bbt); - section->set_frame (frame_at_pulse_locked (imaginary, pulse)); - } - MetricSectionSorter cmp; imaginary.sort (cmp); if (section->position_lock_style() == AudioTime) {