Vkeybd: Bind F5 to F8 keys to velocity

This commit is contained in:
Robin Gareus 2023-06-10 14:59:49 +02:00
parent a3e64445de
commit 322e7c328e
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
4 changed files with 26 additions and 0 deletions

View File

@ -315,6 +315,18 @@ APianoKeyboard::handle_fixed_keys (GdkEventKey* ev)
case GDK_KEY_F4:
PitchBend (16383, false);
return true;
case GDK_KEY_F5:
SetVelocity (32);
return true;
case GDK_KEY_F6:
SetVelocity (64);
return true;
case GDK_KEY_F7:
SetVelocity (96);
return true;
case GDK_KEY_F8:
SetVelocity (127);
return true;
case GDK_KEY_Down:
PitchBend (0, true);
return true;

View File

@ -38,6 +38,7 @@ public:
sigc::signal<void> Rest;
sigc::signal<void,bool> SustainChanged;
sigc::signal<void, int, bool> PitchBend;
sigc::signal<void, int> SetVelocity;
sigc::signal<void, bool> SwitchOctave;
void sustain_press ();

View File

@ -221,6 +221,7 @@ VirtualKeyboardWindow::VirtualKeyboardWindow ()
_piano.NoteOff.connect (sigc::mem_fun (*this, &VirtualKeyboardWindow::note_off_event_handler));
_piano.SwitchOctave.connect (sigc::mem_fun (*this, &VirtualKeyboardWindow::octave_key_event_handler));
_piano.PitchBend.connect (sigc::mem_fun (*this, &VirtualKeyboardWindow::pitch_bend_key_event_handler));
_piano.SetVelocity.connect (sigc::mem_fun (*this, &VirtualKeyboardWindow::velocity_key_event_handler));
/* initialize GUI */
@ -448,6 +449,17 @@ VirtualKeyboardWindow::update_cc (size_t i, int cc)
_cc_key[i].set_active (buf);
}
void
VirtualKeyboardWindow::velocity_key_event_handler (int v)
{
if (v < 1 || v > 127) {
return;
}
char buf[16];
sprintf (buf, "%d", v);
_piano_velocity.set_active (buf);
}
void
VirtualKeyboardWindow::octave_key_event_handler (bool up)
{

View File

@ -111,6 +111,7 @@ private:
void modwheel_slider_adjusted ();
void octave_key_event_handler (bool);
void velocity_key_event_handler (int);
void pitch_bend_key_event_handler (int, bool);
bool pitch_bend_timeout ();