From d62f7e1c72523e77b8d1fd1b3f4a2e8d078ac5f1 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 13 Aug 2010 16:50:29 +0000 Subject: Patch from colinf to add tape-style region stretching via rubberband. Fixes #3075. git-svn-id: svn://localhost/ardour2/branches/3.0@7620 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor.cc | 2 ++ gtk2_ardour/editor.h | 1 + gtk2_ardour/editor_timefx.cc | 49 ++++++++++++++++++++++++++++++------------- gtk2_ardour/time_fx_dialog.cc | 2 +- 4 files changed, 39 insertions(+), 15 deletions(-) diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 872566f54f..19408d32ed 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -201,6 +201,7 @@ static const gchar *_rb_opt_strings[] = { N_("Unpitched percussion with stable notes"), N_("Crisp monophonic instrumental"), N_("Unpitched solo percussion"), + N_("Resample without preserving pitch"), 0 }; #endif @@ -329,6 +330,7 @@ Editor::Editor () edit_point_strings = I18N (_edit_point_strings); #ifdef USE_RUBBERBAND rb_opt_strings = I18N (_rb_opt_strings); + rb_current_opt = 4; #endif snap_threshold = 5.0; diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 55ea12c35e..9158e40d26 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -221,6 +221,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD #ifdef USE_RUBBERBAND std::vector rb_opt_strings; + int rb_current_opt; #endif /* things that need to be public to be used in the main menubar */ diff --git a/gtk2_ardour/editor_timefx.cc b/gtk2_ardour/editor_timefx.cc index 6f5e380fef..88889a4745 100644 --- a/gtk2_ardour/editor_timefx.cc +++ b/gtk2_ardour/editor_timefx.cc @@ -171,21 +171,42 @@ Editor::time_fx (RegionSelection& regions, float val, bool pitching) txt = current_timefx->stretch_opts_selector.get_active_text (); - if (txt == rb_opt_strings[0]) { - transients = NoTransients; peaklock = false; longwin = true; shortwin = false; - } else if (txt == rb_opt_strings[1]) { - transients = NoTransients; peaklock = false; longwin = false; shortwin = false; - } else if (txt == rb_opt_strings[2]) { - transients = NoTransients; peaklock = true; longwin = false; shortwin = false; - } else if (txt == rb_opt_strings[3]) { - transients = BandLimitedTransients; peaklock = true; longwin = false; shortwin = false; - } else if (txt == rb_opt_strings[5]) { - transients = Transients; peaklock = false; longwin = false; shortwin = true; - } else { - /* default/4 */ - - transients = Transients; peaklock = true; longwin = false; shortwin = false; + for (int i = 0; i <= 6; i++) { + if (txt == rb_opt_strings[i]) { + rb_current_opt = i; + break; + } } + + switch (rb_current_opt) { + case 0: + transients = NoTransients; peaklock = false; longwin = true; shortwin = false; + break; + case 1: + transients = NoTransients; peaklock = false; longwin = false; shortwin = false; + break; + case 2: + transients = NoTransients; peaklock = true; longwin = false; shortwin = false; + break; + case 3: + transients = BandLimitedTransients; peaklock = true; longwin = false; shortwin = false; + break; + case 5: + transients = Transients; peaklock = false; longwin = false; shortwin = true; + break; + case 6: + transients = NoTransients; + precise = true; + preserve_formants = false; + current_timefx->request.pitch_fraction = 1/val; + shortwin = true; + // peaklock = false; + break; + default: + /* default/4 */ + transients = Transients; peaklock = true; longwin = false; shortwin = false; + break; + }; if (realtime) options |= RubberBandStretcher::OptionProcessRealTime; if (precise) options |= RubberBandStretcher::OptionStretchPrecise; diff --git a/gtk2_ardour/time_fx_dialog.cc b/gtk2_ardour/time_fx_dialog.cc index d1650430b2..c42caaf925 100644 --- a/gtk2_ardour/time_fx_dialog.cc +++ b/gtk2_ardour/time_fx_dialog.cc @@ -145,7 +145,7 @@ TimeFXDialog::TimeFXDialog (Editor& e, bool pitch) set_popdown_strings (stretch_opts_selector, editor.rb_opt_strings); /* set default */ - stretch_opts_selector.set_active_text (editor.rb_opt_strings[4]); + stretch_opts_selector.set_active_text (editor.rb_opt_strings[editor.rb_current_opt]); table->attach (stretch_opts_selector, 2, 3, 0, 1, Gtk::FILL, Gtk::EXPAND & Gtk::FILL, 0, 0); table->attach (precise_button, 1, 3, 1, 2, Gtk::FILL, Gtk::EXPAND, 0, 0); -- cgit v1.2.3