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 <gtkmm/stock.h>
21 #include "gtkmm2ext/utils.h"
23 #include "quantize_dialog.h"
24 #include "public_editor.h"
30 using namespace Gtkmm2ext;
31 using namespace ARDOUR;
33 static const gchar *_grid_strings[] = {
46 static const gchar *_type_strings[] = {
53 std::vector<std::string> QuantizeDialog::grid_strings;
54 std::vector<std::string> QuantizeDialog::type_strings;
56 QuantizeDialog::QuantizeDialog (PublicEditor& e)
57 : ArdourDialog (_("Quantize"), false, false)
59 , type_label (_("Quantize Type"))
60 , strength_adjustment (100.0, 0.0, 100.0, 1.0, 10.0)
61 , strength_spinner (strength_adjustment)
62 , strength_label (_("Strength"))
63 , swing_adjustment (100.0, -130.0, 130.0, 1.0, 10.0)
64 , swing_spinner (swing_adjustment)
65 , swing_button (_("Swing"))
66 , threshold_adjustment (0.0, -1920.0, 1920.0, 1.0, 10.0) // XXX MAGIC TICK NUMBER FIX ME
67 , threshold_spinner (threshold_adjustment)
68 , threshold_label (_("Threshold (ticks)"))
69 , snap_start_button (_("Snap note start"))
70 , snap_end_button (_("Snap note end"))
72 if (grid_strings.empty()) {
73 grid_strings = I18N (_grid_strings);
74 type_strings = I18N (_type_strings);
77 set_popdown_strings (start_grid_combo, grid_strings);
78 start_grid_combo.set_active_text (grid_strings.front());
79 set_popdown_strings (end_grid_combo, grid_strings);
80 end_grid_combo.set_active_text (grid_strings.front());
82 set_popdown_strings (type_combo, type_strings);
83 type_combo.set_active_text (type_strings.front());
85 get_vbox()->set_border_width (12);
89 hbox = manage (new HBox);
90 hbox->set_spacing (12);
91 hbox->set_border_width (6);
92 hbox->pack_start (type_label);
93 hbox->pack_start (type_combo);
97 get_vbox()->pack_start (*hbox);
99 hbox = manage (new HBox);
100 hbox->set_spacing (12);
101 hbox->set_border_width (6);
102 hbox->pack_start (snap_start_button);
103 hbox->pack_start (start_grid_combo);
105 snap_start_button.show ();
106 start_grid_combo.show ();
107 get_vbox()->pack_start (*hbox);
109 hbox = manage (new HBox);
110 hbox->set_spacing (12);
111 hbox->set_border_width (6);
112 hbox->pack_start (snap_end_button);
113 hbox->pack_start (end_grid_combo);
115 snap_end_button.show ();
116 end_grid_combo.show ();
117 get_vbox()->pack_start (*hbox);
119 hbox = manage (new HBox);
120 hbox->set_spacing (12);
121 hbox->set_border_width (6);
122 hbox->pack_start (threshold_label);
123 hbox->pack_start (threshold_spinner);
125 threshold_label.show ();
126 threshold_spinner.show ();
127 get_vbox()->pack_start (*hbox);
129 hbox = manage (new HBox);
130 hbox->set_spacing (12);
131 hbox->set_border_width (6);
132 hbox->pack_start (strength_label);
133 hbox->pack_start (strength_spinner);
135 strength_label.show ();
136 strength_spinner.show ();
137 get_vbox()->pack_start (*hbox);
139 hbox = manage (new HBox);
140 hbox->set_spacing (12);
141 hbox->set_border_width (6);
142 hbox->pack_start (swing_button);
143 hbox->pack_start (swing_spinner);
145 swing_button.show ();
146 swing_spinner.show ();
147 get_vbox()->pack_start (*hbox);
149 snap_start_button.set_active (true);
150 snap_end_button.set_active (false);
152 add_button (Stock::CANCEL, RESPONSE_CANCEL);
153 add_button (Stock::OK, RESPONSE_OK);
156 QuantizeDialog::~QuantizeDialog()
161 QuantizeDialog::start_grid_size () const
163 return grid_size_to_musical_time (start_grid_combo.get_active_text ());
167 QuantizeDialog::end_grid_size () const
169 return grid_size_to_musical_time (start_grid_combo.get_active_text ());
173 QuantizeDialog::grid_size_to_musical_time (const string& txt) const
175 if (txt == "main_grid") {
178 Evoral::MusicalTime b = editor.get_grid_type_as_beats (success, 0);
185 if (txt == _("Beats/128")) {
187 } else if (txt == _("Beats/64")) {
189 } else if (txt == _("Beats/32")) {
191 } else if (txt == _("Beats/16")) {
193 } if (txt == _("Beats/8")) {
195 } else if (txt == _("Beats/4")) {
197 } else if (txt == _("Beats/3")) {
199 } else if (txt == _("Beats")) {
207 QuantizeDialog::swing () const
209 if (!swing_button.get_active()) {
213 return swing_adjustment.get_value ();
217 QuantizeDialog::strength () const
219 return strength_adjustment.get_value ();
223 QuantizeDialog::threshold () const
225 return threshold_adjustment.get_value ();