From ba00aba51c779f2cd16dffb52808d3930c2f1eaf Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 7 Jan 2012 02:44:41 +0000 Subject: [PATCH] fix positioning of grid line after a non-beat aligned tempo change git-svn-id: svn://localhost/ardour2/branches/3.0@11182 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/tempo.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc index 1247f1e806..363930ac80 100644 --- a/libs/ardour/tempo.cc +++ b/libs/ardour/tempo.cc @@ -951,8 +951,20 @@ TempoMap::_extend_map (TempoSection* tempo, MeterSection* meter, tempo->set_frame (bar_start_frame + llrint ((ts->bar_offset() * meter->divisions_per_bar() * beat_frames))); - /* advance to the location of the new (adjusted) beat */ - current_frame += (ts->bar_offset() * beat_frames) + ((1.0 - ts->bar_offset()) * next_beat_frames); + /* advance to the location of + * the new (adjusted) beat. do + * this by figuring out the + * offset within the beat that + * would have been there + * without the tempo + * change. then stretch the + * beat accordingly. + */ + + double offset_within_old_beat = (tempo->frame() - current_frame) / beat_frames; + + current_frame += (offset_within_old_beat * beat_frames) + ((1.0 - offset_within_old_beat) * next_beat_frames); + /* next metric doesn't have to * match this precisely to * merit a reloop ...