fix positioning of grid line after a non-beat aligned tempo change
authorPaul Davis <paul@linuxaudiosystems.com>
Sat, 7 Jan 2012 02:44:41 +0000 (02:44 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Sat, 7 Jan 2012 02:44:41 +0000 (02:44 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@11182 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/tempo.cc

index 1247f1e806ee4fe20fa12652636ce3a053354655..363930ac8078c70faca0228aad5952136a7591c5 100644 (file)
@@ -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 ...