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 "pbd/convert.h"
24 #include "quantize_dialog.h"
25 #include "public_editor.h"
31 using namespace Gtkmm2ext
;
32 using namespace ARDOUR
;
34 static const gchar
*_grid_strings
[] = {
47 static const gchar
*_type_strings
[] = {
54 std::vector
<std::string
> QuantizeDialog::grid_strings
;
55 std::vector
<std::string
> QuantizeDialog::type_strings
;
57 QuantizeDialog::QuantizeDialog (PublicEditor
& e
)
58 : ArdourDialog (_("Quantize"), false, false)
60 , type_label (_("Quantize Type"))
61 , strength_adjustment (100.0, 0.0, 100.0, 1.0, 10.0)
62 , strength_spinner (strength_adjustment
)
63 , strength_label (_("Strength"))
64 , swing_adjustment (100.0, -130.0, 130.0, 1.0, 10.0)
65 , swing_spinner (swing_adjustment
)
66 , swing_button (_("Swing"))
67 , threshold_adjustment (0.0, -1920.0, 1920.0, 1.0, 10.0) // XXX MAGIC TICK NUMBER FIX ME
68 , threshold_spinner (threshold_adjustment
)
69 , threshold_label (_("Threshold (ticks)"))
70 , snap_start_button (_("Snap note start"))
71 , snap_end_button (_("Snap note end"))
73 if (grid_strings
.empty()) {
74 grid_strings
= I18N (_grid_strings
);
75 type_strings
= I18N (_type_strings
);
78 set_popdown_strings (start_grid_combo
, grid_strings
);
79 start_grid_combo
.set_active_text (grid_strings
.front());
80 set_popdown_strings (end_grid_combo
, grid_strings
);
81 end_grid_combo
.set_active_text (grid_strings
.front());
83 set_popdown_strings (type_combo
, type_strings
);
84 type_combo
.set_active_text (type_strings
.front());
86 get_vbox()->set_border_width (12);
90 hbox
= manage (new HBox
);
91 hbox
->set_spacing (12);
92 hbox
->set_border_width (6);
93 hbox
->pack_start (type_label
);
94 hbox
->pack_start (type_combo
);
98 get_vbox()->pack_start (*hbox
);
100 hbox
= manage (new HBox
);
101 hbox
->set_spacing (12);
102 hbox
->set_border_width (6);
103 hbox
->pack_start (snap_start_button
);
104 hbox
->pack_start (start_grid_combo
);
106 snap_start_button
.show ();
107 start_grid_combo
.show ();
108 get_vbox()->pack_start (*hbox
);
110 hbox
= manage (new HBox
);
111 hbox
->set_spacing (12);
112 hbox
->set_border_width (6);
113 hbox
->pack_start (snap_end_button
);
114 hbox
->pack_start (end_grid_combo
);
116 snap_end_button
.show ();
117 end_grid_combo
.show ();
118 get_vbox()->pack_start (*hbox
);
120 hbox
= manage (new HBox
);
121 hbox
->set_spacing (12);
122 hbox
->set_border_width (6);
123 hbox
->pack_start (threshold_label
);
124 hbox
->pack_start (threshold_spinner
);
126 threshold_label
.show ();
127 threshold_spinner
.show ();
128 get_vbox()->pack_start (*hbox
);
130 hbox
= manage (new HBox
);
131 hbox
->set_spacing (12);
132 hbox
->set_border_width (6);
133 hbox
->pack_start (strength_label
);
134 hbox
->pack_start (strength_spinner
);
136 strength_label
.show ();
137 strength_spinner
.show ();
138 get_vbox()->pack_start (*hbox
);
140 hbox
= manage (new HBox
);
141 hbox
->set_spacing (12);
142 hbox
->set_border_width (6);
143 hbox
->pack_start (swing_button
);
144 hbox
->pack_start (swing_spinner
);
146 swing_button
.show ();
147 swing_spinner
.show ();
148 get_vbox()->pack_start (*hbox
);
150 snap_start_button
.set_active (true);
151 snap_end_button
.set_active (false);
153 add_button (Stock::CANCEL
, RESPONSE_CANCEL
);
154 add_button (Stock::OK
, RESPONSE_OK
);
157 QuantizeDialog::~QuantizeDialog()
162 QuantizeDialog::start_grid_size () const
164 return grid_size_to_musical_time (start_grid_combo
.get_active_text ());
168 QuantizeDialog::end_grid_size () const
170 return grid_size_to_musical_time (start_grid_combo
.get_active_text ());
174 QuantizeDialog::grid_size_to_musical_time (const string
& txt
) const
176 if (txt
== "main grid") {
179 Evoral::MusicalTime b
= editor
.get_grid_type_as_beats (success
, 0);
186 if (txt
== _("Beats/128")) {
188 } else if (txt
== _("Beats/64")) {
190 } else if (txt
== _("Beats/32")) {
192 } else if (txt
== _("Beats/16")) {
194 } if (txt
== _("Beats/8")) {
196 } else if (txt
== _("Beats/4")) {
198 } else if (txt
== _("Beats/3")) {
200 } else if (txt
== _("Beats")) {
208 QuantizeDialog::swing () const
210 if (!swing_button
.get_active()) {
214 return swing_adjustment
.get_value ();
218 QuantizeDialog::strength () const
220 return strength_adjustment
.get_value ();
224 QuantizeDialog::threshold () const
226 return threshold_adjustment
.get_value ();