2 Copyright (C) 2000-2009 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include "time_fx_dialog.h"
28 #include "pbd/error.h"
29 #include "pbd/pthread_utils.h"
30 #include "pbd/memento_command.h"
32 #include <gtkmm2ext/window_title.h>
33 #include <gtkmm2ext/utils.h>
36 #include "audio_time_axis.h"
37 #include "audio_region_view.h"
38 #include "region_selection.h"
40 #include "ardour/session.h"
41 #include "ardour/region.h"
42 #include "ardour/audioplaylist.h"
43 #include "ardour/audio_track.h"
44 #include "ardour/audioregion.h"
45 #include "ardour/audio_diskstream.h"
46 #include "ardour/stretch.h"
47 #include "ardour/midi_stretch.h"
48 #include "ardour/pitch.h"
51 #include "rubberband/RubberBandStretcher.h"
52 using namespace RubberBand;
58 using namespace ARDOUR;
62 using namespace Gtkmm2ext;
64 TimeFXDialog::TimeFXDialog (Editor& e, bool pitch)
65 : ArdourDialog (X_("time fx dialog"))
68 , pitch_octave_adjustment (0.0, -4.0, 4.0, 1, 2.0)
69 , pitch_semitone_adjustment (0.0, -12.0, 12.0, 1.0, 4.0)
70 , pitch_cent_adjustment (0.0, -499.0, 500.0, 5.0, 15.0)
71 , pitch_octave_spinner (pitch_octave_adjustment)
72 , pitch_semitone_spinner (pitch_semitone_adjustment)
73 , pitch_cent_spinner (pitch_cent_adjustment)
74 , quick_button (_("Quick but Ugly"))
75 , antialias_button (_("Skip Anti-aliasing"))
76 , stretch_opts_label (_("Contents:"))
77 , precise_button (_("Strict Linear"))
78 , preserve_formants_button(_("Preserve Formants"))
81 set_position (Gtk::WIN_POS_MOUSE);
82 set_name (N_("TimeFXDialog"));
84 WindowTitle title(Glib::get_application_name());
86 title += _("Pitch Shift");
88 title += _("Time Stretch");
90 set_title(title.get_string());
92 cancel_button = add_button (_("Cancel"), Gtk::RESPONSE_CANCEL);
94 get_vbox()->set_spacing (5);
95 get_vbox()->set_border_width (12);
99 upper_button_box.set_spacing (5);
100 upper_button_box.set_border_width (5);
104 l = manage (new Label (_("Octaves")));
105 upper_button_box.pack_start (*l, false, false);
106 upper_button_box.pack_start (pitch_octave_spinner, false, false);
108 l = manage (new Label (_("Semitones (12TET)")));
109 upper_button_box.pack_start (*l, false, false);
110 upper_button_box.pack_start (pitch_semitone_spinner, false, false);
112 l = manage (new Label (_("Cents")));
113 upper_button_box.pack_start (*l, false, false);
114 upper_button_box.pack_start (pitch_cent_spinner, false, false);
116 pitch_cent_spinner.set_digits (1);
118 upper_button_box.pack_start (preserve_formants_button, false, false);
121 add_button (_("Shift"), Gtk::RESPONSE_ACCEPT);
123 get_vbox()->pack_start (upper_button_box, false, false);
127 #ifdef USE_RUBBERBAND
128 opts_box.set_spacing (5);
129 opts_box.set_border_width (5);
130 vector<string> strings;
132 set_popdown_strings (stretch_opts_selector, editor.rb_opt_strings);
134 stretch_opts_selector.set_active_text (editor.rb_opt_strings[4]);
136 opts_box.pack_start (precise_button, false, false);
137 opts_box.pack_start (stretch_opts_label, false, false);
138 opts_box.pack_start (stretch_opts_selector, false, false);
140 get_vbox()->pack_start (opts_box, false, false);
143 upper_button_box.set_homogeneous (true);
144 upper_button_box.set_spacing (5);
145 upper_button_box.set_border_width (5);
147 upper_button_box.pack_start (quick_button, true, true);
148 upper_button_box.pack_start (antialias_button, true, true);
150 quick_button.set_name (N_("TimeFXButton"));
151 antialias_button.set_name (N_("TimeFXButton"));
153 get_vbox()->pack_start (upper_button_box, false, false);
156 add_button (_("Stretch/Shrink"), Gtk::RESPONSE_ACCEPT);
159 get_vbox()->pack_start (progress_bar);
161 progress_bar.set_name (N_("TimeFXProgress"));
163 show_all_children ();
167 TimeFXDialog::update_progress ()
169 progress_bar.set_fraction (request.progress);
170 return !request.done;
174 TimeFXDialog::cancel_in_progress ()
177 request.cancel = true;
178 first_cancel.disconnect();
182 TimeFXDialog::delete_in_progress (GdkEventAny* ev)
185 request.cancel = true;
186 first_delete.disconnect();