2 Copyright (C) 2009 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 "gtkmm2ext/utils.h"
22 #include "quantize_dialog.h"
23 #include "public_editor.h"
29 using namespace Gtkmm2ext;
30 using namespace ARDOUR;
32 static const gchar *_grid_strings[] = {
45 static const gchar *_type_strings[] = {
52 std::vector<std::string> QuantizeDialog::grid_strings;
53 std::vector<std::string> QuantizeDialog::type_strings;
55 QuantizeDialog::QuantizeDialog (PublicEditor& e)
56 : ArdourDialog (_("Quantize"), false, false)
58 , type_label (_("Quantize Type"))
59 , strength_adjustment (100.0, 0.0, 100.0, 1.0, 10.0)
60 , strength_spinner (strength_adjustment)
61 , strength_label (_("Strength"))
62 , swing_adjustment (100.0, -130.0, 130.0, 1.0, 10.0)
63 , swing_spinner (swing_adjustment)
64 , swing_button (_("Swing"))
65 , threshold_adjustment (0.0, -1920.0, 1920.0, 1.0, 10.0) // XXX MAGIC TICK NUMBER FIX ME
66 , threshold_spinner (threshold_adjustment)
67 , threshold_label (_("Threshold (ticks)"))
68 , snap_start_button (_("Snap note start"))
69 , snap_end_button (_("Snap note end"))
71 if (grid_strings.empty()) {
72 grid_strings = I18N (_grid_strings);
73 type_strings = I18N (_type_strings);
76 set_popdown_strings (start_grid_combo, grid_strings);
77 start_grid_combo.set_active_text (grid_strings.front());
78 set_popdown_strings (end_grid_combo, grid_strings);
79 end_grid_combo.set_active_text (grid_strings.front());
81 set_popdown_strings (type_combo, type_strings);
82 type_combo.set_active_text (type_strings.front());
84 get_vbox()->set_border_width (12);
88 hbox = manage (new HBox);
89 hbox->set_spacing (12);
90 hbox->set_border_width (6);
91 hbox->pack_start (type_label);
92 hbox->pack_start (type_combo);
96 get_vbox()->pack_start (*hbox);
98 hbox = manage (new HBox);
99 hbox->set_spacing (12);
100 hbox->set_border_width (6);
101 hbox->pack_start (snap_start_button);
102 hbox->pack_start (start_grid_combo);
104 snap_start_button.show ();
105 start_grid_combo.show ();
106 get_vbox()->pack_start (*hbox);
108 hbox = manage (new HBox);
109 hbox->set_spacing (12);
110 hbox->set_border_width (6);
111 hbox->pack_start (snap_end_button);
112 hbox->pack_start (end_grid_combo);
114 snap_end_button.show ();
115 end_grid_combo.show ();
116 get_vbox()->pack_start (*hbox);
118 hbox = manage (new HBox);
119 hbox->set_spacing (12);
120 hbox->set_border_width (6);
121 hbox->pack_start (threshold_label);
122 hbox->pack_start (threshold_spinner);
124 threshold_label.show ();
125 threshold_spinner.show ();
126 get_vbox()->pack_start (*hbox);
128 hbox = manage (new HBox);
129 hbox->set_spacing (12);
130 hbox->set_border_width (6);
131 hbox->pack_start (strength_label);
132 hbox->pack_start (strength_spinner);
134 strength_label.show ();
135 strength_spinner.show ();
136 get_vbox()->pack_start (*hbox);
138 hbox = manage (new HBox);
139 hbox->set_spacing (12);
140 hbox->set_border_width (6);
141 hbox->pack_start (swing_button);
142 hbox->pack_start (swing_spinner);
144 swing_button.show ();
145 swing_spinner.show ();
146 get_vbox()->pack_start (*hbox);
148 snap_start_button.set_active (true);
149 snap_end_button.set_active (false);
152 QuantizeDialog::~QuantizeDialog()
157 QuantizeDialog::start_grid_size () const
159 return grid_size_to_musical_time (start_grid_combo.get_active_text ());
163 QuantizeDialog::end_grid_size () const
165 return grid_size_to_musical_time (start_grid_combo.get_active_text ());
169 QuantizeDialog::grid_size_to_musical_time (const string& txt) const
171 if (txt == "main_grid") {
174 Evoral::MusicalTime b = editor.get_grid_type_as_beats (success, 0);
181 if (txt == _("Beats/128")) {
183 } else if (txt == _("Beats/64")) {
185 } else if (txt == _("Beats/32")) {
187 } else if (txt == _("Beats/16")) {
189 } if (txt == _("Beats/8")) {
191 } else if (txt == _("Beats/4")) {
193 } else if (txt == _("Beats/3")) {
195 } else if (txt == _("Beats")) {
203 QuantizeDialog::swing () const
205 if (!swing_button.get_active()) {
209 return swing_adjustment.get_value ();
213 QuantizeDialog::strength () const
215 return strength_adjustment.get_value ();
219 QuantizeDialog::threshold () const
221 return threshold_adjustment.get_value ();