mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-04 20:55:48 +01:00
Improve the performance of TempoMap::frame_at_beat ().
- should be a no-op
This commit is contained in:
parent
6b0eadc62f
commit
c6f2095fb7
1 changed files with 24 additions and 3 deletions
|
|
@ -1469,12 +1469,33 @@ TempoMap::frame_at_beat (const double& beat) const
|
|||
return frame_at_beat_locked (_metrics, beat);
|
||||
}
|
||||
|
||||
/* meter section based */
|
||||
/* meter & tempo section based */
|
||||
framecnt_t
|
||||
TempoMap::frame_at_beat_locked (const Metrics& metrics, const double& beat) const
|
||||
{
|
||||
const TempoSection* prev_t = &tempo_section_at_beat_locked (metrics, beat);
|
||||
const MeterSection* prev_m = &meter_section_at_beat_locked (metrics, beat);
|
||||
MeterSection* prev_m = 0;
|
||||
TempoSection* prev_t = 0;
|
||||
|
||||
for (Metrics::const_iterator i = metrics.begin(); i != metrics.end(); ++i) {
|
||||
MeterSection* m;
|
||||
if ((m = dynamic_cast<MeterSection*> (*i)) != 0) {
|
||||
if (prev_m && m->beat() > beat) {
|
||||
break;
|
||||
}
|
||||
prev_m = m;
|
||||
}
|
||||
}
|
||||
|
||||
for (Metrics::const_iterator i = metrics.begin(); i != metrics.end(); ++i) {
|
||||
TempoSection* t;
|
||||
if ((t = dynamic_cast<TempoSection*> (*i)) != 0) {
|
||||
if (prev_t && ((t->pulse() - prev_m->pulse()) * prev_m->note_divisor()) + prev_m->beat() > beat) {
|
||||
break;
|
||||
}
|
||||
prev_t = t;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return prev_t->frame_at_pulse (((beat - prev_m->beat()) / prev_m->note_divisor()) + prev_m->pulse(), _frame_rate);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue