mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-09 00:04:56 +01:00
fix initial filling out of tempo bars|beats map after loading from XML by extending it (at least) to the last tempo/meter metric
git-svn-id: svn://localhost/ardour2/branches/3.0@11255 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
7fcfe672c4
commit
4b95a7912a
1 changed files with 36 additions and 10 deletions
|
|
@ -750,12 +750,11 @@ TempoMap::recompute_map (bool reassign_tempo_bbt, framepos_t end)
|
||||||
|
|
||||||
if (end < 0) {
|
if (end < 0) {
|
||||||
|
|
||||||
if (_map.empty()) {
|
/* we will actually stop once we hit
|
||||||
/* compute 1 mins worth */
|
the last metric.
|
||||||
end = _frame_rate * 60;
|
*/
|
||||||
} else {
|
end = max_framepos;
|
||||||
end = _map.back().frame;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (!_map.empty ()) {
|
if (!_map.empty ()) {
|
||||||
/* never allow the map to be shortened */
|
/* never allow the map to be shortened */
|
||||||
|
|
@ -896,6 +895,8 @@ TempoMap::_extend_map (TempoSection* tempo, MeterSection* meter,
|
||||||
double beat_frames;
|
double beat_frames;
|
||||||
framepos_t bar_start_frame;
|
framepos_t bar_start_frame;
|
||||||
|
|
||||||
|
DEBUG_TRACE (DEBUG::TempoMath, string_compose ("Extend map to %1 from %2 = %3\n", end, current, current_frame));
|
||||||
|
|
||||||
if (current.beats == 1) {
|
if (current.beats == 1) {
|
||||||
bar_start_frame = current_frame;
|
bar_start_frame = current_frame;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1027,6 +1028,15 @@ TempoMap::_extend_map (TempoSection* tempo, MeterSection* meter,
|
||||||
DEBUG_TRACE (DEBUG::TempoMath, string_compose ("Add Beat at %1|%2 @ %3\n", current.bars, current.beats, current_frame));
|
DEBUG_TRACE (DEBUG::TempoMath, string_compose ("Add Beat at %1|%2 @ %3\n", current.bars, current.beats, current_frame));
|
||||||
_map.push_back (BBTPoint (*meter, *tempo, (framepos_t) llrint(current_frame), current.bars, current.beats));
|
_map.push_back (BBTPoint (*meter, *tempo, (framepos_t) llrint(current_frame), current.bars, current.beats));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (next_metric == metrics.end()) {
|
||||||
|
/* no more metrics - we've timestamped them all, stop here */
|
||||||
|
if (end == max_framepos) {
|
||||||
|
DEBUG_TRACE (DEBUG::TempoMath, string_compose ("stop extending map now that we've reach the end @ %1|%2 = %3\n",
|
||||||
|
current.bars, current.beats, current_frame));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1596,7 +1606,6 @@ TempoMap::set_state (const XMLNode& node, int /*version*/)
|
||||||
XMLNodeConstIterator niter;
|
XMLNodeConstIterator niter;
|
||||||
Metrics old_metrics (metrics);
|
Metrics old_metrics (metrics);
|
||||||
MeterSection* last_meter = 0;
|
MeterSection* last_meter = 0;
|
||||||
|
|
||||||
metrics.clear();
|
metrics.clear();
|
||||||
|
|
||||||
nlist = node.children();
|
nlist = node.children();
|
||||||
|
|
@ -1644,7 +1653,7 @@ TempoMap::set_state (const XMLNode& node, int /*version*/)
|
||||||
metrics.sort (cmp);
|
metrics.sort (cmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
recompute_map (true);
|
recompute_map (true, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyChanged (PropertyChange ());
|
PropertyChanged (PropertyChange ());
|
||||||
|
|
@ -2166,6 +2175,9 @@ TempoMap::framewalk_to_beats (framepos_t pos, framecnt_t distance) const
|
||||||
|
|
||||||
assert (tempo);
|
assert (tempo);
|
||||||
|
|
||||||
|
DEBUG_TRACE (DEBUG::TempoMath, string_compose ("frame %1 walk by %2 frames, start with tempo = %3 @ %4\n",
|
||||||
|
pos, distance, *((Tempo*)tempo), tempo->frame()));
|
||||||
|
|
||||||
Evoral::MusicalTime beats = 0;
|
Evoral::MusicalTime beats = 0;
|
||||||
|
|
||||||
while (distance) {
|
while (distance) {
|
||||||
|
|
@ -2179,12 +2191,18 @@ TempoMap::framewalk_to_beats (framepos_t pos, framecnt_t distance) const
|
||||||
/* Amount to subtract this time */
|
/* Amount to subtract this time */
|
||||||
double const sub = min (distance, distance_to_end);
|
double const sub = min (distance, distance_to_end);
|
||||||
|
|
||||||
|
DEBUG_TRACE (DEBUG::TempoMath, string_compose ("to reach end at %1 (end ? %2), distance= %3 sub=%4\n", end, (next_tempo == metrics.end()),
|
||||||
|
distance_to_end, sub));
|
||||||
|
|
||||||
/* Update */
|
/* Update */
|
||||||
pos += sub;
|
pos += sub;
|
||||||
distance -= sub;
|
distance -= sub;
|
||||||
assert (tempo);
|
assert (tempo);
|
||||||
beats += sub / tempo->frames_per_beat (_frame_rate);
|
beats += sub / tempo->frames_per_beat (_frame_rate);
|
||||||
|
|
||||||
|
DEBUG_TRACE (DEBUG::TempoMath, string_compose ("now at %1, beats = %2 distance left %3\n",
|
||||||
|
pos, beats, distance));
|
||||||
|
|
||||||
/* Move on if there's anything to move to */
|
/* Move on if there's anything to move to */
|
||||||
|
|
||||||
if (next_tempo != metrics.end()) {
|
if (next_tempo != metrics.end()) {
|
||||||
|
|
@ -2203,6 +2221,14 @@ TempoMap::framewalk_to_beats (framepos_t pos, framecnt_t distance) const
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (next_tempo == metrics.end()) {
|
||||||
|
DEBUG_TRACE (DEBUG::TempoMath, "no more tempo sections\n");
|
||||||
|
} else {
|
||||||
|
DEBUG_TRACE (DEBUG::TempoMath, string_compose ("next tempo section is %1 @ %2\n",
|
||||||
|
**next_tempo, (*next_tempo)->frame()));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
assert (tempo);
|
assert (tempo);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue