Set mixbufs count in the case of a panner being used, as
[ardour2.git] / gtk2_ardour / quantize_dialog.cc
blob397eb23145d42a235c7fffd6d344dd119bbb62c7
1 /*
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 <gtkmm/table.h>
22 #include "gtkmm2ext/utils.h"
24 #include "pbd/convert.h"
25 #include "quantize_dialog.h"
26 #include "public_editor.h"
28 #include "i18n.h"
30 using namespace std;
31 using namespace Gtk;
32 using namespace Gtkmm2ext;
33 using namespace ARDOUR;
35 static const gchar *_grid_strings[] = {
36 N_("main grid"),
37 N_("Beats/128"),
38 N_("Beats/64"),
39 N_("Beats/32"),
40 N_("Beats/16"),
41 N_("Beats/8"),
42 N_("Beats/4"),
43 N_("Beats/3"),
44 N_("Beats/2"),
45 N_("Beats"),
49 static const gchar *_type_strings[] = {
50 N_("Grid"),
51 N_("Legato"),
52 N_("Groove"),
56 std::vector<std::string> QuantizeDialog::grid_strings;
57 std::vector<std::string> QuantizeDialog::type_strings;
59 QuantizeDialog::QuantizeDialog (PublicEditor& e)
60 : ArdourDialog (_("Quantize"), false, false)
61 , editor (e)
62 , type_label (_("Quantize Type"))
63 , strength_adjustment (100.0, 0.0, 100.0, 1.0, 10.0)
64 , strength_spinner (strength_adjustment)
65 , strength_label (_("Strength"))
66 , swing_adjustment (100.0, -130.0, 130.0, 1.0, 10.0)
67 , swing_spinner (swing_adjustment)
68 , swing_button (_("Swing"))
69 , threshold_adjustment (0.0, -1920.0, 1920.0, 1.0, 10.0) // XXX MAGIC TICK NUMBER FIX ME
70 , threshold_spinner (threshold_adjustment)
71 , threshold_label (_("Threshold (ticks)"))
72 , snap_start_button (_("Snap note start"))
73 , snap_end_button (_("Snap note end"))
75 if (grid_strings.empty()) {
76 grid_strings = I18N (_grid_strings);
77 type_strings = I18N (_type_strings);
80 set_popdown_strings (start_grid_combo, grid_strings);
81 start_grid_combo.set_active_text (grid_strings.front());
82 set_popdown_strings (end_grid_combo, grid_strings);
83 end_grid_combo.set_active_text (grid_strings.front());
85 set_popdown_strings (type_combo, type_strings);
86 type_combo.set_active_text (type_strings.front());
88 Table* table = manage (new Table (6, 2));
89 table->set_spacings (12);
90 table->set_border_width (12);
92 int r = 0;
94 type_label.set_alignment (0, 0.5);
95 table->attach (type_label, 0, 1, r, r + 1);
96 table->attach (type_combo, 1, 2, r, r + 1);
97 ++r;
99 table->attach (snap_start_button, 0, 1, r, r + 1);
100 table->attach (start_grid_combo, 1, 2, r, r + 1);
101 ++r;
103 table->attach (snap_end_button, 0, 1, r, r + 1);
104 table->attach (end_grid_combo, 1, 2, r, r + 1);
105 ++r;
107 threshold_label.set_alignment (0, 0.5);
108 table->attach (threshold_label, 0, 1, r, r + 1);
109 table->attach (threshold_spinner, 1, 2, r, r + 1);
110 ++r;
112 strength_label.set_alignment (0, 0.5);
113 table->attach (strength_label, 0, 1, r, r + 1);
114 table->attach (strength_spinner, 1, 2, r, r + 1);
115 ++r;
117 table->attach (swing_button, 0, 1, r, r + 1);
118 table->attach (swing_spinner, 1, 2, r, r + 1);
120 snap_start_button.set_active (true);
121 snap_end_button.set_active (false);
123 get_vbox()->pack_start (*table);
124 show_all ();
126 add_button (Stock::CANCEL, RESPONSE_CANCEL);
127 add_button (Stock::OK, RESPONSE_OK);
130 QuantizeDialog::~QuantizeDialog()
134 double
135 QuantizeDialog::start_grid_size () const
137 return grid_size_to_musical_time (start_grid_combo.get_active_text ());
140 double
141 QuantizeDialog::end_grid_size () const
143 return grid_size_to_musical_time (start_grid_combo.get_active_text ());
146 double
147 QuantizeDialog::grid_size_to_musical_time (const string& txt) const
149 if (txt == "main grid") {
150 bool success;
152 Evoral::MusicalTime b = editor.get_grid_type_as_beats (success, 0);
153 if (!success) {
154 return 1.0;
156 return (double) b;
159 if (txt == _("Beats/128")) {
160 return 1.0/128.0;
161 } else if (txt == _("Beats/64")) {
162 return 1.0/64.0;
163 } else if (txt == _("Beats/32")) {
164 return 1.0/32.0;
165 } else if (txt == _("Beats/16")) {
166 return 1.0/16.0;
167 } if (txt == _("Beats/8")) {
168 return 1.0/8.0;
169 } else if (txt == _("Beats/4")) {
170 return 1.0/4.0;
171 } else if (txt == _("Beats/3")) {
172 return 1.0/3.0;
173 } else if (txt == _("Beats/2")) {
174 return 1.0/2.0;
175 } else if (txt == _("Beats")) {
176 return 1.0;
179 return 1.0;
182 float
183 QuantizeDialog::swing () const
185 if (!swing_button.get_active()) {
186 return 0.0f;
189 return swing_adjustment.get_value ();
192 float
193 QuantizeDialog::strength () const
195 return strength_adjustment.get_value ();
198 float
199 QuantizeDialog::threshold () const
201 return threshold_adjustment.get_value ();