ardour
normalize_dialog.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 Paul Davis
3 
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.
8 
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.
13 
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.
17 
18 */
19 
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"
26 #include "i18n.h"
27 
28 using namespace Gtk;
29 
32 
34  : ArdourDialog (more_than_one ? _("Normalize regions") : _("Normalize region"))
35  , _normalize_individually (0)
36 {
37  get_vbox()->set_spacing (12);
38 
39  HBox* hbox = manage (new HBox);
40  hbox->set_spacing (6);
41  hbox->set_border_width (6);
42  hbox->pack_start (*manage (new Label (_("Normalize to:"))), false, false);
43  _spin = manage (new SpinButton (0.2, 2));
44  _spin->set_range (-112, 0);
45  _spin->set_increments (0.1, 1);
46  _spin->set_value (_last_normalization_value);
47  _spin->set_activates_default ();
48  hbox->pack_start (*_spin, false, false);
49  hbox->pack_start (*manage (new Label (_("dbFS"))), false, false);
50  get_vbox()->pack_start (*hbox);
51 
52  if (more_than_one) {
53  RadioButtonGroup group;
54  VBox* vbox = manage (new VBox);
55 
56  _normalize_individually = manage (new RadioButton (group, _("Normalize each region using its own peak value")));
57  vbox->pack_start (*_normalize_individually);
58  RadioButton* b = manage (new RadioButton (group, _("Normalize each region using the peak value of all regions")));
59  vbox->pack_start (*b);
60 
62  b->set_active (!_last_normalize_individually);
63 
64  get_vbox()->pack_start (*vbox);
65  }
66 
67  _progress_bar = manage (new ProgressBar);
68  get_vbox()->pack_start (*_progress_bar);
69 
70  show_all ();
71 
72  add_button (Stock::CANCEL, RESPONSE_CANCEL);
73  add_button (_("Normalize"), RESPONSE_ACCEPT);
74  set_default_response (RESPONSE_ACCEPT);
75 
76  signal_response().connect (sigc::mem_fun (*this, &NormalizeDialog::button_clicked));
77 }
78 
79 bool
81 {
82  if (_normalize_individually == 0) {
83  return true;
84  }
85 
86  return _normalize_individually->get_active ();
87 }
88 
89 double
91 {
92  return _spin->get_value ();
93 }
94 
95 void
97 {
98  _progress_bar->set_fraction (p);
99 }
100 
101 int
103 {
104  int const r = ArdourDialog::run ();
108  }
109  return r;
110 }
111 
112 void
114 {
115  if (r == RESPONSE_CANCEL) {
116  cancel ();
117  }
118 }
Definition: ardour_ui.h:130
Gtk::ProgressBar * _progress_bar
void button_clicked(int)
double target() const
#define _(Text)
Definition: i18n.h:11
Gtk::SpinButton * _spin
Gtk::RadioButton * _normalize_individually
static double _last_normalization_value
static bool _last_normalize_individually
bool normalize_individually() const
void update_progress_gui(float)