2019-10-17 21:50:52 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2019 Robin Gareus <robin@gareus.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _virtual_keyboard_window_h_
|
|
|
|
#define _virtual_keyboard_window_h_
|
|
|
|
|
2019-10-19 20:43:39 -04:00
|
|
|
#include <gtkmm/box.h>
|
2019-10-18 11:26:25 -04:00
|
|
|
#include <gtkmm/spinbutton.h>
|
|
|
|
|
|
|
|
#include "pbd/controllable.h"
|
2019-10-21 10:06:29 -04:00
|
|
|
#include "pbd/signals.h"
|
2019-10-18 11:26:25 -04:00
|
|
|
|
2019-10-20 12:29:23 -04:00
|
|
|
#include "gtkmm2ext/persistent_tooltip.h"
|
|
|
|
|
2019-10-18 11:26:25 -04:00
|
|
|
#include "widgets/ardour_button.h"
|
|
|
|
#include "widgets/ardour_dropdown.h"
|
|
|
|
#include "widgets/ardour_knob.h"
|
2019-10-20 12:29:23 -04:00
|
|
|
#include "widgets/slider_controller.h"
|
2019-10-18 11:26:25 -04:00
|
|
|
|
2019-10-17 21:50:52 -04:00
|
|
|
#include "ardour_window.h"
|
2019-10-25 12:01:08 -04:00
|
|
|
#include "pianokeyboard.h"
|
2019-10-17 21:50:52 -04:00
|
|
|
|
|
|
|
namespace ARDOUR {
|
|
|
|
class Session;
|
|
|
|
}
|
|
|
|
|
2019-10-21 10:06:29 -04:00
|
|
|
class VKBDControl : public PBD::Controllable
|
|
|
|
{
|
2019-10-18 11:26:25 -04:00
|
|
|
public:
|
2019-10-20 12:29:23 -04:00
|
|
|
VKBDControl (const std::string& name, double normal = 127, double upper = 127)
|
2019-10-21 10:06:29 -04:00
|
|
|
: PBD::Controllable (name, Flag (0))
|
2019-10-18 11:26:25 -04:00
|
|
|
, _lower (0)
|
2019-10-20 12:29:23 -04:00
|
|
|
, _upper (upper)
|
2019-10-18 11:26:25 -04:00
|
|
|
, _normal (normal)
|
|
|
|
, _value (normal)
|
|
|
|
{}
|
|
|
|
|
|
|
|
/* Controllable API */
|
2019-10-21 10:06:29 -04:00
|
|
|
void set_value (double v, PBD::Controllable::GroupControlDisposition gcd)
|
|
|
|
{
|
2019-10-18 11:26:25 -04:00
|
|
|
if (v != _value) {
|
|
|
|
_value = std::max (_lower, std::min (_upper, v));
|
2019-10-21 10:06:29 -04:00
|
|
|
Changed (true, gcd); /* EMIT SIGNAL */
|
2019-10-18 11:26:25 -04:00
|
|
|
ValueChanged ((int)_value); /* EMIT SIGNAL */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string get_user_string () const
|
|
|
|
{
|
|
|
|
char buf[32];
|
2019-10-21 10:06:29 -04:00
|
|
|
sprintf (buf, "%.0f", get_value ());
|
|
|
|
return std::string (buf);
|
2019-10-18 11:26:25 -04:00
|
|
|
}
|
|
|
|
|
2019-10-21 10:06:29 -04:00
|
|
|
double get_value () const { return _value; }
|
2019-10-18 11:26:25 -04:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2019-10-17 21:50:52 -04:00
|
|
|
class VirtualKeyboardWindow : public ArdourWindow
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
VirtualKeyboardWindow ();
|
|
|
|
~VirtualKeyboardWindow ();
|
|
|
|
|
2019-10-20 14:53:40 -04:00
|
|
|
void set_session (ARDOUR::Session*);
|
|
|
|
|
2022-04-06 23:56:45 -04:00
|
|
|
XMLNode& get_state () const;
|
2019-10-21 10:06:29 -04:00
|
|
|
void set_state (const XMLNode&);
|
2019-10-20 14:53:40 -04:00
|
|
|
|
2019-10-23 23:13:56 -04:00
|
|
|
protected:
|
|
|
|
bool on_focus_in_event (GdkEventFocus*);
|
|
|
|
|
2019-10-17 21:50:52 -04:00
|
|
|
private:
|
2019-10-19 20:43:39 -04:00
|
|
|
void on_unmap ();
|
|
|
|
bool on_key_press_event (GdkEventKey*);
|
2019-12-15 07:58:03 -05:00
|
|
|
bool on_key_release_event (GdkEventKey*);
|
2019-10-19 20:43:39 -04:00
|
|
|
|
2019-12-18 22:27:54 -05:00
|
|
|
void parameter_changed (std::string const&);
|
|
|
|
|
2019-10-21 10:06:29 -04:00
|
|
|
void note_on_event_handler (int, int);
|
2019-10-17 21:50:52 -04:00
|
|
|
void note_off_event_handler (int);
|
2019-10-18 11:26:25 -04:00
|
|
|
void control_change_event_handler (int, int);
|
2019-12-18 09:01:17 -05:00
|
|
|
void control_change_knob_event_handler (int, int);
|
|
|
|
|
|
|
|
void modwheel_update_tooltip (int);
|
|
|
|
void modwheel_slider_adjusted ();
|
2019-12-15 08:04:44 -05:00
|
|
|
|
2019-12-16 09:02:39 -05:00
|
|
|
void octave_key_event_handler (bool);
|
|
|
|
void pitch_bend_key_event_handler (int, bool);
|
|
|
|
bool pitch_bend_timeout ();
|
|
|
|
|
2019-10-20 12:29:23 -04:00
|
|
|
void pitch_bend_event_handler (int);
|
2019-12-15 07:58:03 -05:00
|
|
|
void pitch_bend_release ();
|
2019-12-15 08:04:44 -05:00
|
|
|
void pitch_bend_update_tooltip (int);
|
|
|
|
void pitch_slider_adjusted ();
|
2019-10-18 11:26:25 -04:00
|
|
|
|
2019-10-21 09:27:42 -04:00
|
|
|
void select_keyboard_layout (std::string const&);
|
2019-12-18 22:27:54 -05:00
|
|
|
void update_velocity_settings ();
|
2019-10-20 23:41:34 -04:00
|
|
|
void update_octave_key ();
|
|
|
|
void update_octave_range ();
|
2019-12-18 09:01:17 -05:00
|
|
|
void cc_key_changed (size_t);
|
|
|
|
void update_cc (size_t, int);
|
2019-10-19 20:43:39 -04:00
|
|
|
bool send_panic_message (GdkEventButton*);
|
2019-12-25 06:46:34 -05:00
|
|
|
bool on_velocity_scroll_event (GdkEventScroll*);
|
2019-10-17 21:50:52 -04:00
|
|
|
|
2019-10-25 12:01:08 -04:00
|
|
|
APianoKeyboard _piano;
|
2019-10-18 11:26:25 -04:00
|
|
|
|
2019-10-25 17:52:53 -04:00
|
|
|
ArdourWidgets::ArdourDropdown _midi_channel;
|
2019-12-24 12:15:09 -05:00
|
|
|
ArdourWidgets::ArdourDropdown _piano_velocity;
|
|
|
|
ArdourWidgets::ArdourDropdown _piano_octave_key;
|
|
|
|
ArdourWidgets::ArdourDropdown _piano_octave_range;
|
2019-10-25 17:52:53 -04:00
|
|
|
ArdourWidgets::ArdourDropdown _transpose_output;
|
2019-12-18 22:27:54 -05:00
|
|
|
ArdourWidgets::ArdourButton _send_panic;
|
2019-10-18 11:26:25 -04:00
|
|
|
|
2019-10-20 12:29:23 -04:00
|
|
|
boost::shared_ptr<VKBDControl> _pitchbend;
|
|
|
|
Gtk::Adjustment _pitch_adjustment;
|
|
|
|
ArdourWidgets::VSliderController* _pitch_slider;
|
|
|
|
Gtkmm2ext::PersistentTooltip* _pitch_slider_tooltip;
|
|
|
|
|
2019-12-18 09:01:17 -05:00
|
|
|
boost::shared_ptr<VKBDControl> _modwheel;
|
|
|
|
Gtk::Adjustment _modwheel_adjustment;
|
|
|
|
ArdourWidgets::VSliderController* _modwheel_slider;
|
|
|
|
Gtkmm2ext::PersistentTooltip* _modwheel_tooltip;
|
|
|
|
#define VKBD_NCTRLS 4
|
2019-10-19 20:43:39 -04:00
|
|
|
|
|
|
|
boost::shared_ptr<VKBDControl> _cc[VKBD_NCTRLS];
|
|
|
|
ArdourWidgets::ArdourKnob* _cc_knob[VKBD_NCTRLS];
|
|
|
|
ArdourWidgets::ArdourDropdown _cc_key[VKBD_NCTRLS];
|
2019-10-18 11:26:25 -04:00
|
|
|
|
|
|
|
PBD::ScopedConnectionList _cc_connections;
|
2019-12-16 09:02:39 -05:00
|
|
|
|
|
|
|
sigc::connection _bender_connection;
|
|
|
|
int _pitch_bend_target;
|
2019-10-17 21:50:52 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|