diff options
author | Robin Gareus <robin@gareus.org> | 2019-10-18 17:26:25 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2019-10-18 22:56:46 +0200 |
commit | 19e4f47b4bd968be6471aa22f196bced33296568 (patch) | |
tree | 307865f945c777043c1d6e5eb5f49d96641b4c55 /gtk2_ardour/virtual_keyboard_window.h | |
parent | 148a9682be3fcf1c83c738287f875c9c629edbd1 (diff) |
Cont'd work on Virtual-keyboard
* allow gtk_pianokeyboard to respond to y-axis click position
and include MIDI velocity with note-on signal
* add configuration settings to virual-keyboard
min/max velocity, keyboard-layout
* add a CC7 controller knob
Diffstat (limited to 'gtk2_ardour/virtual_keyboard_window.h')
-rw-r--r-- | gtk2_ardour/virtual_keyboard_window.h | 78 |
1 files changed, 74 insertions, 4 deletions
diff --git a/gtk2_ardour/virtual_keyboard_window.h b/gtk2_ardour/virtual_keyboard_window.h index af09f74e89..9fa230de80 100644 --- a/gtk2_ardour/virtual_keyboard_window.h +++ b/gtk2_ardour/virtual_keyboard_window.h @@ -19,6 +19,15 @@ #ifndef _virtual_keyboard_window_h_ #define _virtual_keyboard_window_h_ +#include <gtkmm/spinbutton.h> + +#include "pbd/signals.h" +#include "pbd/controllable.h" + +#include "widgets/ardour_button.h" +#include "widgets/ardour_dropdown.h" +#include "widgets/ardour_knob.h" + #include "ardour_window.h" #include "gtk_pianokeyboard.h" @@ -26,6 +35,50 @@ namespace ARDOUR { class Session; } +class VKBDControl : public PBD::Controllable { +public: + VKBDControl (const std::string& name, double normal = 127) + : PBD::Controllable (name, Flag(0)) + , _lower (0) + , _upper (127) + , _normal (normal) + , _value (normal) + {} + + /* Controllable API */ + void set_value (double v, PBD::Controllable::GroupControlDisposition gcd) { + if (v != _value) { + _value = std::max (_lower, std::min (_upper, v)); + Changed (true, gcd); /* EMIT SIGNAL */ + ValueChanged ((int)_value); /* EMIT SIGNAL */ + } + } + + double get_value () const { + return _value; + } + + std::string get_user_string () const + { + char buf[32]; + sprintf (buf, "%.0f", get_value()); + return std::string(buf); + } + + double lower () const { return _lower; } + double upper () const { return _upper; } + double normal () const { return _normal; } + + PBD::Signal1<void, int> ValueChanged; + +protected: + double _lower; + double _upper; + double _normal; + double _value; +}; + + class VirtualKeyboardWindow : public ArdourWindow { public: @@ -37,9 +90,9 @@ protected: bool on_key_press_event (GdkEventKey*); private: - static void _note_on_event_handler (GtkWidget*, int note, gpointer arg) + static void _note_on_event_handler (GtkWidget*, int note, int vel, gpointer arg) { - static_cast<VirtualKeyboardWindow*>(arg)->note_on_event_handler(note); + static_cast<VirtualKeyboardWindow*>(arg)->note_on_event_handler(note, vel); } static void _note_off_event_handler (GtkWidget*, int note, gpointer arg) @@ -47,13 +100,30 @@ private: static_cast<VirtualKeyboardWindow*>(arg)->note_off_event_handler(note); } - void note_on_event_handler (int); + void note_on_event_handler (int, int); void note_off_event_handler (int); + void control_change_event_handler (int, int); + + void select_keyboard_layout (int); + void update_velocity_settings (int); + void update_sensitivity (); + bool yaxis_velocity_button_release (GdkEventButton* ev); PianoKeyboard* _piano; Gtk::Widget* _pianomm; - Gtk::SpinButton _piano_velocity; Gtk::SpinButton _piano_channel; + + ArdourWidgets::ArdourButton _yaxis_velocity; + ArdourWidgets::ArdourDropdown _keyboard_layout; + + Gtk::SpinButton _piano_key_velocity; + Gtk::SpinButton _piano_min_velocity; + Gtk::SpinButton _piano_max_velocity; + + boost::shared_ptr<VKBDControl> _cc7; + ArdourWidgets::ArdourKnob _cc7_knob; + + PBD::ScopedConnectionList _cc_connections; }; #endif |