summaryrefslogtreecommitdiff
path: root/libs/ardour/tempo.cc
diff options
context:
space:
mode:
authornick_m <mainsbridge@gmail.com>2017-07-18 03:10:07 +1000
committernick_m <mainsbridge@gmail.com>2017-07-22 02:15:20 +1000
commit1c51435fa35e6a5a60076b3226beac1dc8172cb1 (patch)
treec38f9e5dbaa51b4d6233369d1d85c2e3168d37ea /libs/ardour/tempo.cc
parent90547112e250cea1e14736adfda4d78b0b50baec (diff)
Calculate clamped tempo stretch ratios using the correct (musical) domain
Diffstat (limited to 'libs/ardour/tempo.cc')
-rw-r--r--libs/ardour/tempo.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc
index d1275dc98c..e1b6842649 100644
--- a/libs/ardour/tempo.cc
+++ b/libs/ardour/tempo.cc
@@ -3351,7 +3351,7 @@ TempoMap::gui_change_tempo (TempoSection* ts, const Tempo& bpm)
}
void
-TempoMap::gui_stretch_tempo (TempoSection* ts, const framepos_t frame, const framepos_t end_frame)
+TempoMap::gui_stretch_tempo (TempoSection* ts, const framepos_t frame, const framepos_t end_frame, const double start_qnote, const double end_qnote)
{
/*
Ts (future prev_t) Tnext
@@ -3388,14 +3388,14 @@ TempoMap::gui_stretch_tempo (TempoSection* ts, const framepos_t frame, const fra
*/
double contribution = 0.0;
if (next_t && prev_to_prev_t && prev_to_prev_t->type() == TempoSection::Ramp) {
- contribution = (prev_t->frame() - prev_to_prev_t->frame()) / (double) (next_t->frame() - prev_to_prev_t->frame());
+ contribution = (prev_t->pulse() - prev_to_prev_t->pulse()) / (double) (next_t->pulse() - prev_to_prev_t->pulse());
}
- framepos_t const fr_off = (end_frame - frame);
- const frameoffset_t prev_t_frame_contribution = fr_off - (contribution * (double) fr_off);
+ framepos_t const fr_off = end_frame - frame;
+ frameoffset_t const prev_t_frame_contribution = fr_off - (contribution * (double) fr_off);
if (frame > prev_to_prev_t->frame() + min_dframe && (frame + prev_t_frame_contribution) > prev_to_prev_t->frame() + min_dframe) {
- new_bpm = prev_t->note_types_per_minute() * ((frame - prev_to_prev_t->frame())
- / (double) ((frame + prev_t_frame_contribution) - prev_to_prev_t->frame()));
+ new_bpm = prev_t->note_types_per_minute() * ((start_qnote - (prev_to_prev_t->pulse() * 4.0))
+ / (end_qnote - (prev_to_prev_t->pulse() * 4.0)));
} else {
new_bpm = prev_t->note_types_per_minute();
}