summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2011-11-24 00:40:45 +0000
committerCarl Hetherington <carl@carlh.net>2011-11-24 00:40:45 +0000
commit5aec659c606861f88068782257966fd91726254b (patch)
treea8a96c0943c8f6e198081a7c03502b9d21e7cac1 /libs
parent5c8abd8293af875ba9c2835e00b1af63dc24a76d (diff)
If a tempo change is inserted some way through a bar, fix up the time signature of the previous bar so that the tempo map remains consistent. Should help with #4200.
git-svn-id: svn://localhost/ardour2/branches/3.0@10816 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/tempo.cc38
1 files changed, 36 insertions, 2 deletions
diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc
index 579b523fa0..6dd92aa119 100644
--- a/libs/ardour/tempo.cc
+++ b/libs/ardour/tempo.cc
@@ -368,6 +368,42 @@ TempoMap::remove_meter (const MeterSection& tempo)
void
TempoMap::do_insert (MetricSection* section, bool with_bbt)
{
+ /* First of all, check to see if the new MetricSection is in the
+ middle of a bar. If so, we need to fix the bar that we are in
+ to have a different meter.
+ */
+
+ assert (section->start().ticks == 0);
+
+ if (section->start().beats != 1) {
+
+ /* Here's the tempo and metric where we are proposing to insert `section' */
+ TempoMetric tm = metric_at (section->start ());
+
+ /* This is where we will put the `corrective' new meter; at the start of
+ the bar that we are inserting into the middle of.
+ */
+ BBT_Time where_correction = section->start();
+ where_correction.beats = 1;
+ where_correction.ticks = 0;
+
+ /* Put in the meter change to make the bar before our `section' the right
+ length.
+ */
+ do_insert (new MeterSection (where_correction, section->start().beats, tm.meter().note_divisor ()), true);
+
+ /* This is where the new stuff will now go; the start of the next bar
+ (after the one whose meter we just fixed).
+ */
+ BBT_Time where_new (where_correction.bars + 1, 1, 0);
+
+ /* Change back to the original meter */
+ do_insert (new MeterSection (where_new, tm.meter().beats_per_bar(), tm.meter().note_divisor()), true);
+
+ /* And set up `section' for where it should be, ready to be inserted */
+ section->set_start (where_new);
+ }
+
Metrics::iterator i;
/* Look for any existing MetricSection that is of the same type and
@@ -831,8 +867,6 @@ TempoMap::bbt_time_with_metric (framepos_t frame, BBT_Time& bbt, const TempoMetr
{
framecnt_t frame_diff;
- // cerr << "---- BBT time for " << frame << " using metric @ " << metric.frame() << " BBT " << metric.start() << endl;
-
const double beats_per_bar = metric.meter().beats_per_bar();
const double ticks_per_frame = metric.tempo().frames_per_beat (_frame_rate, metric.meter()) / BBT_Time::ticks_per_beat;