Struct musical_keyboard::MusicalKeyboard
[−]
[src]
pub struct MusicalKeyboard { pub octave: Octave, pub velocity: Velocity, pub is_active: bool, }
A struct used for creating musical Note
s via the computer keyboard.
Fields
octave: Octave
The current base octave for the keyboard.
velocity: Velocity
The current velocity for the generated notes.
is_active: bool
Whether or not the keyboard is currently active.
Methods
impl MusicalKeyboard
[src]
fn new(octave: Octave, velocity: Velocity, is_active: bool) -> MusicalKeyboard
Constructor for MusicalKeyboard.
fn default() -> MusicalKeyboard
Default constructor for MusicalKeyboard.
fn handle_input(&mut self, ctrl: bool, key: Key, is_pressed: bool) -> Option<NoteEvent>
Handle keyboard input. This will check the given key for the following: - Z will step the octave down. - X will step the octave up. - C will step the velocity down. - V will step the velocity up. - Ctrl + K will toggle the keyboard on and off. - Home-row and some of the top row will trigger notes or release them depending on is_pressed.
fn maybe_note(&self, key: Key) -> Option<(Letter, Octave)>
Translates a key into it's respective note. This key pattern is an attempt at modelling a piano's keys, where Key::A is a piano's C.
fn maybe_note_on(&self, key: Key) -> Option<NoteEvent>
Translates a pressed key to a note on event.
fn maybe_note_off(&self, key: Key) -> Option<NoteEvent>
Translates a released key to a note off event.
Trait Implementations
impl Debug for MusicalKeyboard
[src]
impl Clone for MusicalKeyboard
[src]
fn clone(&self) -> MusicalKeyboard
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more