Represents general musical note and allow to convert it, currently only to MIDI byte and back.
Basically, this crate just makes very good work on alteration and resolving enharmonical representation of midi notes, based on given key and scale.
At least, it works better, that built-in Reaper and MuseScore algorithms.
It uses Nederlanden language as string representation, as it is the most consistent and easy to use (and hard to mistake) note representation.
https://docs.rs/musical-note/
```Rust use musicalnote::{miditonote, Accidental, Key, NoteName, Octave, ResolvedNote, Scale}; let as3 = ResolvedNote::new(NoteName::A, Accidental::Flat, Octave::new(5), 68); asserteq!(ResolvedNote::fromstr("as3").unwrap(), as3); asserteq!(ResolvedNote::fromstr("Aes3").unwrap(), as3); let amoll = Key::new(NoteName::A, Accidental::White, Scale::Minor);
// automatically unwraps let adur = Key::from((&"a".tostring(), Scale::Major));
let dmoll = Key::fromstr("d", Scale::Minor).unwrap(); let ddur = Key::fromstr("d", Scale::Major).unwrap();
let fismoll = Key::fromstr("fis", Scale::Minor).unwrap(); let fisdur = Key::fromstr("fis", Scale::Major).unwrap();
let aisdur = Key::fromstr("ais", Scale::Major).unwrap(); let desmoll = Key::fromstr("des", Scale::Minor).unwrap(); // first test against idiot mistake: asserteq!( miditonote(60, Key::fromstr("c", Scale::Major).unwrap(), None), ResolvedNote::new(NoteName::C, Accidental::White, Octave::new(60 / 12), 60) );
// // test on Bb2 let midi = 58u8; asserteq!( miditonote(midi, dmoll, None), ResolvedNote::fromstr("bes2").unwrap() ); // // test against major alteration (VI♭) asserteq!( miditonote(midi, ddur, None), ResolvedNote::fromstr("bes2").unwrap() );
// // test against minor alteration (II♭) asserteq!( miditonote(midi, amoll, None), ResolvedNote::from_str("bes2").unwrap() ); ```