+ current_timefx->status = 0;
+ current_timefx->regions = regions;
+
+ if (pitching) {
+
+ float cents = current_timefx->pitch_octave_adjustment.get_value() * 1200.0;
+ float pitch_fraction;
+ cents += current_timefx->pitch_semitone_adjustment.get_value() * 100.0;
+ cents += current_timefx->pitch_cent_adjustment.get_value();
+
+ if (cents == 0.0) {
+ // user didn't change anything
+ current_timefx->hide ();
+ return 0;
+ }
+
+ // one octave == 1200 cents
+ // adding one octave doubles the frequency
+ // ratio is 2^^octaves
+
+ pitch_fraction = pow(2, cents/1200);
+
+ current_timefx->request.time_fraction = 1.0;
+ current_timefx->request.pitch_fraction = pitch_fraction;
+
+ } else {
+
+ current_timefx->request.time_fraction = val;
+ current_timefx->request.pitch_fraction = 1.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 ();
+
+ 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;
+ };
+
+
+ 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.progress = 0.0f;
+ current_timefx->request.done = false;
+ current_timefx->request.cancel = false;