X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Ftime_fx_dialog.cc;h=eb7750f4f81b492385b6100b23d22babec2a40ed;hb=0a0eec2adca785e6fff1b1e798bbded196188f4c;hp=e16ba9250442771441eb8ef346f1f5f0f44fb3bf;hpb=60055a0d6ab0ce7abd65daeb52cef96cf2c4244f;p=ardour.git diff --git a/gtk2_ardour/time_fx_dialog.cc b/gtk2_ardour/time_fx_dialog.cc index e16ba92504..eb7750f4f8 100644 --- a/gtk2_ardour/time_fx_dialog.cc +++ b/gtk2_ardour/time_fx_dialog.cc @@ -21,14 +21,17 @@ #include #include #include - #include +#include + #include "pbd/error.h" #include "pbd/pthread_utils.h" #include "pbd/memento_command.h" +#include "pbd/unwind.h" +#include "pbd/stacktrace.h" -#include +#include "gtkmm2ext/utils.h" #include "audio_clock.h" #include "editor.h" @@ -36,13 +39,14 @@ #include "audio_region_view.h" #include "region_selection.h" #include "time_fx_dialog.h" +#include "timers.h" #ifdef USE_RUBBERBAND #include using namespace RubberBand; #endif -#include "i18n.h" +#include "pbd/i18n.h" using namespace std; using namespace ARDOUR; @@ -56,7 +60,7 @@ TimeFXDialog::TimeFXDialog (Editor& e, bool pitch, framecnt_t oldlen, framecnt_t , pitching (pitch) , quick_button (_("Quick but Ugly")) , antialias_button (_("Skip Anti-aliasing")) - , stretch_opts_label (_("Contents:")) + , stretch_opts_label (_("Contents")) , precise_button (_("Minimize time distortion")) , preserve_formants_button(_("Preserve Formants")) , original_length (oldlen) @@ -66,11 +70,11 @@ TimeFXDialog::TimeFXDialog (Editor& e, bool pitch, framecnt_t oldlen, framecnt_t , pitch_octave_spinner (pitch_octave_adjustment) , pitch_semitone_spinner (pitch_semitone_adjustment) , pitch_cent_spinner (pitch_cent_adjustment) - , percent_adjustment (100.0, -1000.0, 1000.0, 1.0, 10.0) + , duration_adjustment (100.0, -1000.0, 1000.0, 1.0, 10.0) , duration_clock (0) - , duration_chosen (_("Duration")) - , choice_group (duration_chosen.get_group()) - , percent_chosen (choice_group, _("Percent")) + , ignore_adjustment_change (false) + , ignore_clock_change (false) + , progress (0.0f) { set_modal (true); set_skip_taskbar_hint (true); @@ -134,11 +138,11 @@ TimeFXDialog::TimeFXDialog (Editor& e, bool pitch, framecnt_t oldlen, framecnt_t int row = 0; table->set_row_spacings (6); - table->set_col_spacings (6); + table->set_col_spacings (12); #ifdef USE_RUBBERBAND vector strings; - duration_clock = manage (new AudioClock (X_("stretch"), true, "stretch", true, false, true, false, true)); + duration_clock = manage (new AudioClock (X_("stretch"), true, X_("stretch"), true, false, true, false, true)); duration_clock->set_session (e.session()); duration_clock->set (new_length, true); duration_clock->set_mode (AudioClock::BBT); @@ -148,17 +152,18 @@ TimeFXDialog::TimeFXDialog (Editor& e, bool pitch, framecnt_t oldlen, framecnt_t clock_align->add (*duration_clock); clock_align->set (0.0, 0.5, 0.0, 1.0); - Gtk::RadioButtonGroup group; - table->attach (duration_chosen, 0, 1, row, row+1, Gtk::FILL, Gtk::FILL, 0, 0); + l = manage (new Gtk::Label (_("Duration"))); + table->attach (*l, 0, 1, row, row+1, Gtk::FILL, Gtk::FILL, 0, 0); table->attach (*clock_align, 1, 2, row, row+1, Gtk::AttachOptions (Gtk::EXPAND|Gtk::FILL), Gtk::FILL, 0, 0); row++; const double fract = ((double) new_length) / original_length; /* note the *100.0 to convert fract into a percentage */ - percent_adjustment.set_value (fract*100.0); - Gtk::SpinButton* spinner = manage (new Gtk::SpinButton (percent_adjustment, 1.0, 3)); + duration_adjustment.set_value (fract*100.0); + Gtk::SpinButton* spinner = manage (new Gtk::SpinButton (duration_adjustment, 1.0, 3)); - table->attach (percent_chosen, 0, 1, row, row+1, Gtk::FILL, Gtk::FILL, 0, 0); + l = manage (new Gtk::Label (_("Percent"))); + table->attach (*l, 0, 1, row, row+1, Gtk::FILL, Gtk::FILL, 0, 0); table->attach (*spinner, 1, 2, row, row+1, Gtk::FILL, Gtk::FILL, 0, 0); row++; @@ -172,6 +177,10 @@ TimeFXDialog::TimeFXDialog (Editor& e, bool pitch, framecnt_t oldlen, framecnt_t table->attach (precise_button, 0, 2, row, row+1, Gtk::FILL, Gtk::EXPAND, 0, 0); row++; + + duration_clock->ValueChanged.connect (sigc::mem_fun (*this, &TimeFXDialog::duration_clock_changed)); + duration_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &TimeFXDialog::duration_adjustment_changed)); + #else quick_button.set_name (N_("TimeFXButton")); table->attach (quick_button, 1, 3, row, row+1, Gtk::FILL, Gtk::EXPAND, 0, 0); @@ -207,10 +216,31 @@ TimeFXDialog::TimeFXDialog (Editor& e, bool pitch, framecnt_t oldlen, framecnt_t show_all_children (); } +void +TimeFXDialog::start_updates () +{ + update_connection = Timers::rapid_connect (sigc::mem_fun (*this, &TimeFXDialog::timer_update)); +} + void TimeFXDialog::update_progress_gui (float p) { - progress_bar.set_fraction (p); + /* time/pitch FX are applied in a dedicated thread, so we cannot just + update the GUI when notified about progress. That is deferred to a + timer-driven callback which will ensure that the visual progress + indicator is updated. + */ + progress = p; +} + +void +TimeFXDialog::timer_update () +{ + progress_bar.set_fraction (progress); + + if (request.done || request.cancel) { + update_connection.disconnect (); + } } void @@ -237,11 +267,7 @@ TimeFXDialog::get_time_fraction () const return 1.0; } - if (duration_chosen.get_active()) { - return duration_clock->current_duration () / original_length; - } - - return percent_adjustment.get_value() / 100.0; + return duration_adjustment.get_value() / 100.0; } float @@ -266,3 +292,27 @@ TimeFXDialog::get_pitch_fraction () const return pow(2, cents/1200); } + +void +TimeFXDialog::duration_adjustment_changed () +{ + if (ignore_adjustment_change) { + return; + } + + PBD::Unwinder uw (ignore_clock_change, true); + + duration_clock->set ((framecnt_t) (original_length * (duration_adjustment.get_value()/ 100.0))); +} + +void +TimeFXDialog::duration_clock_changed () +{ + if (ignore_clock_change) { + return; + } + + PBD::Unwinder uw (ignore_adjustment_change, true); + + duration_adjustment.set_value (100.0 * (duration_clock->current_duration() / (double) original_length)); +}