13
0

Tempo ramps - towards having multiple audio-locked meters again.

- also speeds up meter dragging
This commit is contained in:
nick_m 2016-03-25 00:26:05 +11:00
parent e4dfd23d2e
commit 187122ce5b
2 changed files with 11 additions and 8 deletions

View File

@ -440,7 +440,7 @@ private:
double pulse_at_frame_locked (const Metrics& metrics, const framecnt_t& frame) const; double pulse_at_frame_locked (const Metrics& metrics, const framecnt_t& frame) const;
framecnt_t frame_at_pulse_locked (const Metrics& metrics, const double& beat) const; framecnt_t frame_at_pulse_locked (const Metrics& metrics, const double& beat) const;
double pulse_offset_at (const Metrics& metrics, const double& pulse) const; double beat_offset_at (const Metrics& metrics, const double& beat) const;
frameoffset_t frame_offset_at (const Metrics& metrics, const framepos_t& frame) const; frameoffset_t frame_offset_at (const Metrics& metrics, const framepos_t& frame) const;
double beat_at_frame_locked (const Metrics& metrics, const framecnt_t& frame) const; double beat_at_frame_locked (const Metrics& metrics, const framecnt_t& frame) const;

View File

@ -1834,34 +1834,35 @@ TempoMap::frame_at_pulse_locked (const Metrics& metrics, const double& pulse) co
} }
double double
TempoMap::pulse_offset_at (const Metrics& metrics, const double& pulse) const TempoMap::beat_offset_at (const Metrics& metrics, const double& beat) const
{ {
MeterSection* prev_m = 0; MeterSection* prev_m = 0;
double pulse_off = first_meter().pulse(); double beat_off = first_meter().pulse();
for (Metrics::const_iterator i = metrics.begin(); i != metrics.end(); ++i) { for (Metrics::const_iterator i = metrics.begin(); i != metrics.end(); ++i) {
MeterSection* m = 0; MeterSection* m = 0;
if ((m = dynamic_cast<MeterSection*> (*i)) != 0) { if ((m = dynamic_cast<MeterSection*> (*i)) != 0) {
if (prev_m) { if (prev_m) {
if (m->pulse() > pulse) { if (m->beat() > beat) {
break; break;
} }
if (m->position_lock_style() == AudioTime) { if (m->position_lock_style() == AudioTime) {
pulse_off += (m->pulse() - prev_m->pulse()) - floor (m->pulse() - prev_m->pulse()); beat_off += ((m->beat() - prev_m->beat()) / prev_m->note_divisor()) - floor (m->pulse() - prev_m->pulse());
} }
} }
prev_m = m; prev_m = m;
} }
} }
return pulse_off; return beat_off;
} }
frameoffset_t frameoffset_t
TempoMap::frame_offset_at (const Metrics& metrics, const framepos_t& frame) const TempoMap::frame_offset_at (const Metrics& metrics, const framepos_t& frame) const
{ {
frameoffset_t frame_off = 0; frameoffset_t frame_off = 0;
MeterSection* prev_m = 0;
for (Metrics::const_iterator i = metrics.begin(); i != metrics.end(); ++i) { for (Metrics::const_iterator i = metrics.begin(); i != metrics.end(); ++i) {
MeterSection* m = 0; MeterSection* m = 0;
@ -1869,9 +1870,11 @@ TempoMap::frame_offset_at (const Metrics& metrics, const framepos_t& frame) cons
if (m->frame() > frame) { if (m->frame() > frame) {
break; break;
} }
if (m->position_lock_style() == AudioTime) { if (prev_m && m->position_lock_style() == AudioTime) {
frame_off += frame_at_pulse_locked (metrics, m->pulse()) - m->frame(); const double pulse = prev_m->pulse() + ((m->beat() - prev_m->beat()) / prev_m->note_divisor());
frame_off += frame_at_pulse_locked (metrics, pulse) - m->frame();
} }
prev_m = m;
} }
} }