diff options
author | nick_m <mainsbridge@gmail.com> | 2017-07-18 03:10:07 +1000 |
---|---|---|
committer | nick_m <mainsbridge@gmail.com> | 2017-07-22 02:15:20 +1000 |
commit | 1c51435fa35e6a5a60076b3226beac1dc8172cb1 (patch) | |
tree | c38f9e5dbaa51b4d6233369d1d85c2e3168d37ea /libs/ardour | |
parent | 90547112e250cea1e14736adfda4d78b0b50baec (diff) |
Calculate clamped tempo stretch ratios using the correct (musical) domain
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/ardour/tempo.h | 2 | ||||
-rw-r--r-- | libs/ardour/tempo.cc | 12 |
2 files changed, 7 insertions, 7 deletions
diff --git a/libs/ardour/ardour/tempo.h b/libs/ardour/ardour/tempo.h index 5ab84cc3ce..5e62f3432d 100644 --- a/libs/ardour/ardour/tempo.h +++ b/libs/ardour/ardour/tempo.h @@ -513,7 +513,7 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible void gui_set_tempo_position (TempoSection*, const framepos_t& frame, const int& sub_num); void gui_set_meter_position (MeterSection*, const framepos_t& frame); bool gui_change_tempo (TempoSection*, const Tempo& bpm); - void gui_stretch_tempo (TempoSection* tempo, const framepos_t frame, const framepos_t end_frame); + void gui_stretch_tempo (TempoSection* tempo, const framepos_t frame, const framepos_t end_frame, const double start_qnote, const double end_qnote); void gui_stretch_tempo_end (TempoSection* tempo, const framepos_t frame, const framepos_t end_frame); bool gui_twist_tempi (TempoSection* first, const Tempo& bpm, const framepos_t frame, const framepos_t end_frame); 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(); } |