13
0

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 "*transport 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 "*edit point clock" style:highest "medium_text"
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
(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)) {
current_timefx->hide ();
error << _("timefx cannot be started - thread creation error") << endmsg;

View File

@ -27,6 +27,8 @@
#include "pbd/error.h"
#include "pbd/pthread_utils.h"
#include "pbd/memento_command.h"
#include "pbd/unwind.h"
#include "pbd/stacktrace.h"
#include <gtkmm2ext/utils.h>
@ -36,6 +38,7 @@
#include "audio_region_view.h"
#include "region_selection.h"
#include "time_fx_dialog.h"
#include "timers.h"
#ifdef USE_RUBBERBAND
#include <rubberband/RubberBandStretcher.h>
@ -56,7 +59,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 +69,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 +137,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<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 (new_length, true);
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->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 +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);
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 +215,26 @@ 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);
progress = p;
}
void
TimeFXDialog::timer_update ()
{
progress_bar.set_fraction (progress);
if (request.done || request.cancel) {
update_connection.disconnect ();
}
}
void
@ -237,11 +261,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 +286,27 @@ TimeFXDialog::get_pitch_fraction () const
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_pitch_fraction () const;
void start_updates ();
private:
ARDOUR::framecnt_t original_length;
Gtk::Adjustment pitch_octave_adjustment;
@ -80,12 +82,17 @@ class TimeFXDialog : public ArdourDialog, public ProgressReporter
Gtk::SpinButton pitch_octave_spinner;
Gtk::SpinButton pitch_semitone_spinner;
Gtk::SpinButton pitch_cent_spinner;
Gtk::Adjustment percent_adjustment;
Gtk::Adjustment duration_adjustment;
AudioClock* duration_clock;
Gtk::RadioButton duration_chosen;
Gtk::RadioButtonGroup choice_group;
Gtk::RadioButton percent_chosen;
bool ignore_adjustment_change;
bool ignore_clock_change;
sigc::connection update_connection;
float progress;
void update_progress_gui (float);
void duration_clock_changed ();
void duration_adjustment_changed ();
void timer_update ();
};
#endif /* __ardour_time_fx_dialog_h__ */