+ current_timefx->status = 0;
+ current_timefx->request.time_fraction = current_timefx->get_time_fraction ();
+ current_timefx->request.pitch_fraction = current_timefx->get_pitch_fraction ();
+
+ if (current_timefx->request.time_fraction == 1.0 &&
+ current_timefx->request.pitch_fraction == 1.0) {
+ /* nothing to do */
+ current_timefx->hide ();
+ return 0;
+ }
+
+#ifdef USE_RUBBERBAND
+ /* parse options */
+
+ RubberBandStretcher::Options options = 0;
+
+ bool realtime = false;
+ bool precise = false;
+ bool peaklock = true;
+ bool longwin = false;
+ bool shortwin = false;
+ bool preserve_formants = false;
+ string txt;
+
+ enum {
+ NoTransients,
+ BandLimitedTransients,
+ Transients
+ } transients = Transients;
+
+ precise = current_timefx->precise_button.get_active();
+ preserve_formants = current_timefx->preserve_formants_button.get_active();
+
+ txt = current_timefx->stretch_opts_selector.get_active_text ();
+
+ for (int i = 0; i <= 6; i++) {
+ if (txt == rb_opt_strings[i]) {
+ rb_current_opt = i;
+ break;
+ }
+ }
+
+ int rb_mode = rb_current_opt;
+
+ if (pitching /*&& rb_current_opt == 6*/) {
+ /* The timefx dialog does not show the "stretch_opts_selector"
+ * when pitch-shifting. So the most recently used option from
+ * "Time Stretch" would be used (if any). That may even be
+ * "resample without preserving pitch", which would be invalid.
+ *
+ * TODO: also show stretch_opts_selector when pitching (except the option
+ * to not preserve pitch) and use separate rb_current_opt when pitching.
+ *
+ * Actually overhaul this the dialog and processing opts below and use rubberband's
+ * "Crispness" levels:
+ * -c 0 equivalent to --no-transients --no-lamination --window-long
+ * -c 1 equivalent to --detector-soft --no-lamination --window-long (for piano)
+ * -c 2 equivalent to --no-transients --no-lamination
+ * -c 3 equivalent to --no-transients
+ * -c 4 equivalent to --bl-transients
+ * -c 5 default processing options
+ * -c 6 equivalent to --no-lamination --window-short (may be good for drums)
+ */
+ rb_mode = 4;
+ }
+
+ switch (rb_mode) {
+ 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.0 / current_timefx->request.time_fraction;
+ 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;
+ if (preserve_formants) options |= RubberBandStretcher::OptionFormantPreserved;
+ if (!peaklock) options |= RubberBandStretcher::OptionPhaseIndependent;
+ if (longwin) options |= RubberBandStretcher::OptionWindowLong;
+ if (shortwin) options |= RubberBandStretcher::OptionWindowShort;
+
+ switch (transients) {
+ case NoTransients:
+ options |= RubberBandStretcher::OptionTransientsSmooth;
+ break;
+ case BandLimitedTransients:
+ options |= RubberBandStretcher::OptionTransientsMixed;
+ break;
+ case Transients:
+ options |= RubberBandStretcher::OptionTransientsCrisp;
+ break;
+ }
+
+ current_timefx->request.opts = (int) options;
+#else
+ current_timefx->request.quick_seek = current_timefx->quick_button.get_active();
+ current_timefx->request.antialias = !current_timefx->antialias_button.get_active();
+#endif
+ current_timefx->request.done = false;
+ current_timefx->request.cancel = false;
+