Ardour  9.0-pre0-582-g084a23a80d
tempo_dialog.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2017 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2005 Karsten Wiese <fzuuzf@googlemail.com>
4  * Copyright (C) 2005 Taybin Rutkin <taybin@taybin.com>
5  * Copyright (C) 2008-2011 David Robillard <d@drobilla.net>
6  * Copyright (C) 2009-2010 Carl Hetherington <carl@carlh.net>
7  * Copyright (C) 2014-2015 Colin Fletcher <colin.m.fletcher@googlemail.com>
8  * Copyright (C) 2015-2017 Nick Mainsbridge <mainsbridge@gmail.com>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License along
21  * with this program; if not, write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  */
24 
25 #pragma once
26 
27 #include <gtkmm/entry.h>
28 #include <gtkmm/frame.h>
29 #include <gtkmm/box.h>
30 #include <gtkmm/button.h>
31 #include <gtkmm/label.h>
32 #include <gtkmm/liststore.h>
33 #include <gtkmm/table.h>
34 #include <gtkmm/entry.h>
35 #include <gtkmm/spinbutton.h>
36 #include <gtkmm/combobox.h>
37 #include <gtkmm/comboboxtext.h>
38 
39 #include "ardour/types.h"
40 #include "ardour/tempo.h"
41 #include "midi++/types.h"
42 
43 #include "ardour_dialog.h"
44 
45 namespace MIDI {
46  class Parser;
47 }
48 namespace ARDOUR {
49  class MidiPort;
50 }
51 
52 
53 class TempoDialog : public ArdourDialog
54 {
55 public:
56  TempoDialog (Temporal::TempoMap::SharedPtr const &, Temporal::timepos_t const & , const std::string & action);
57  TempoDialog (Temporal::TempoMap::SharedPtr const &, Temporal::TempoPoint&, const std::string & action);
59 
60  double get_bpm ();
61  double get_end_bpm ();
62  int get_note_type ();
66 
67  void on_show ();
68 
69 private:
70  void init (const Temporal::BBT_Time& start, double bpm, double end_bpm, double note_type, Temporal::TempoPoint::Type type, bool movable, Temporal::TimeDomain style);
71  bool is_user_input_valid() const;
72  void bpm_changed ();
76  void pulse_change ();
82  void port_changed ();
83  void ports_changed ();
84 
85  void tap_tempo (int64_t);
87 
88  typedef std::map<std::string,int> NoteTypes;
90 
91  typedef std::map<std::string, Temporal::Tempo::Type> TempoTypes;
93 
94  typedef std::map<std::string, Temporal::TimeDomain> LockStyles;
96 
97  bool tapped; // whether the tap-tempo button has been clicked
98  double sum_x, sum_xx, sum_xy, sum_y;
99  double tap_count;
100  double last_t;
101  gint64 first_t;
102 
105 
122 
124  {
125  public:
127  {
128  add (pretty_name);
129  add (port_name);
130  }
133  };
134 
136  Glib::RefPtr<Gtk::ListStore> _midi_port_list;
137 
139  std::shared_ptr<MIDI::Parser> _midi_tap_parser;
140  std::shared_ptr<ARDOUR::MidiPort> _midi_tap_port;
144  sigc::connection _port_changed_connection;
145 };
146 
147 class MeterDialog : public ArdourDialog
148 {
149 public:
150  MeterDialog (Temporal::TempoMap::SharedPtr const & , Temporal::timepos_t const &, const std::string & action);
151  MeterDialog (Temporal::MeterPoint&, const std::string & action);
152 
153  double get_bpb ();
157 
158 private:
159  void init (const Temporal::BBT_Time&, double, double, bool, bool, Temporal::TimeDomain style);
160  bool is_user_input_valid() const;
165 
166  typedef std::map<std::string,float> NoteTypes;
168 
169  typedef std::map<std::string, Temporal::TimeDomain> LockStyles;
171 
175  std::vector<std::string> strings;
179 };
180 
void add(TreeModelColumnBase &column)
LockStyles lock_styles
Definition: tempo_dialog.h:170
bool is_user_input_valid() const
bool get_bbt_time(Temporal::BBT_Time &)
bool entry_key_press(GdkEventKey *)
MeterDialog(Temporal::MeterPoint &, const std::string &action)
void note_type_change()
void lock_style_change()
Gtk::Entry bpb_entry
Definition: tempo_dialog.h:172
std::map< std::string, float > NoteTypes
Definition: tempo_dialog.h:166
Gtk::ComboBoxText lock_style
Definition: tempo_dialog.h:174
bool entry_key_release(GdkEventKey *)
NoteTypes note_types
Definition: tempo_dialog.h:167
Temporal::TimeDomain get_lock_style()
double get_bpb()
std::map< std::string, Temporal::TimeDomain > LockStyles
Definition: tempo_dialog.h:169
MeterDialog(Temporal::TempoMap::SharedPtr const &, Temporal::timepos_t const &, const std::string &action)
void init(const Temporal::BBT_Time &, double, double, bool, bool, Temporal::TimeDomain style)
Gtk::Entry when_bar_entry
Definition: tempo_dialog.h:178
int get_note_type()
Gtk::Button cancel_button
Definition: tempo_dialog.h:177
Gtk::ComboBoxText note_type
Definition: tempo_dialog.h:173
Gtk::Button ok_button
Definition: tempo_dialog.h:176
std::vector< std::string > strings
Definition: tempo_dialog.h:175
Gtk::TreeModelColumn< std::string > pretty_name
Definition: tempo_dialog.h:131
Gtk::TreeModelColumn< std::string > port_name
Definition: tempo_dialog.h:132
double get_bpm()
double tap_count
Definition: tempo_dialog.h:99
PBD::ScopedConnection _manager_connection
Definition: tempo_dialog.h:142
Gtk::SpinButton bpm_spinner
Definition: tempo_dialog.h:108
Glib::RefPtr< Gtk::ListStore > _midi_port_list
Definition: tempo_dialog.h:136
double sum_xy
Definition: tempo_dialog.h:98
Gtk::Label pulse_selector_label
Definition: tempo_dialog.h:116
TempoDialog(Temporal::TempoMap::SharedPtr const &, Temporal::timepos_t const &, const std::string &action)
Temporal::TempoMap::SharedPtr _map
Definition: tempo_dialog.h:103
double last_t
Definition: tempo_dialog.h:100
MidiPortCols _midi_port_cols
Definition: tempo_dialog.h:135
void midi_event(MIDI::byte *, size_t, MIDI::samplecnt_t)
TempoDialog(Temporal::TempoMap::SharedPtr const &, Temporal::TempoPoint &, const std::string &action)
void port_changed()
bool bpm_button_release(GdkEventButton *)
PBD::Signal< void(int64_t)> _midi_tap_signal
Definition: tempo_dialog.h:138
bool bpm_button_press(GdkEventButton *)
Gtk::SpinButton end_bpm_spinner
Definition: tempo_dialog.h:110
Gtk::ComboBoxText lock_style
Definition: tempo_dialog.h:120
Temporal::TempoPoint * _section
Definition: tempo_dialog.h:104
double sum_x
Definition: tempo_dialog.h:98
void tempo_type_change()
void on_show()
This is a default handler for the signal signal_show().
Gtk::Entry when_beat_entry
Definition: tempo_dialog.h:113
std::map< std::string, int > NoteTypes
Definition: tempo_dialog.h:88
void lock_style_change()
bool entry_key_release(GdkEventKey *)
double get_end_bpm()
bool is_user_input_valid() const
bool tap_tempo_button_press(GdkEventButton *)
void bpm_changed()
double sum_xx
Definition: tempo_dialog.h:98
PBD::ScopedConnection _parser_connection
Definition: tempo_dialog.h:141
Temporal::Tempo::Type get_tempo_type()
std::shared_ptr< MIDI::Parser > _midi_tap_parser
Definition: tempo_dialog.h:139
std::map< std::string, Temporal::Tempo::Type > TempoTypes
Definition: tempo_dialog.h:91
void tap_tempo(int64_t)
Temporal::TimeDomain get_lock_style()
Gtk::ComboBox _midi_port_combo
Definition: tempo_dialog.h:121
bool tap_tempo_key_press(GdkEventKey *)
void init(const Temporal::BBT_Time &start, double bpm, double end_bpm, double note_type, Temporal::TempoPoint::Type type, bool movable, Temporal::TimeDomain style)
Gtk::Entry when_bar_entry
Definition: tempo_dialog.h:112
Gtk::ComboBoxText tempo_type
Definition: tempo_dialog.h:119
Gtk::Label when_bar_label
Definition: tempo_dialog.h:114
std::shared_ptr< ARDOUR::MidiPort > _midi_tap_port
Definition: tempo_dialog.h:140
LockStyles lock_styles
Definition: tempo_dialog.h:95
void pulse_change()
void ports_changed()
PBD::ScopedConnection _xthread_connection
Definition: tempo_dialog.h:143
Gtk::ComboBoxText pulse_selector
Definition: tempo_dialog.h:106
Gtk::Label when_beat_label
Definition: tempo_dialog.h:115
Gtk::Label _end_bpm_label
Definition: tempo_dialog.h:111
Gtk::Label _tap_source_label
Definition: tempo_dialog.h:117
Gtk::Adjustment end_bpm_adjustment
Definition: tempo_dialog.h:109
int get_note_type()
Gtk::Adjustment bpm_adjustment
Definition: tempo_dialog.h:107
TempoTypes tempo_types
Definition: tempo_dialog.h:92
sigc::connection _port_changed_connection
Definition: tempo_dialog.h:144
bool get_bbt_time(Temporal::BBT_Time &)
double sum_y
Definition: tempo_dialog.h:98
gint64 first_t
Definition: tempo_dialog.h:101
NoteTypes note_types
Definition: tempo_dialog.h:89
bool tap_tempo_focus_out(GdkEventFocus *)
std::map< std::string, Temporal::TimeDomain > LockStyles
Definition: tempo_dialog.h:94
Gtk::Button tap_tempo_button
Definition: tempo_dialog.h:118
std::shared_ptr< TempoMap const > SharedPtr
PBD::PropertyDescriptor< timepos_t > start
int64_t samplecnt_t