Struct musical_keyboard::MusicalKeyboard
[−]
[src]
pub struct MusicalKeyboard { pub octave: Octave, pub velocity: Velocity, pub currently_pressed_keys: HashMap<Key, Octave>, }
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.
currently_pressed_keys: HashMap<Key, Octave>
The currently pressed keys.
Methods
impl MusicalKeyboard
[src]
fn new(octave: Octave, velocity: Velocity) -> Self
Constructor for MusicalKeyboard.
fn key_pressed(&mut self, key: Key) -> Option<NoteOn>
Return a NoteOn given some pressed key.
- Z will step the octave down.
- X will step the octave up.
- C will step the velocity down.
- V will step the velocity up.
- Home-row and some of the top row will trigger notes or release them depending on is_pressed.
fn key_released(&mut self, key: Key) -> Option<NoteOff>
Return a NoteOff given some released key.
fn maybe_note(&mut 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(&mut self, key: Key) -> Option<NoteOn>
Translates a pressed key to a note on event.
If the given key is already pressed, it is ignored. This helps to avoid triggering notes from a window's key-repeat function.
fn maybe_note_off(&mut self, key: Key) -> Option<NoteOff>
Translates a released key to a note off event.
Trait Implementations
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