Provides a computer-keyboard-based MIDI input mechanism for the Vital standalone application.
More...
#include <synth_computer_keyboard.h>
|
| SynthComputerKeyboard ()=delete |
| Deleted default constructor to ensure that a SoundEngine and MidiKeyboardState are provided.
|
|
| SynthComputerKeyboard (vital::SoundEngine *synth, MidiKeyboardState *keyboard_state) |
| Constructs a SynthComputerKeyboard tied to a given Vital SoundEngine and MidiKeyboardState.
|
|
| ~SynthComputerKeyboard () |
| Destructor. Cleans up any resources.
|
|
void | changeKeyboardOffset (int new_offset) |
| Changes the base offset of the computer keyboard notes.
|
|
bool | keyPressed (const KeyPress &key, Component *origin) override |
| Called when a key is pressed.
|
|
bool | keyStateChanged (bool isKeyDown, Component *origin) override |
| Called when a key state changes (pressed or released).
|
|
| StringLayout () |
| Constructs a StringLayout with no keys and an empty layout.
|
|
std::wstring | getLayout () |
| Retrieves the current keyboard layout (a wstring of character-to-note mappings).
|
|
void | setLayout (const std::wstring &layout) |
| Sets the current keyboard layout.
|
|
wchar_t | getUpKey () |
| Gets the character assigned to increase the octave.
|
|
void | setUpKey (wchar_t up_key) |
| Sets the character assigned to increase the octave.
|
|
wchar_t | getDownKey () |
| Gets the character assigned to decrease the octave.
|
|
void | setDownKey (wchar_t down_key) |
| Sets the character assigned to decrease the octave.
|
|
|
static constexpr int | kKeyboardMidiChannel = 1 |
| The MIDI channel used for the computer keyboard input.
|
|
|
std::wstring | layout_ |
| The mapping of keys to notes.
|
|
int | up_key_ |
| The key code (wchar_t) for octave up.
|
|
int | down_key_ |
| The key code (wchar_t) for octave down.
|
|
Provides a computer-keyboard-based MIDI input mechanism for the Vital standalone application.
SynthComputerKeyboard maps certain keys on a computer keyboard to MIDI note on/off events, allowing users to play notes without a hardware MIDI controller. It also supports shifting the keyboard layout up and down octaves via dedicated keys.
This class implements JUCE's KeyListener interface to receive and respond to keyboard events.
◆ SynthComputerKeyboard() [1/2]
SynthComputerKeyboard::SynthComputerKeyboard |
( |
| ) |
|
|
delete |
Deleted default constructor to ensure that a SoundEngine and MidiKeyboardState are provided.
◆ SynthComputerKeyboard() [2/2]
SynthComputerKeyboard::SynthComputerKeyboard |
( |
vital::SoundEngine * | synth, |
|
|
MidiKeyboardState * | keyboard_state ) |
Constructs a SynthComputerKeyboard tied to a given Vital SoundEngine and MidiKeyboardState.
- Parameters
-
synth | A pointer to the Vital::SoundEngine, used to handle corrections in time and audio state. |
keyboard_state | A pointer to a MidiKeyboardState that tracks the active note on/off states. |
◆ ~SynthComputerKeyboard()
SynthComputerKeyboard::~SynthComputerKeyboard |
( |
| ) |
|
Destructor. Cleans up any resources.
◆ changeKeyboardOffset()
void SynthComputerKeyboard::changeKeyboardOffset |
( |
int | new_offset | ) |
|
Changes the base offset of the computer keyboard notes.
For example, shifting the keyboard up or down one octave changes which MIDI notes the keys trigger.
- Parameters
-
new_offset | The new keyboard offset in semitones (MIDI note numbers). |
◆ keyPressed()
bool SynthComputerKeyboard::keyPressed |
( |
const KeyPress & | key, |
|
|
Component * | origin ) |
|
override |
Called when a key is pressed.
- Parameters
-
key | The KeyPress representing the pressed key. |
origin | The Component that originated the event. |
- Returns
- True if the event was handled; false otherwise.
◆ keyStateChanged()
bool SynthComputerKeyboard::keyStateChanged |
( |
bool | isKeyDown, |
|
|
Component * | origin ) |
|
override |
Called when a key state changes (pressed or released).
This function detects when keys mapped to notes are pressed or released, and sends note-on or note-off messages to the synthesizer accordingly.
- Parameters
-
isKeyDown | True if a key is currently pressed; false if released. |
origin | The Component that originated the event. |
- Returns
- True if the event was handled; false otherwise.
◆ kKeyboardMidiChannel
int SynthComputerKeyboard::kKeyboardMidiChannel = 1 |
|
staticconstexpr |
The MIDI channel used for the computer keyboard input.
The documentation for this class was generated from the following files: