2009-02-26 20:20:25 -05:00
|
|
|
/*
|
2009-10-14 12:10:01 -04:00
|
|
|
Copyright (C) 2000-2009 Paul Davis
|
2009-02-26 20:20:25 -05:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "time_fx_dialog.h"
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "pbd/error.h"
|
|
|
|
#include "pbd/pthread_utils.h"
|
|
|
|
#include "pbd/memento_command.h"
|
|
|
|
|
|
|
|
#include <gtkmm2ext/utils.h>
|
|
|
|
|
|
|
|
#include "editor.h"
|
|
|
|
#include "audio_time_axis.h"
|
|
|
|
#include "audio_region_view.h"
|
|
|
|
#include "region_selection.h"
|
|
|
|
|
|
|
|
#ifdef USE_RUBBERBAND
|
2013-10-26 10:58:14 -04:00
|
|
|
#include <rubberband/RubberBandStretcher.h>
|
2009-02-26 20:20:25 -05:00
|
|
|
using namespace RubberBand;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace PBD;
|
|
|
|
using namespace Gtk;
|
|
|
|
using namespace Gtkmm2ext;
|
|
|
|
|
|
|
|
TimeFXDialog::TimeFXDialog (Editor& e, bool pitch)
|
|
|
|
: ArdourDialog (X_("time fx dialog"))
|
|
|
|
, editor (e)
|
|
|
|
, pitching (pitch)
|
|
|
|
, pitch_octave_adjustment (0.0, -4.0, 4.0, 1, 2.0)
|
|
|
|
, pitch_semitone_adjustment (0.0, -12.0, 12.0, 1.0, 4.0)
|
|
|
|
, pitch_cent_adjustment (0.0, -499.0, 500.0, 5.0, 15.0)
|
|
|
|
, pitch_octave_spinner (pitch_octave_adjustment)
|
|
|
|
, pitch_semitone_spinner (pitch_semitone_adjustment)
|
|
|
|
, pitch_cent_spinner (pitch_cent_adjustment)
|
|
|
|
, quick_button (_("Quick but Ugly"))
|
|
|
|
, antialias_button (_("Skip Anti-aliasing"))
|
|
|
|
, stretch_opts_label (_("Contents:"))
|
2012-03-22 11:48:49 -04:00
|
|
|
, precise_button (_("Minimize time distortion"))
|
2009-02-26 20:20:25 -05:00
|
|
|
, preserve_formants_button(_("Preserve Formants"))
|
|
|
|
{
|
|
|
|
set_modal (true);
|
2009-06-27 07:29:54 -04:00
|
|
|
set_skip_taskbar_hint (true);
|
|
|
|
set_resizable (false);
|
2009-02-26 20:20:25 -05:00
|
|
|
set_name (N_("TimeFXDialog"));
|
|
|
|
|
|
|
|
if (pitching) {
|
2011-04-05 22:04:37 -04:00
|
|
|
set_title (_("Pitch Shift Audio"));
|
2009-02-26 20:20:25 -05:00
|
|
|
} else {
|
2011-04-05 22:04:37 -04:00
|
|
|
set_title (_("Time Stretch Audio"));
|
2009-02-26 20:20:25 -05:00
|
|
|
}
|
|
|
|
|
2009-06-27 07:29:54 -04:00
|
|
|
cancel_button = add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
2009-02-26 20:20:25 -05:00
|
|
|
|
2009-06-27 07:29:54 -04:00
|
|
|
VBox* vbox = manage (new VBox);
|
|
|
|
Gtk::Label* l;
|
2009-02-26 20:20:25 -05:00
|
|
|
|
2009-06-27 07:29:54 -04:00
|
|
|
get_vbox()->set_spacing (4);
|
2009-02-26 20:20:25 -05:00
|
|
|
|
2009-06-27 07:29:54 -04:00
|
|
|
vbox->set_spacing (18);
|
|
|
|
vbox->set_border_width (5);
|
2009-02-26 20:20:25 -05:00
|
|
|
|
2009-06-27 07:29:54 -04:00
|
|
|
upper_button_box.set_spacing (6);
|
2009-02-26 20:20:25 -05:00
|
|
|
|
2009-06-27 07:29:54 -04:00
|
|
|
l = manage (new Label (_("<b>Options</b>"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false ));
|
|
|
|
l->set_use_markup ();
|
2009-02-26 20:20:25 -05:00
|
|
|
|
2009-06-27 07:29:54 -04:00
|
|
|
upper_button_box.pack_start (*l, false, false);
|
2009-02-26 20:20:25 -05:00
|
|
|
|
2009-06-27 07:29:54 -04:00
|
|
|
if (pitching) {
|
|
|
|
Table* table = manage (new Table (4, 3, false));
|
|
|
|
table->set_row_spacings (6);
|
|
|
|
table->set_col_spacing (1, 6);
|
|
|
|
l = manage (new Label ("", Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false )); //Common gnome way for padding
|
|
|
|
l->set_padding (8, 0);
|
|
|
|
table->attach (*l, 0, 1, 0, 4, Gtk::FILL, Gtk::FILL, 0, 0);
|
|
|
|
|
|
|
|
l = manage (new Label (_("Octaves:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
|
|
|
|
table->attach (*l, 1, 2, 0, 1, Gtk::FILL, Gtk::EXPAND, 0, 0);
|
|
|
|
table->attach (pitch_octave_spinner, 2, 3, 0, 1, Gtk::FILL, Gtk::EXPAND & Gtk::FILL, 0, 0);
|
2011-11-14 08:43:56 -05:00
|
|
|
pitch_octave_spinner.set_activates_default ();
|
2009-06-27 07:29:54 -04:00
|
|
|
|
|
|
|
l = manage (new Label (_("Semitones:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
|
|
|
|
table->attach (*l, 1, 2, 1, 2, Gtk::FILL, Gtk::EXPAND, 0, 0);
|
|
|
|
table->attach (pitch_semitone_spinner, 2, 3, 1, 2, Gtk::FILL, Gtk::EXPAND & Gtk::FILL, 0, 0);
|
2011-11-14 08:43:56 -05:00
|
|
|
pitch_semitone_spinner.set_activates_default ();
|
2009-06-27 07:29:54 -04:00
|
|
|
|
|
|
|
l = manage (new Label (_("Cents:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
|
2009-02-26 20:20:25 -05:00
|
|
|
pitch_cent_spinner.set_digits (1);
|
2009-06-27 07:29:54 -04:00
|
|
|
table->attach (*l, 1, 2, 2, 3, Gtk::FILL, Gtk::EXPAND, 0, 0);
|
|
|
|
table->attach (pitch_cent_spinner, 2, 3, 2, 3, Gtk::FILL, Gtk::EXPAND & Gtk::FILL, 0, 0);
|
2011-11-14 08:43:56 -05:00
|
|
|
pitch_cent_spinner.set_activates_default ();
|
2009-02-26 20:20:25 -05:00
|
|
|
|
2009-06-27 07:29:54 -04:00
|
|
|
table->attach (preserve_formants_button, 1, 3, 3, 4, Gtk::FILL, Gtk::EXPAND, 0, 0);
|
2009-02-26 20:20:25 -05:00
|
|
|
|
2011-11-28 14:46:30 -05:00
|
|
|
add_button (S_("Time|Shift"), Gtk::RESPONSE_ACCEPT);
|
2009-02-26 20:20:25 -05:00
|
|
|
|
2009-06-27 07:29:54 -04:00
|
|
|
upper_button_box.pack_start (*table, false, true);
|
2009-02-26 20:20:25 -05:00
|
|
|
} else {
|
2009-06-27 07:29:54 -04:00
|
|
|
Table* table = manage (new Table (2, 3, false));
|
|
|
|
table->set_row_spacings (6);
|
|
|
|
table->set_col_spacing (1, 6);
|
|
|
|
l = manage (new Label ("", Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false ));
|
|
|
|
l->set_padding (8, 0);
|
|
|
|
table->attach (*l, 0, 1, 0, 2, Gtk::FILL, Gtk::FILL, 0, 0);
|
2009-02-26 20:20:25 -05:00
|
|
|
|
|
|
|
#ifdef USE_RUBBERBAND
|
|
|
|
vector<string> strings;
|
|
|
|
|
2009-06-27 07:29:54 -04:00
|
|
|
table->attach (stretch_opts_label, 1, 2, 0, 1, Gtk::FILL, Gtk::EXPAND, 0, 0);
|
|
|
|
|
2009-02-26 20:20:25 -05:00
|
|
|
set_popdown_strings (stretch_opts_selector, editor.rb_opt_strings);
|
|
|
|
/* set default */
|
2010-08-13 12:50:29 -04:00
|
|
|
stretch_opts_selector.set_active_text (editor.rb_opt_strings[editor.rb_current_opt]);
|
2009-06-27 07:29:54 -04:00
|
|
|
table->attach (stretch_opts_selector, 2, 3, 0, 1, Gtk::FILL, Gtk::EXPAND & Gtk::FILL, 0, 0);
|
2009-02-26 20:20:25 -05:00
|
|
|
|
2009-06-27 07:29:54 -04:00
|
|
|
table->attach (precise_button, 1, 3, 1, 2, Gtk::FILL, Gtk::EXPAND, 0, 0);
|
2009-02-26 20:20:25 -05:00
|
|
|
|
|
|
|
#else
|
|
|
|
quick_button.set_name (N_("TimeFXButton"));
|
2009-06-27 07:29:54 -04:00
|
|
|
table->attach (quick_button, 1, 3, 0, 1, Gtk::FILL, Gtk::EXPAND, 0, 0);
|
2009-02-26 20:20:25 -05:00
|
|
|
|
2009-06-27 07:29:54 -04:00
|
|
|
antialias_button.set_name (N_("TimeFXButton"));
|
|
|
|
table->attach (antialias_button, 1, 3, 1, 2, Gtk::FILL, Gtk::EXPAND, 0, 0);
|
2009-02-26 20:20:25 -05:00
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
#endif
|
2009-06-27 07:29:54 -04:00
|
|
|
|
2009-02-26 20:20:25 -05:00
|
|
|
add_button (_("Stretch/Shrink"), Gtk::RESPONSE_ACCEPT);
|
2009-06-27 07:29:54 -04:00
|
|
|
|
|
|
|
upper_button_box.pack_start (*table, false, true);
|
2009-02-26 20:20:25 -05:00
|
|
|
}
|
|
|
|
|
2011-11-14 08:43:56 -05:00
|
|
|
set_default_response (Gtk::RESPONSE_ACCEPT);
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2009-06-27 07:29:54 -04:00
|
|
|
VBox* progress_box = manage (new VBox);
|
|
|
|
progress_box->set_spacing (6);
|
|
|
|
|
|
|
|
l = manage (new Label (_("<b>Progress</b>"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
|
|
|
|
l->set_use_markup ();
|
2009-02-26 20:20:25 -05:00
|
|
|
|
2009-06-27 07:29:54 -04:00
|
|
|
progress_box->pack_start (*l, false, false);
|
|
|
|
progress_box->pack_start (progress_bar, false, true);
|
|
|
|
|
|
|
|
|
|
|
|
vbox->pack_start (upper_button_box, false, true);
|
|
|
|
vbox->pack_start (*progress_box, false, true);
|
|
|
|
|
|
|
|
get_vbox()->pack_start (*vbox, false, false);
|
2009-02-26 20:20:25 -05:00
|
|
|
|
|
|
|
show_all_children ();
|
|
|
|
}
|
|
|
|
|
2012-01-24 12:04:15 -05:00
|
|
|
void
|
|
|
|
TimeFXDialog::update_progress_gui (float p)
|
2009-02-26 20:20:25 -05:00
|
|
|
{
|
2012-01-24 12:04:15 -05:00
|
|
|
progress_bar.set_fraction (p);
|
2009-02-26 20:20:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TimeFXDialog::cancel_in_progress ()
|
|
|
|
{
|
|
|
|
status = -2;
|
|
|
|
request.cancel = true;
|
|
|
|
first_cancel.disconnect();
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
2009-07-21 11:55:17 -04:00
|
|
|
TimeFXDialog::delete_in_progress (GdkEventAny*)
|
2009-02-26 20:20:25 -05:00
|
|
|
{
|
|
|
|
status = -2;
|
|
|
|
request.cancel = true;
|
|
|
|
first_delete.disconnect();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|