Move normalize dialogue to its own file. Add progress bar. Clean up labelling. Should fix 2825.

git-svn-id: svn://localhost/ardour2/branches/3.0@7923 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2010-10-26 00:30:22 +00:00
parent 7d2c21fddb
commit 8f448a78cd
6 changed files with 155 additions and 39 deletions

View File

@ -735,8 +735,6 @@ Editor::Editor ()
TimeAxisView::CatchDeletion.connect (*this, invalidator (*this), ui_bind (&Editor::timeaxisview_deleted, this, _1), gui_context());
_last_normalization_value = 0;
constructed = true;
instant_save ();

View File

@ -1104,7 +1104,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
void reverse_region ();
void strip_region_silence ();
void normalize_region ();
double _last_normalization_value;
void reset_region_scale_amplitude ();
void adjust_region_scale_amplitude (bool up);
void quantize_region ();

View File

@ -81,6 +81,7 @@
#include "quantize_dialog.h"
#include "interthread_progress_window.h"
#include "insert_time_dialog.h"
#include "normalize_dialog.h"
#include "i18n.h"
@ -4497,37 +4498,7 @@ Editor::normalize_region ()
return;
}
Dialog dialog (rs.size() > 1 ? _("Normalize regions") : _("Normalize region"));
VBox vbox;
vbox.set_spacing (6);
vbox.set_border_width (6);
HBox hbox;
hbox.set_spacing (6);
hbox.set_border_width (6);
hbox.pack_start (*manage (new Label (_("Normalize to:"))));
SpinButton spin (0.2, 2);
spin.set_range (-112, 0);
spin.set_increments (0.1, 1);
spin.set_value (0);
hbox.pack_start (spin);
spin.set_value (_last_normalization_value);
hbox.pack_start (*manage (new Label (_("dbFS"))));
vbox.pack_start (hbox);
CheckButton* normalize_across_all = manage (new CheckButton (_("Normalize across all selected regions")));
vbox.pack_start (*normalize_across_all);
if (rs.size() <= 1) {
normalize_across_all->set_sensitive (false);
}
vbox.show_all ();
dialog.get_vbox()->set_spacing (12);
dialog.get_vbox()->pack_start (vbox);
dialog.add_button (Stock::CANCEL, RESPONSE_CANCEL);
dialog.add_button (_("Normalize"), RESPONSE_ACCEPT);
NormalizeDialog dialog (rs.size() > 1);
if (dialog.run () == RESPONSE_CANCEL) {
return;
@ -4538,14 +4509,23 @@ Editor::normalize_region ()
set_canvas_cursor (wait_cursor);
gdk_flush ();
int tasks = rs.size ();
if (!dialog.normalize_individually()) {
tasks *= 2;
}
int n = 0;
double maxamp = 0;
if (normalize_across_all->get_active ()) {
if (!dialog.normalize_individually()) {
for (RegionSelection::iterator r = rs.begin(); r != rs.end(); ++r) {
AudioRegionView* const arv = dynamic_cast<AudioRegionView*> (*r);
if (!arv) {
continue;
}
maxamp = max (maxamp, arv->audio_region()->maximum_amplitude ());
dialog.set_progress (double (n) / tasks);
++n;
}
}
@ -4556,16 +4536,17 @@ Editor::normalize_region ()
}
arv->region()->clear_changes ();
double const amp = normalize_across_all->get_active() ? maxamp : arv->audio_region()->maximum_amplitude ();
double const amp = dialog.normalize_individually () ? arv->audio_region()->maximum_amplitude () : maxamp;
arv->audio_region()->normalize (amp, spin.get_value ());
arv->audio_region()->normalize (amp, dialog.target ());
_session->add_command (new StatefulDiffCommand (arv->region()));
dialog.set_progress (double (n) / tasks);
++n;
}
commit_reversible_command ();
set_canvas_cursor (current_canvas_cursor);
_last_normalization_value = spin.get_value ();
}

View File

@ -0,0 +1,94 @@
/*
Copyright (C) 2010 Paul Davis
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 <gtkmm/label.h>
#include <gtkmm/spinbutton.h>
#include <gtkmm/radiobutton.h>
#include <gtkmm/stock.h>
#include <gtkmm/progressbar.h>
#include "normalize_dialog.h"
using namespace Gtk;
double NormalizeDialog::_last_normalization_value = 0;
NormalizeDialog::NormalizeDialog (bool more_than_one)
: ArdourDialog (more_than_one ? _("Normalize regions") : _("Normalize region"))
, _normalize_individually (0)
{
get_vbox()->set_spacing (12);
HBox* hbox = manage (new HBox);
hbox->set_spacing (6);
hbox->set_border_width (6);
hbox->pack_start (*manage (new Label (_("Normalize to:"))), false, false);
_spin = manage (new SpinButton (0.2, 2));
_spin->set_range (-112, 0);
_spin->set_increments (0.1, 1);
_spin->set_value (_last_normalization_value);
hbox->pack_start (*_spin, false, false);
hbox->pack_start (*manage (new Label (_("dbFS"))), false, false);
get_vbox()->pack_start (*hbox);
if (more_than_one) {
RadioButtonGroup group;
VBox* vbox = manage (new VBox);
_normalize_individually = manage (new RadioButton (group, _("Normalize each region using its own peak value")));
vbox->pack_start (*_normalize_individually);
RadioButton* b = manage (new RadioButton (group, _("Normalize each region using the peak value of all regions")));
vbox->pack_start (*b);
get_vbox()->pack_start (*vbox);
_progress_bar = manage (new ProgressBar);
get_vbox()->pack_start (*_progress_bar);
}
show_all ();
add_button (Stock::CANCEL, RESPONSE_CANCEL);
add_button (_("Normalize"), RESPONSE_ACCEPT);
}
bool
NormalizeDialog::normalize_individually () const
{
if (_normalize_individually == 0) {
return false;
}
return _normalize_individually->get_active ();
}
double
NormalizeDialog::target () const
{
return _spin->get_value ();
}
void
NormalizeDialog::set_progress (double p)
{
_progress_bar->set_fraction (p);
while (gtk_events_pending()) {
gtk_main_iteration ();
}
}

View File

@ -0,0 +1,43 @@
/*
Copyright (C) 2010 Paul Davis
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 "ardour_dialog.h"
namespace Gtk {
class RadioButton;
class SpinButton;
class ProgressBar;
}
class NormalizeDialog : public ArdourDialog
{
public:
NormalizeDialog (bool);
bool normalize_individually () const;
double target () const;
void set_progress (double);
private:
Gtk::RadioButton* _normalize_individually;
Gtk::SpinButton* _spin;
Gtk::ProgressBar* _progress_bar;
static double _last_normalization_value;
};

View File

@ -146,6 +146,7 @@ gtk2_ardour_sources = [
'mixer_ui.cc',
'monitor_section.cc',
'nag.cc',
'normalize_dialog.cc',
'note_player.cc',
'option_editor.cc',
'opts.cc',