mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 06:44:57 +01:00
Merge with 2.0-ongoing R2883.
git-svn-id: svn://localhost/ardour2/trunk@2885 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
bb457bb960
commit
8a2e30816e
45 changed files with 2346 additions and 701 deletions
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
|
||||
|
|
@ -27,6 +28,7 @@
|
|||
#include <pbd/memento_command.h>
|
||||
|
||||
#include <gtkmm2ext/window_title.h>
|
||||
#include <gtkmm2ext/utils.h>
|
||||
|
||||
#include "editor.h"
|
||||
#include "audio_time_axis.h"
|
||||
|
|
@ -42,8 +44,14 @@
|
|||
#include <ardour/stretch.h>
|
||||
#include <ardour/pitch.h>
|
||||
|
||||
#ifdef USE_RUBBERBAND
|
||||
#include <rubberband/RubberBandStretcher.h>
|
||||
using namespace RubberBand;
|
||||
#endif
|
||||
|
||||
#include "i18n.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace ARDOUR;
|
||||
using namespace PBD;
|
||||
using namespace sigc;
|
||||
|
|
@ -54,14 +62,16 @@ Editor::TimeFXDialog::TimeFXDialog (Editor& e, bool pitch)
|
|||
: ArdourDialog (X_("time fx dialog")),
|
||||
editor (e),
|
||||
pitching (pitch),
|
||||
pitch_octave_adjustment (0.0, 0.0, 4.0, 1, 2.0),
|
||||
pitch_semitone_adjustment (0.0, 0.0, 12.0, 1.0, 4.0),
|
||||
pitch_cent_adjustment (0.0, 0.0, 150.0, 5.0, 15.0),
|
||||
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"))
|
||||
antialias_button (_("Skip Anti-aliasing")),
|
||||
stretch_opts_label (_("Contents:")),
|
||||
precise_button (_("Strict Linear"))
|
||||
{
|
||||
set_modal (true);
|
||||
set_position (Gtk::WIN_POS_MOUSE);
|
||||
|
|
@ -79,8 +89,6 @@ Editor::TimeFXDialog::TimeFXDialog (Editor& e, bool pitch)
|
|||
|
||||
get_vbox()->set_spacing (5);
|
||||
get_vbox()->set_border_width (12);
|
||||
get_vbox()->pack_start (upper_button_box, false, false);
|
||||
get_vbox()->pack_start (progress_bar);
|
||||
|
||||
if (pitching) {
|
||||
|
||||
|
|
@ -105,19 +113,44 @@ Editor::TimeFXDialog::TimeFXDialog (Editor& e, bool pitch)
|
|||
|
||||
add_button (_("Shift"), Gtk::RESPONSE_ACCEPT);
|
||||
|
||||
get_vbox()->pack_start (upper_button_box, false, false);
|
||||
|
||||
} else {
|
||||
|
||||
#ifdef USE_RUBBERBAND
|
||||
opts_box.set_spacing (5);
|
||||
opts_box.set_border_width (5);
|
||||
vector<string> strings;
|
||||
|
||||
set_popdown_strings (stretch_opts_selector, editor.rb_opt_strings);
|
||||
/* set default */
|
||||
stretch_opts_selector.set_active_text (editor.rb_opt_strings[4]);
|
||||
|
||||
opts_box.pack_start (precise_button, false, false);
|
||||
opts_box.pack_start (stretch_opts_label, false, false);
|
||||
opts_box.pack_start (stretch_opts_selector, false, false);
|
||||
|
||||
get_vbox()->pack_start (opts_box, false, false);
|
||||
|
||||
#else
|
||||
upper_button_box.set_homogeneous (true);
|
||||
upper_button_box.set_spacing (5);
|
||||
upper_button_box.set_border_width (5);
|
||||
|
||||
upper_button_box.pack_start (quick_button, true, true);
|
||||
upper_button_box.pack_start (antialias_button, true, true);
|
||||
|
||||
|
||||
quick_button.set_name (N_("TimeFXButton"));
|
||||
antialias_button.set_name (N_("TimeFXButton"));
|
||||
|
||||
get_vbox()->pack_start (upper_button_box, false, false);
|
||||
|
||||
#endif
|
||||
add_button (_("Stretch/Shrink"), Gtk::RESPONSE_ACCEPT);
|
||||
}
|
||||
|
||||
quick_button.set_name (N_("TimeFXButton"));
|
||||
antialias_button.set_name (N_("TimeFXButton"));
|
||||
get_vbox()->pack_start (progress_bar);
|
||||
|
||||
progress_bar.set_name (N_("TimeFXProgress"));
|
||||
|
||||
show_all_children ();
|
||||
|
|
@ -184,6 +217,7 @@ Editor::time_fx (RegionSelection& regions, float val, bool pitching)
|
|||
if (pitching) {
|
||||
|
||||
float cents = current_timefx->pitch_octave_adjustment.get_value() * 1200.0;
|
||||
float pitch_fraction;
|
||||
cents += current_timefx->pitch_semitone_adjustment.get_value() * 100.0;
|
||||
cents += current_timefx->pitch_cent_adjustment.get_value();
|
||||
|
||||
|
|
@ -193,19 +227,15 @@ Editor::time_fx (RegionSelection& regions, float val, bool pitching)
|
|||
return 0;
|
||||
}
|
||||
|
||||
// we now have the pitch shift in cents. divide by 1200 to get octaves
|
||||
// then multiply by 2.0 because 1 octave == doubling the frequency
|
||||
|
||||
cents /= 1200.0;
|
||||
cents /= 2.0;
|
||||
|
||||
// add 1.0 to convert to RB scale
|
||||
|
||||
cents += 1.0;
|
||||
// one octave == 1200 cents
|
||||
// adding one octave doubles the frequency
|
||||
// ratio is 2^^octaves
|
||||
|
||||
pitch_fraction = pow(2, cents/1200);
|
||||
|
||||
current_timefx->request.time_fraction = 1.0;
|
||||
current_timefx->request.pitch_fraction = cents;
|
||||
|
||||
current_timefx->request.pitch_fraction = pitch_fraction;
|
||||
|
||||
} else {
|
||||
|
||||
current_timefx->request.time_fraction = val;
|
||||
|
|
@ -213,8 +243,70 @@ Editor::time_fx (RegionSelection& regions, float val, bool pitching)
|
|||
|
||||
}
|
||||
|
||||
#ifdef USE_RUBBERBAND
|
||||
/* parse options */
|
||||
|
||||
RubberBandStretcher::Options options = 0;
|
||||
|
||||
bool realtime = false;
|
||||
bool precise = false;
|
||||
bool peaklock = true;
|
||||
bool softening = true;
|
||||
bool longwin = false;
|
||||
bool shortwin = false;
|
||||
string txt;
|
||||
|
||||
enum {
|
||||
NoTransients,
|
||||
BandLimitedTransients,
|
||||
Transients
|
||||
} transients = Transients;
|
||||
|
||||
precise = current_timefx->precise_button.get_active();
|
||||
|
||||
txt = current_timefx->stretch_opts_selector.get_active_text ();
|
||||
|
||||
if (txt == rb_opt_strings[0]) {
|
||||
transients = NoTransients; peaklock = false; longwin = true; shortwin = false;
|
||||
} else if (txt == rb_opt_strings[1]) {
|
||||
transients = NoTransients; peaklock = false; longwin = false; shortwin = false;
|
||||
} else if (txt == rb_opt_strings[2]) {
|
||||
transients = NoTransients; peaklock = true; longwin = false; shortwin = false;
|
||||
} else if (txt == rb_opt_strings[3]) {
|
||||
transients = BandLimitedTransients; peaklock = true; longwin = false; shortwin = false;
|
||||
} else if (txt == rb_opt_strings[5]) {
|
||||
transients = Transients; peaklock = false; longwin = false; shortwin = true;
|
||||
} else {
|
||||
/* default/4 */
|
||||
|
||||
transients = Transients; peaklock = true; longwin = false; shortwin = false;
|
||||
};
|
||||
|
||||
|
||||
if (realtime) options |= RubberBandStretcher::OptionProcessRealTime;
|
||||
if (precise) options |= RubberBandStretcher::OptionStretchPrecise;
|
||||
if (!peaklock) options |= RubberBandStretcher::OptionPhaseIndependent;
|
||||
if (!softening) options |= RubberBandStretcher::OptionPhasePeakLocked;
|
||||
if (longwin) options |= RubberBandStretcher::OptionWindowLong;
|
||||
if (shortwin) options |= RubberBandStretcher::OptionWindowShort;
|
||||
|
||||
switch (transients) {
|
||||
case NoTransients:
|
||||
options |= RubberBandStretcher::OptionTransientsSmooth;
|
||||
break;
|
||||
case BandLimitedTransients:
|
||||
options |= RubberBandStretcher::OptionTransientsMixed;
|
||||
break;
|
||||
case Transients:
|
||||
options |= RubberBandStretcher::OptionTransientsCrisp;
|
||||
break;
|
||||
}
|
||||
|
||||
current_timefx->request.opts = (int) options;
|
||||
#else
|
||||
current_timefx->request.quick_seek = current_timefx->quick_button.get_active();
|
||||
current_timefx->request.antialias = !current_timefx->antialias_button.get_active();
|
||||
#endif
|
||||
current_timefx->request.progress = 0.0f;
|
||||
current_timefx->request.done = false;
|
||||
current_timefx->request.cancel = false;
|
||||
|
|
@ -239,7 +331,7 @@ Editor::time_fx (RegionSelection& regions, float val, bool pitching)
|
|||
|
||||
sigc::connection c = Glib::signal_timeout().connect (mem_fun (current_timefx, &TimeFXDialog::update_progress), 100);
|
||||
|
||||
while (!current_timefx->request.done) {
|
||||
while (!current_timefx->request.done && !current_timefx->request.cancel) {
|
||||
gtk_main_iteration ();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue