Make tap tempo use g_get_monotonic_time(), and fix minimum BPM
[ardour.git] / gtk2_ardour / tempo_dialog.h
1 /*
2     Copyright (C) 2000-2007 Paul Davis
3
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.
8
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.
13
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.
17
18 */
19
20 #ifndef __ardour_gtk_tempo_dialog_h__
21 #define __ardour_gtk_tempo_dialog_h__
22
23 #include <gtkmm/entry.h>
24 #include <gtkmm/frame.h>
25 #include <gtkmm/box.h>
26 #include <gtkmm/button.h>
27 #include <gtkmm/label.h>
28 #include <gtkmm/table.h>
29 #include <gtkmm/entry.h>
30 #include <gtkmm/spinbutton.h>
31 #include <gtkmm/comboboxtext.h>
32
33 #include "ardour/types.h"
34 #include "ardour/tempo.h"
35
36 #include "ardour_dialog.h"
37
38 class TempoDialog : public ArdourDialog
39 {
40 public:
41         TempoDialog (ARDOUR::TempoMap&, framepos_t, const std::string & action);
42         TempoDialog (ARDOUR::TempoSection&, const std::string & action);
43
44         double get_bpm ();
45         double get_note_type ();
46         bool   get_bbt_time (Timecode::BBT_Time&);
47
48 private:
49         void init (const Timecode::BBT_Time& start, double, double, bool);
50         void bpm_changed ();
51         bool bpm_button_press (GdkEventButton* );
52         bool bpm_button_release (GdkEventButton* );
53         bool entry_key_release (GdkEventKey* );
54         void pulse_change ();
55         void tap_tempo ();
56
57         typedef std::map<std::string,float> NoteTypes;
58         NoteTypes note_types;
59
60         gint64 last_tap;
61         double average_interval;
62
63         Gtk::ComboBoxText pulse_selector;
64         Gtk::Adjustment   bpm_adjustment;
65         Gtk::SpinButton   bpm_spinner;
66         Gtk::Entry   when_bar_entry;
67         Gtk::Entry   when_beat_entry;
68         Gtk::Label   when_bar_label;
69         Gtk::Label   when_beat_label;
70         Gtk::Label   pulse_selector_label;
71         Gtk::Button  tap_tempo_button;
72 };
73
74 class MeterDialog : public ArdourDialog
75 {
76 public:
77
78         MeterDialog (ARDOUR::TempoMap&, framepos_t, const std::string & action);
79         MeterDialog (ARDOUR::MeterSection&, const std::string & action);
80
81         double get_bpb ();
82         double get_note_type ();
83         bool   get_bbt_time (Timecode::BBT_Time&);
84
85 private:
86         void init (const Timecode::BBT_Time&, double, double, bool);
87         bool entry_key_press (GdkEventKey* );
88         bool entry_key_release (GdkEventKey* );
89         void note_type_change ();
90
91         typedef std::map<std::string,float> NoteTypes;
92         NoteTypes note_types;
93
94         Gtk::Entry   bpb_entry;
95         Gtk::ComboBoxText note_type;
96         std::vector<std::string> strings;
97         Gtk::Button  ok_button;
98         Gtk::Button  cancel_button;
99         Gtk::Entry   when_bar_entry;
100 };
101
102 #endif /* __ardour_gtk_tempo_dialog_h__ */