Ardour  9.0-pre0-582-g084a23a80d
virtual_keyboard_window.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Robin Gareus <robin@gareus.org>
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 along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef _virtual_keyboard_window_h_
20 #define _virtual_keyboard_window_h_
21 
22 #include <gtkmm/box.h>
23 #include <gtkmm/spinbutton.h>
24 
25 #include "pbd/controllable.h"
26 #include "pbd/signals.h"
27 
29 
30 #include "widgets/ardour_button.h"
32 #include "widgets/ardour_knob.h"
33 
34 #include "ardour_window.h"
35 #include "pianokeyboard.h"
36 
37 namespace ARDOUR {
38  class Session;
39 }
40 
41 namespace ArdourWidgets {
42  class VSliderController;
43 }
44 
46 {
47 public:
48  VKBDControl (const std::string& name, double normal = 127, double upper = 127)
49  : PBD::Controllable (name, Flag (0))
50  , _lower (0)
51  , _upper (upper)
52  , _normal (normal)
53  , _value (normal)
54  {}
55 
56  /* Controllable API */
58  {
59  if (v != _value) {
60  _value = std::max (_lower, std::min (_upper, v));
61  Changed (true, gcd); /* EMIT SIGNAL */
62  ValueChanged ((int)_value); /* EMIT SIGNAL */
63  }
64  }
65 
66  std::string get_user_string () const
67  {
68  char buf[32];
69  sprintf (buf, "%.0f", get_value ());
70  return std::string (buf);
71  }
72 
73  double get_value () const { return _value; }
74  double lower () const { return _lower; }
75  double upper () const { return _upper; }
76  double normal () const { return _normal; }
77 
79 
80 protected:
81  double _lower;
82  double _upper;
83  double _normal;
84  double _value;
85 };
86 
88 {
89 public:
92 
94 
95  XMLNode& get_state () const;
96  void set_state (const XMLNode&);
97 
98 protected:
100 
101 private:
102  void on_unmap ();
105 
106  void parameter_changed (std::string const&);
107 
108  void note_on_event_handler (int, int);
112 
115 
120 
122  void pitch_bend_release (int);
125 
126  void select_keyboard_layout (std::string const&);
130  void cc_key_changed (size_t);
131  void update_cc (size_t, int);
134 
136 
143 
144  std::shared_ptr<VKBDControl> _pitchbend;
148 
149  std::shared_ptr<VKBDControl> _modwheel;
153 #define VKBD_NCTRLS 4
154 
155  std::shared_ptr<VKBDControl> _cc[VKBD_NCTRLS];
158 
160 
161  sigc::connection _bender_connection;
163 };
164 
165 #endif
Controllable(const std::string &name, Flag f=Flag(0))
std::string name() const
Definition: controllable.h:154
PBD::Signal< void(bool, PBD::Controllable::GroupControlDisposition)> Changed
Definition: controllable.h:149
PBD::Signal< void(int)> ValueChanged
double lower() const
double normal() const
void set_value(double v, PBD::Controllable::GroupControlDisposition gcd)
double get_value() const
VKBDControl(const std::string &name, double normal=127, double upper=127)
std::string get_user_string() const
double upper() const
bool on_key_press_event(GdkEventKey *)
This is a default handler for the signal signal_key_press_event().
PBD::ScopedConnectionList _cc_connections
sigc::connection _bender_connection
void control_change_knob_event_handler(int, int)
void parameter_changed(std::string const &)
void velocity_key_event_handler(int)
void octave_key_event_handler(bool)
ArdourWidgets::ArdourDropdown _midi_channel
void pitch_bend_key_event_handler(int, bool)
void cc_key_changed(size_t)
Gtk::Adjustment _modwheel_adjustment
ArdourWidgets::ArdourKnob * _cc_knob[4]
bool send_panic_message(GdkEventButton *)
void pitch_bend_update_tooltip(int)
ArdourWidgets::ArdourDropdown _piano_octave_range
void pitch_bend_release(int)
void update_cc(size_t, int)
ArdourWidgets::ArdourDropdown _piano_octave_key
void select_keyboard_layout(std::string const &)
std::shared_ptr< VKBDControl > _cc[4]
ArdourWidgets::ArdourButton _send_panic
bool on_key_release_event(GdkEventKey *)
This is a default handler for the signal signal_key_release_event().
ArdourWidgets::ArdourDropdown _transpose_output
void set_session(ARDOUR::Session *)
ArdourWidgets::VSliderController * _pitch_slider
void set_state(const XMLNode &)
Gtkmm2ext::PersistentTooltip * _modwheel_tooltip
void modwheel_update_tooltip(int)
ArdourWidgets::ArdourDropdown _cc_key[4]
void note_off_event_handler(int)
void control_change_event_handler(int, int)
void pitch_bend_event_handler(int)
std::shared_ptr< VKBDControl > _modwheel
Gtkmm2ext::PersistentTooltip * _pitch_slider_tooltip
ArdourWidgets::VSliderController * _modwheel_slider
void note_on_event_handler(int, int)
void on_unmap()
This is a default handler for the signal signal_unmap().
std::shared_ptr< VKBDControl > _pitchbend
bool on_velocity_scroll_event(GdkEventScroll *)
bool on_focus_in_event(GdkEventFocus *)
This is a default handler for the signal signal_focus_in_event().
ArdourWidgets::ArdourDropdown _piano_velocity
XMLNode & get_state() const
Definition: xml++.h:114
Definition: axis_view.h:42
#define VKBD_NCTRLS