musical_keyboard

Crates.iomusical_keyboard
lib.rsmusical_keyboard
version0.6.0
sourcesrc
created_at2015-02-13 08:12:01.93806
updated_at2017-03-22 08:23:53.817056
descriptionA small lib for converting keyboard input into musical notes.
homepagehttps://github.com/RustAudio/musical_keyboard
repositoryhttps://github.com/RustAudio/musical_keyboard.git
max_upload_size
id1399
size10,252
(mitchmindtree)

documentation

README

musical_keyboard Build Status Crates.io Crates.io docs.rs

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.

License

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.

Commit count: 24

cargo fmt