more work on time/pitch stretch/shifting

Clock and percent measure are now linked, not alternatives. Threading for GUI updates is now safe.
This commit is contained in:
Paul Davis 2016-02-22 10:17:09 -05:00
parent 031286f1a1
commit e98553edfa
4 changed files with 76 additions and 22 deletions

View file

@ -1058,6 +1058,7 @@ widget "*transport clock" style:highest "bigger_clock"
widget "*secondary clock" style:highest "bigger_clock" widget "*secondary clock" style:highest "bigger_clock"
widget "*transport delta clock" style:highest "bigger_clock" widget "*transport delta clock" style:highest "bigger_clock"
widget "*secondary delta clock" style:highest "bigger_clock" widget "*secondary delta clock" style:highest "bigger_clock"
widget "*stretch clock" style:highest "bigger_clock"
widget "*silence duration clock" style:highest "medium_text" widget "*silence duration clock" style:highest "medium_text"
widget "*edit point clock" style:highest "medium_text" widget "*edit point clock" style:highest "medium_text"
widget "*nudge clock" style:highest "small_clock" widget "*nudge clock" style:highest "small_clock"

View file

@ -275,6 +275,8 @@ Editor::time_fx (RegionList& regions, float val, bool pitching)
current_timefx->first_delete = current_timefx->signal_delete_event().connect current_timefx->first_delete = current_timefx->signal_delete_event().connect
(sigc::mem_fun (current_timefx, &TimeFXDialog::delete_in_progress)); (sigc::mem_fun (current_timefx, &TimeFXDialog::delete_in_progress));
current_timefx->start_updates ();
if (pthread_create_and_store ("timefx", &current_timefx->request.thread, timefx_thread, current_timefx)) { if (pthread_create_and_store ("timefx", &current_timefx->request.thread, timefx_thread, current_timefx)) {
current_timefx->hide (); current_timefx->hide ();
error << _("timefx cannot be started - thread creation error") << endmsg; error << _("timefx cannot be started - thread creation error") << endmsg;

View file

@ -27,6 +27,8 @@
#include "pbd/error.h" #include "pbd/error.h"
#include "pbd/pthread_utils.h" #include "pbd/pthread_utils.h"
#include "pbd/memento_command.h" #include "pbd/memento_command.h"
#include "pbd/unwind.h"
#include "pbd/stacktrace.h"
#include <gtkmm2ext/utils.h> #include <gtkmm2ext/utils.h>
@ -36,6 +38,7 @@
#include "audio_region_view.h" #include "audio_region_view.h"
#include "region_selection.h" #include "region_selection.h"
#include "time_fx_dialog.h" #include "time_fx_dialog.h"
#include "timers.h"
#ifdef USE_RUBBERBAND #ifdef USE_RUBBERBAND
#include <rubberband/RubberBandStretcher.h> #include <rubberband/RubberBandStretcher.h>
@ -56,7 +59,7 @@ TimeFXDialog::TimeFXDialog (Editor& e, bool pitch, framecnt_t oldlen, framecnt_t
, pitching (pitch) , pitching (pitch)
, quick_button (_("Quick but Ugly")) , quick_button (_("Quick but Ugly"))
, antialias_button (_("Skip Anti-aliasing")) , antialias_button (_("Skip Anti-aliasing"))
, stretch_opts_label (_("Contents:")) , stretch_opts_label (_("Contents"))
, precise_button (_("Minimize time distortion")) , precise_button (_("Minimize time distortion"))
, preserve_formants_button(_("Preserve Formants")) , preserve_formants_button(_("Preserve Formants"))
, original_length (oldlen) , original_length (oldlen)
@ -66,11 +69,11 @@ TimeFXDialog::TimeFXDialog (Editor& e, bool pitch, framecnt_t oldlen, framecnt_t
, pitch_octave_spinner (pitch_octave_adjustment) , pitch_octave_spinner (pitch_octave_adjustment)
, pitch_semitone_spinner (pitch_semitone_adjustment) , pitch_semitone_spinner (pitch_semitone_adjustment)
, pitch_cent_spinner (pitch_cent_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_clock (0)
, duration_chosen (_("Duration")) , ignore_adjustment_change (false)
, choice_group (duration_chosen.get_group()) , ignore_clock_change (false)
, percent_chosen (choice_group, _("Percent")) , progress (0.0f)
{ {
set_modal (true); set_modal (true);
set_skip_taskbar_hint (true); set_skip_taskbar_hint (true);
@ -134,11 +137,11 @@ TimeFXDialog::TimeFXDialog (Editor& e, bool pitch, framecnt_t oldlen, framecnt_t
int row = 0; int row = 0;
table->set_row_spacings (6); table->set_row_spacings (6);
table->set_col_spacings (6); table->set_col_spacings (12);
#ifdef USE_RUBBERBAND #ifdef USE_RUBBERBAND
vector<string> strings; vector<string> 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_session (e.session());
duration_clock->set (new_length, true); duration_clock->set (new_length, true);
duration_clock->set_mode (AudioClock::BBT); duration_clock->set_mode (AudioClock::BBT);
@ -148,17 +151,18 @@ TimeFXDialog::TimeFXDialog (Editor& e, bool pitch, framecnt_t oldlen, framecnt_t
clock_align->add (*duration_clock); clock_align->add (*duration_clock);
clock_align->set (0.0, 0.5, 0.0, 1.0); clock_align->set (0.0, 0.5, 0.0, 1.0);
Gtk::RadioButtonGroup group; l = manage (new Gtk::Label (_("Duration")));
table->attach (duration_chosen, 0, 1, row, row+1, Gtk::FILL, Gtk::FILL, 0, 0); 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); table->attach (*clock_align, 1, 2, row, row+1, Gtk::AttachOptions (Gtk::EXPAND|Gtk::FILL), Gtk::FILL, 0, 0);
row++; row++;
const double fract = ((double) new_length) / original_length; const double fract = ((double) new_length) / original_length;
/* note the *100.0 to convert fract into a percentage */ /* note the *100.0 to convert fract into a percentage */
percent_adjustment.set_value (fract*100.0); duration_adjustment.set_value (fract*100.0);
Gtk::SpinButton* spinner = manage (new Gtk::SpinButton (percent_adjustment, 1.0, 3)); 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); table->attach (*spinner, 1, 2, row, row+1, Gtk::FILL, Gtk::FILL, 0, 0);
row++; row++;
@ -172,6 +176,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); table->attach (precise_button, 0, 2, row, row+1, Gtk::FILL, Gtk::EXPAND, 0, 0);
row++; 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 #else
quick_button.set_name (N_("TimeFXButton")); quick_button.set_name (N_("TimeFXButton"));
table->attach (quick_button, 1, 3, row, row+1, Gtk::FILL, Gtk::EXPAND, 0, 0); table->attach (quick_button, 1, 3, row, row+1, Gtk::FILL, Gtk::EXPAND, 0, 0);
@ -207,10 +215,26 @@ TimeFXDialog::TimeFXDialog (Editor& e, bool pitch, framecnt_t oldlen, framecnt_t
show_all_children (); show_all_children ();
} }
void
TimeFXDialog::start_updates ()
{
update_connection = Timers::rapid_connect (sigc::mem_fun (*this, &TimeFXDialog::timer_update));
}
void void
TimeFXDialog::update_progress_gui (float p) TimeFXDialog::update_progress_gui (float p)
{ {
progress_bar.set_fraction (p); progress = p;
}
void
TimeFXDialog::timer_update ()
{
progress_bar.set_fraction (progress);
if (request.done || request.cancel) {
update_connection.disconnect ();
}
} }
void void
@ -237,11 +261,7 @@ TimeFXDialog::get_time_fraction () const
return 1.0; return 1.0;
} }
if (duration_chosen.get_active()) { return duration_adjustment.get_value() / 100.0;
return duration_clock->current_duration () / original_length;
}
return percent_adjustment.get_value() / 100.0;
} }
float float
@ -266,3 +286,27 @@ TimeFXDialog::get_pitch_fraction () const
return pow(2, cents/1200); return pow(2, cents/1200);
} }
void
TimeFXDialog::duration_adjustment_changed ()
{
if (ignore_adjustment_change) {
return;
}
PBD::Unwinder<bool> 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<bool> uw (ignore_adjustment_change, true);
duration_adjustment.set_value (100.0 * (duration_clock->current_duration() / (double) original_length));
}

View file

@ -72,6 +72,8 @@ class TimeFXDialog : public ArdourDialog, public ProgressReporter
float get_time_fraction () const; float get_time_fraction () const;
float get_pitch_fraction () const; float get_pitch_fraction () const;
void start_updates ();
private: private:
ARDOUR::framecnt_t original_length; ARDOUR::framecnt_t original_length;
Gtk::Adjustment pitch_octave_adjustment; Gtk::Adjustment pitch_octave_adjustment;
@ -80,12 +82,17 @@ class TimeFXDialog : public ArdourDialog, public ProgressReporter
Gtk::SpinButton pitch_octave_spinner; Gtk::SpinButton pitch_octave_spinner;
Gtk::SpinButton pitch_semitone_spinner; Gtk::SpinButton pitch_semitone_spinner;
Gtk::SpinButton pitch_cent_spinner; Gtk::SpinButton pitch_cent_spinner;
Gtk::Adjustment percent_adjustment; Gtk::Adjustment duration_adjustment;
AudioClock* duration_clock; AudioClock* duration_clock;
Gtk::RadioButton duration_chosen; bool ignore_adjustment_change;
Gtk::RadioButtonGroup choice_group; bool ignore_clock_change;
Gtk::RadioButton percent_chosen; sigc::connection update_connection;
float progress;
void update_progress_gui (float); void update_progress_gui (float);
void duration_clock_changed ();
void duration_adjustment_changed ();
void timer_update ();
}; };
#endif /* __ardour_time_fx_dialog_h__ */ #endif /* __ardour_time_fx_dialog_h__ */