- current_timestretch->status = 0;
- current_timestretch->regions = regions;
- current_timestretch->request.fraction = fraction;
- current_timestretch->request.quick_seek = current_timestretch->quick_button.get_active();
- current_timestretch->request.antialias = !current_timestretch->antialias_button.get_active();
- current_timestretch->request.progress = 0.0f;
- current_timestretch->request.running = true;
-
+#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;
+ }
+ }
+
+ 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;
+ 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;
+