13
0

Tempo rampo - tempo tick lines no longer assume constant tempo.

This commit is contained in:
nick_m 2016-03-28 05:21:29 +11:00
parent a7df009de7
commit 15f8f371c3
3 changed files with 23 additions and 7 deletions

View File

@ -74,8 +74,17 @@ TempoLines::draw_ticks (std::vector<ARDOUR::TempoMap::BBTPoint>& grid,
/* draw line with alpha corresponding to coarsest level */
const uint8_t a = max(8, (int)rint(UINT_RGBA_A(base) / (0.8 * log2(level))));
const uint32_t c = UINT_RGBA_CHANGE_A(base, a);
const framepos_t f = grid.begin()->frame + (l * (fpb / (double)divisions));
//const framepos_t f = frame_at_tick (last_beat_in_ticks + (l * (BBT_Time::ticks_per_beat / (double)divisions)));
framepos_t f = 0;
if (grid.begin()->c != 0.0) {
const double pulses_per_div = l * (grid.begin()->tempo.note_type() / grid.begin()->meter->note_divisor()) / divisions;
const double time_at_pulse = log (((grid.begin()->c * (pulses_per_div / grid.begin()->tempo.note_type())) /
grid.begin()->tempo.pulses_per_minute()) + 1) / grid.begin()->c;
f = grid.begin()->frame + (framecnt_t) floor ((time_at_pulse * 60.0 * frame_rate) + 0.5);
} else {
f = grid.begin()->frame + (l * (fpb / (double)divisions));
}
if (f > leftmost_frame) {
lines.add (PublicEditor::instance().sample_to_pixel_unrounded (f), 1.0, c);
}

View File

@ -307,12 +307,13 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
framepos_t frame;
const MeterSection* meter;
const Tempo tempo;
double c;
uint32_t bar;
uint32_t beat;
BBTPoint (const MeterSection& m, const Tempo& t, framepos_t f,
uint32_t b, uint32_t e)
: frame (f), meter (&m), tempo (t.beats_per_minute(), t.note_type()), bar (b), beat (e) {}
uint32_t b, uint32_t e, double func_c)
: frame (f), meter (&m), tempo (t.beats_per_minute(), t.note_type()), c (func_c), bar (b), beat (e) {}
Timecode::BBT_Time bbt() const { return Timecode::BBT_Time (bar, beat, 0); }
operator Timecode::BBT_Time() const { return bbt(); }
@ -458,6 +459,7 @@ private:
const MeterSection& meter_section_at_locked (framepos_t frame) const;
const TempoSection& tempo_section_at_locked (framepos_t frame) const;
const Tempo tempo_at_locked (const framepos_t& frame) const;
bool check_solved (Metrics& metrics, bool by_frame);
bool solve_map (Metrics& metrics, TempoSection* section, const Tempo& bpm, const framepos_t& frame);

View File

@ -940,7 +940,6 @@ TempoMap::replace_meter (const MeterSection& ms, const Meter& meter, const BBT_T
{
Glib::Threads::RWLock::WriterLock lm (lock);
MeterSection& first (first_meter());
TempoSection& first_t (first_tempo());
const PositionLockStyle pl = ms.position_lock_style();
if (ms.pulse() != first.pulse()) {
@ -965,7 +964,6 @@ TempoMap::replace_meter (const MeterSection& ms, const Meter& meter, const frame
MeterSection& first (first_meter());
TempoSection& first_t (first_tempo());
const PositionLockStyle pl = ms.position_lock_style();
if (ms.pulse() != first.pulse()) {
remove_meter_locked (ms);
add_meter_locked (meter, frame, true);
@ -1450,6 +1448,7 @@ TempoMap::recompute_tempos (Metrics& metrics)
prev_ts = t;
}
}
prev_ts->set_c_func (0.0);
}
/* tempos must be positioned correctly */
@ -2551,7 +2550,7 @@ TempoMap::get_grid (vector<TempoMap::BBTPoint>& points,
MeterSection const meter = meter_section_at_locked (pos);
BBT_Time const bbt = beats_to_bbt (cnt);
points.push_back (BBTPoint (meter, Tempo (tempo.beats_per_minute(), tempo.note_type()), pos, bbt.bars, bbt.beats));
points.push_back (BBTPoint (meter, tempo_at_locked (pos), pos, bbt.bars, bbt.beats, tempo.get_c_func()));
++cnt;
}
}
@ -2630,6 +2629,12 @@ const Tempo
TempoMap::tempo_at (const framepos_t& frame) const
{
Glib::Threads::RWLock::ReaderLock lm (lock);
return tempo_at_locked (frame);
}
const Tempo
TempoMap::tempo_at_locked (const framepos_t& frame) const
{
//frameoffset_t const frame_off = frame_offset_at (_metrics, frame);
TempoSection* prev_ts = 0;