diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index aed5cdc5e7..f9ea36104a 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -2134,7 +2134,7 @@ private: static void* timefx_thread (void* arg); void do_timefx (); - int time_stretch (RegionSelection&, float fraction); + int time_stretch (RegionSelection&, Temporal::ratio_t const & fraction); int pitch_shift (RegionSelection&, float cents); void pitch_shift_region (); diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 83c028c59d..f949f3841a 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -5543,7 +5543,7 @@ TimeFXDrag::finished (GdkEvent* event, bool movement_occurred) parameters for the timestretch. */ - ratio_t fraction (1, 1); + ratio_t ratio (1, 1); if (movement_occurred) { @@ -5560,12 +5560,17 @@ TimeFXDrag::finished (GdkEvent* event, bool movement_occurred) timecnt_t newlen = _primary->region()->position().distance (adjusted_pos); - fraction = newlen / _primary->region()->length(); + if (_primary->region()->length().time_domain() == Temporal::BeatTime) { + ratio = ratio_t (newlen.ticks(), _primary->region()->length().ticks()); + } else { + ratio = ratio_t (newlen.samples(), _primary->region()->length().samples()); + } #ifndef USE_RUBBERBAND // Soundtouch uses fraction / 100 instead of normal (/ 1) +#warning NUTEMPO timefx request now uses a rational type so this needs revisiting if (_primary->region()->data_type() == DataType::AUDIO) { - fraction = ((newlen - _primary->region()->length()) / newlen) * 100; + ratio = ((newlen - _primary->region()->length()) / newlen) * 100; } #endif } @@ -5577,7 +5582,7 @@ TimeFXDrag::finished (GdkEvent* event, bool movement_occurred) selection. */ - if (_editor->time_stretch (_editor->get_selection().regions, fraction) == -1) { + if (_editor->time_stretch (_editor->get_selection().regions, ratio) == -1) { error << _("An error occurred while executing time stretch operation") << endmsg; } } @@ -6966,7 +6971,6 @@ void NoteCreateDrag::motion (GdkEvent* event, bool) { const timepos_t pos = _drags->current_pointer_time (); - const int32_t divisions = _editor->get_grid_music_divisions (event->button.state); Temporal::Beats aligned_beats = grid_aligned_beats (pos, event); if (_editor->snap_mode() != SnapOff) { diff --git a/gtk2_ardour/editor_timefx.cc b/gtk2_ardour/editor_timefx.cc index ef457312fb..fd8b22a170 100644 --- a/gtk2_ardour/editor_timefx.cc +++ b/gtk2_ardour/editor_timefx.cc @@ -66,7 +66,7 @@ using namespace Gtkmm2ext; /** @return -1 in case of error, 1 if operation was cancelled by the user, 0 if everything went ok */ int -Editor::time_stretch (RegionSelection& regions, float fraction) +Editor::time_stretch (RegionSelection& regions, Temporal::ratio_t const & ratio) { RegionList audio; RegionList midi; @@ -81,7 +81,7 @@ Editor::time_stretch (RegionSelection& regions, float fraction) } } - int aret = time_fx (audio, fraction, false); + int aret = time_fx (audio, ratio, false); if (aret < 0) { abort_reversible_command (); return aret; @@ -99,7 +99,7 @@ Editor::time_stretch (RegionSelection& regions, float fraction) } ARDOUR::TimeFXRequest request; - request.time_fraction = fraction; + request.time_fraction = ratio; for (RegionList::iterator i = midi.begin(); i != midi.end(); ++i) { boost::shared_ptr playlist = (*i)->playlist();