Crates.io | musical_keyboard |
lib.rs | musical_keyboard |
version | 0.6.0 |
source | src |
created_at | 2015-02-13 08:12:01.93806 |
updated_at | 2017-03-22 08:23:53.817056 |
description | A small lib for converting keyboard input into musical notes. |
homepage | https://github.com/RustAudio/musical_keyboard |
repository | https://github.com/RustAudio/musical_keyboard.git |
max_upload_size | |
id | 1399 |
size | 10,252 |
A small lib for converting keyboard input into musical notes.
extern crate musical_keyboard;
use musical_keyboard::{Letter, MusicalKeyboard, NoteEvent, Key};
fn main() {
let mut musical_keyboard = MusicalKeyboard::default();
let on = musical_keyboard.key_pressed(Key::A);
assert_eq!(Some(NoteOn { letter: Letter::C, octave: 2, velocity: 1.0 }), on);
musical_keyboard.key_pressed(Key::X);
let on = musical_keyboard.key_pressed(Key::D);
assert_eq!(Some(NoteOn { letter: Letter::E, octave: 3, velocity: 1.0 }), on);
let off = musical_keyboard.key_released(Key::D);
assert_eq!(Some(NoteOff { letter: Letter::E, octave: 3 }), off);
musical_keyboard.key_pressed(Key::C);
let on = musical_keyboard.key_pressed(Key::Semicolon);
assert_eq!(Some(NoteOn { letter: Letter::E, octave: 4, velocity: 0.95 }), on);
}
The behaviour is modelled on Logic Studio X's musical keyboard.
Licensed under either of
at your option.
Contributions
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.