22 #include <gtkmm/stock.h>
39 , bpm_adjustment (60.0, 1.0, 999.9, 0.1, 1.0)
40 , bpm_spinner (bpm_adjustment)
41 , when_bar_label (
_(
"bar:"), ALIGN_LEFT, ALIGN_CENTER)
42 , when_beat_label (
_(
"beat:"), ALIGN_LEFT, ALIGN_CENTER)
43 , pulse_selector_label (
_(
"Pulse note"), ALIGN_LEFT, ALIGN_CENTER)
44 , tap_tempo_button (
_(
"Tap tempo"))
46 Timecode::BBT_Time when;
50 init (when, tempo.beats_per_minute(), tempo.note_type(),
true);
55 , bpm_adjustment (60.0, 1.0, 999.9, 0.1, 1.0)
56 , bpm_spinner (bpm_adjustment)
57 , when_bar_label (
_(
"bar:"), ALIGN_LEFT, ALIGN_CENTER)
58 , when_beat_label (
_(
"beat:"), ALIGN_LEFT, ALIGN_CENTER)
59 , pulse_selector_label (
_(
"Pulse note"), ALIGN_LEFT, ALIGN_CENTER)
60 , tap_tempo_button (
_(
"Tap tempo"))
66 TempoDialog::init (
const Timecode::BBT_Time& when,
double bpm,
double note_type,
bool movable)
68 vector<string> strings;
69 NoteTypes::iterator x;
78 strings.push_back (
_(
"whole"));
80 strings.push_back (
_(
"second"));
82 strings.push_back (
_(
"third"));
84 strings.push_back (
_(
"quarter"));
86 strings.push_back (
_(
"eighth"));
87 note_types.insert (make_pair (
_(
"sixteenth"), 16.0));
88 strings.push_back (
_(
"sixteenth"));
89 note_types.insert (make_pair (
_(
"thirty-second"), 32.0));
90 strings.push_back (
_(
"thirty-second"));
91 note_types.insert (make_pair (
_(
"sixty-fourth"), 64.0));
92 strings.push_back (
_(
"sixty-fourth"));
93 note_types.insert (make_pair (
_(
"one-hundred-twenty-eighth"), 128.0));
94 strings.push_back (
_(
"one-hundred-twenty-eighth"));
99 if (x->second == note_type) {
112 table = manage (
new Table (5, 5));
114 table = manage (
new Table (5, 4));
117 table->set_spacings (6);
118 table->set_homogeneous (
false);
121 Label* bpm_label = manage (
new Label(
_(
"Beats per minute:"), ALIGN_LEFT, ALIGN_CENTER));
122 table->attach (*bpm_label, 0, 1, 0, 1);
135 snprintf (buf,
sizeof (buf),
"%" PRIu32, when.bars);
137 snprintf (buf,
sizeof (buf),
"%" PRIu32, when.beats);
149 table->attach (
when_bar_label, 1, 2, row, row+1, Gtk::AttachOptions(0), Gtk::AttachOptions(0));
150 table->attach (
when_bar_entry, 2, 3, row, row+1, Gtk::AttachOptions(0), Gtk::AttachOptions(0));
152 table->attach (
when_beat_label, 3, 4, row, row+1, Gtk::AttachOptions(0), Gtk::AttachOptions(0));
153 table->attach (
when_beat_entry, 4, 5, row, row+1, Gtk::AttachOptions(0), Gtk::AttachOptions(0));
155 Label* when_label = manage (
new Label(
_(
"Tempo begins at"), ALIGN_LEFT, ALIGN_CENTER));
156 table->attach (*when_label, 0, 1, row, row+1);
159 get_vbox()->set_border_width (12);
160 get_vbox()->pack_end (*table);
163 add_button (Stock::CANCEL, RESPONSE_CANCEL);
164 add_button (Stock::APPLY, RESPONSE_ACCEPT);
165 set_response_sensitive (RESPONSE_ACCEPT,
true);
166 set_default_response (RESPONSE_ACCEPT);
173 set_name (
"MetricDialog");
175 bpm_spinner.signal_activate().connect (sigc::bind (sigc::mem_fun (*
this, &TempoDialog::response), RESPONSE_ACCEPT));
179 when_bar_entry.signal_activate().connect (sigc::bind (sigc::mem_fun (*
this, &TempoDialog::response), RESPONSE_ACCEPT));
181 when_beat_entry.signal_activate().connect (sigc::bind (sigc::mem_fun (*
this, &TempoDialog::response), RESPONSE_ACCEPT));
235 if (sscanf (
when_bar_entry.get_text().c_str(),
"%" PRIu32, &requested.bars) != 1) {
239 if (sscanf (
when_beat_entry.get_text().c_str(),
"%" PRIu32, &requested.beats) != 1) {
271 now = g_get_monotonic_time ();
274 double interval, bpm;
275 static const double decay = 0.5;
277 interval = (now -
last_tap) * 1.0e-6;
278 if (interval <= 6.0) {
317 Timecode::BBT_Time when;
322 init (when, meter.divisions_per_bar(), meter.note_divisor(),
true);
336 NoteTypes::iterator x;
338 snprintf (buf,
sizeof (buf),
"%.2f", bpb);
344 strings.push_back (
_(
"whole"));
346 strings.push_back (
_(
"second"));
348 strings.push_back (
_(
"third"));
350 strings.push_back (
_(
"quarter"));
352 strings.push_back (
_(
"eighth"));
353 note_types.insert (make_pair (
_(
"sixteenth"), 16.0));
354 strings.push_back (
_(
"sixteenth"));
355 note_types.insert (make_pair (
_(
"thirty-second"), 32.0));
356 strings.push_back (
_(
"thirty-second"));
357 note_types.insert (make_pair (
_(
"sixty-fourth"), 64.0));
358 strings.push_back (
_(
"sixty-fourth"));
359 note_types.insert (make_pair (
_(
"one-hundred-twenty-eighth"), 128.0));
360 strings.push_back (
_(
"one-hundred-twenty-eighth"));
365 if (x->second == divisor) {
375 Label* note_label = manage (
new Label (
_(
"Note value:"), ALIGN_LEFT, ALIGN_CENTER));
376 Label* bpb_label = manage (
new Label (
_(
"Beats per bar:"), ALIGN_LEFT, ALIGN_CENTER));
377 Table* table = manage (
new Table (3, 2));
378 table->set_spacings (6);
380 table->attach (*bpb_label, 0, 1, 0, 1, FILL|EXPAND, FILL|EXPAND);
381 table->attach (
bpb_entry, 1, 2, 0, 1, FILL|EXPAND, FILL|EXPAND);
382 table->attach (*note_label, 0, 1, 1, 2, FILL|EXPAND, FILL|EXPAND);
383 table->attach (
note_type, 1, 2, 1, 2, FILL|EXPAND, SHRINK);
385 snprintf (buf,
sizeof (buf),
"%" PRIu32, when.bars);
390 Label* when_label = manage (
new Label(
_(
"Meter begins at bar:"), ALIGN_LEFT, ALIGN_CENTER));
392 table->attach (*when_label, 0, 1, 2, 3, FILL | EXPAND, FILL | EXPAND);
393 table->attach (
when_bar_entry, 1, 2, 2, 3, FILL | EXPAND, FILL | EXPAND);
396 get_vbox()->set_border_width (12);
397 get_vbox()->pack_start (*table,
false,
false);
399 add_button (Stock::CANCEL, RESPONSE_CANCEL);
400 add_button (Stock::APPLY, RESPONSE_ACCEPT);
401 set_response_sensitive (RESPONSE_ACCEPT,
true);
402 set_default_response (RESPONSE_ACCEPT);
404 get_vbox()->show_all ();
406 set_name (
"MetricDialog");
407 bpb_entry.signal_activate().connect (sigc::bind (sigc::mem_fun (*
this, &MeterDialog::response), RESPONSE_ACCEPT));
410 when_bar_entry.signal_activate().connect (sigc::bind (sigc::mem_fun (*
this, &MeterDialog::response), RESPONSE_ACCEPT));
428 switch (ev->keyval) {
490 if (sscanf (
bpb_entry.get_text().c_str(),
"%lf", &bpb) != 1) {
513 if (sscanf (
when_bar_entry.get_text().c_str(),
"%" PRIu32, &requested.bars) != 1) {
void init(bool wait_for_waves)
Gtk::Entry when_bar_entry
bool bpm_button_press(GdkEventButton *)
void bbt_time(framepos_t when, Timecode::BBT_Time &)
TempoDialog(ARDOUR::TempoMap &, framepos_t, const std::string &action)
bool tap_tempo_focus_out(GdkEventFocus *)
bool entry_key_release(GdkEventKey *)
LIBPBD_API Transmitter error
std::ostream & endmsg(std::ostream &ostr)
LIBGTKMM2EXT_API void set_popdown_strings(Gtk::ComboBoxText &, const std::vector< std::string > &)
framepos_t round_to_bar(framepos_t frame, RoundMode dir)
bool bpm_button_release(GdkEventButton *)
const Meter & meter_at(framepos_t) const
bool is_user_input_valid() const
const Timecode::BBT_Time & start() const
bool get_bbt_time(Timecode::BBT_Time &)
bool entry_key_press(GdkEventKey *)
Gtk::Label when_beat_label
Gtk::ComboBoxText note_type
Gtk::Entry when_bar_entry
bool entry_key_release(GdkEventKey *)
Gtk::SpinButton bpm_spinner
Gtk::Button tap_tempo_button
double note_divisor() const
Gtk::Label pulse_selector_label
double beats_per_minute() const
Gtk::Label when_bar_label
Gtk::ComboBoxText pulse_selector
static UIConfiguration * config()
bool get_bbt_time(Timecode::BBT_Time &)
double divisions_per_bar() const
bool tap_tempo_button_press(GdkEventButton *)
MeterDialog(ARDOUR::TempoMap &, framepos_t, const std::string &action)
std::vector< std::string > strings
Gtk::Entry when_beat_entry
const Tempo & tempo_at(framepos_t) const
std::string string_compose(const std::string &fmt, const T1 &o1)
bool is_user_input_valid() const