2 Copyright (C) 2010 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 <gtkmm/label.h>
21 #include <gtkmm/spinbutton.h>
22 #include <gtkmm/radiobutton.h>
23 #include <gtkmm/stock.h>
24 #include <gtkmm/progressbar.h>
25 #include "normalize_dialog.h"
29 double NormalizeDialog::_last_normalization_value = 0;
31 NormalizeDialog::NormalizeDialog (bool more_than_one)
32 : ArdourDialog (more_than_one ? _("Normalize regions") : _("Normalize region"))
33 , _normalize_individually (0)
35 get_vbox()->set_spacing (12);
37 HBox* hbox = manage (new HBox);
38 hbox->set_spacing (6);
39 hbox->set_border_width (6);
40 hbox->pack_start (*manage (new Label (_("Normalize to:"))), false, false);
41 _spin = manage (new SpinButton (0.2, 2));
42 _spin->set_range (-112, 0);
43 _spin->set_increments (0.1, 1);
44 _spin->set_value (_last_normalization_value);
45 hbox->pack_start (*_spin, false, false);
46 hbox->pack_start (*manage (new Label (_("dbFS"))), false, false);
47 get_vbox()->pack_start (*hbox);
50 RadioButtonGroup group;
51 VBox* vbox = manage (new VBox);
53 _normalize_individually = manage (new RadioButton (group, _("Normalize each region using its own peak value")));
54 vbox->pack_start (*_normalize_individually);
55 RadioButton* b = manage (new RadioButton (group, _("Normalize each region using the peak value of all regions")));
56 vbox->pack_start (*b);
58 get_vbox()->pack_start (*vbox);
60 _progress_bar = manage (new ProgressBar);
61 get_vbox()->pack_start (*_progress_bar);
66 add_button (Stock::CANCEL, RESPONSE_CANCEL);
67 add_button (_("Normalize"), RESPONSE_ACCEPT);
71 NormalizeDialog::normalize_individually () const
73 if (_normalize_individually == 0) {
77 return _normalize_individually->get_active ();
81 NormalizeDialog::target () const
83 return _spin->get_value ();
87 NormalizeDialog::set_progress (double p)
89 _progress_bar->set_fraction (p);
91 while (gtk_events_pending()) {
92 gtk_main_iteration ();