2010-10-25 20:30:22 -04:00
|
|
|
/*
|
|
|
|
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"
|
2011-04-22 23:34:42 -04:00
|
|
|
#include "i18n.h"
|
2010-10-25 20:30:22 -04:00
|
|
|
|
|
|
|
using namespace Gtk;
|
|
|
|
|
|
|
|
double NormalizeDialog::_last_normalization_value = 0;
|
2010-10-28 20:40:08 -04:00
|
|
|
bool NormalizeDialog::_last_normalize_individually = true;
|
2010-10-25 20:30:22 -04:00
|
|
|
|
|
|
|
NormalizeDialog::NormalizeDialog (bool more_than_one)
|
|
|
|
: ArdourDialog (more_than_one ? _("Normalize regions") : _("Normalize region"))
|
|
|
|
, _normalize_individually (0)
|
|
|
|
{
|
|
|
|
get_vbox()->set_spacing (12);
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-10-25 20:30:22 -04:00
|
|
|
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);
|
2011-04-05 06:34:33 -04:00
|
|
|
_spin->set_activates_default ();
|
2010-10-25 20:30:22 -04:00
|
|
|
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);
|
|
|
|
|
2010-10-28 20:40:08 -04:00
|
|
|
_normalize_individually->set_active (_last_normalize_individually);
|
|
|
|
b->set_active (!_last_normalize_individually);
|
|
|
|
|
2010-10-25 20:30:22 -04:00
|
|
|
get_vbox()->pack_start (*vbox);
|
|
|
|
}
|
|
|
|
|
2010-10-27 10:22:24 -04:00
|
|
|
_progress_bar = manage (new ProgressBar);
|
|
|
|
get_vbox()->pack_start (*_progress_bar);
|
|
|
|
|
2010-10-25 20:30:22 -04:00
|
|
|
show_all ();
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-10-25 20:30:22 -04:00
|
|
|
add_button (Stock::CANCEL, RESPONSE_CANCEL);
|
|
|
|
add_button (_("Normalize"), RESPONSE_ACCEPT);
|
2011-04-05 06:34:33 -04:00
|
|
|
set_default_response (RESPONSE_ACCEPT);
|
2010-10-28 13:09:32 -04:00
|
|
|
|
|
|
|
signal_response().connect (sigc::mem_fun (*this, &NormalizeDialog::button_clicked));
|
2010-10-25 20:30:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
NormalizeDialog::normalize_individually () const
|
|
|
|
{
|
|
|
|
if (_normalize_individually == 0) {
|
2010-10-27 10:22:24 -04:00
|
|
|
return true;
|
2010-10-25 20:30:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return _normalize_individually->get_active ();
|
|
|
|
}
|
|
|
|
|
|
|
|
double
|
|
|
|
NormalizeDialog::target () const
|
|
|
|
{
|
|
|
|
return _spin->get_value ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-10-27 10:22:24 -04:00
|
|
|
NormalizeDialog::update_progress_gui (float p)
|
2010-10-25 20:30:22 -04:00
|
|
|
{
|
|
|
|
_progress_bar->set_fraction (p);
|
|
|
|
}
|
2010-10-28 13:01:15 -04:00
|
|
|
|
|
|
|
int
|
|
|
|
NormalizeDialog::run ()
|
|
|
|
{
|
|
|
|
int const r = ArdourDialog::run ();
|
|
|
|
_last_normalization_value = target ();
|
2010-10-28 21:04:27 -04:00
|
|
|
if (_normalize_individually) {
|
|
|
|
_last_normalize_individually = _normalize_individually->get_active ();
|
|
|
|
}
|
2010-10-28 13:01:15 -04:00
|
|
|
return r;
|
|
|
|
}
|
2010-10-28 13:09:32 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
NormalizeDialog::button_clicked (int r)
|
|
|
|
{
|
|
|
|
if (r == RESPONSE_CANCEL) {
|
|
|
|
cancel ();
|
|
|
|
}
|
|
|
|
}
|