Struct musical_note::NotesMap
source · pub struct NotesMap { /* private fields */ }Expand description
Effectively maps notes to midi and backwards.
Example
use musical_note::{NotesMap, NoteName, Accidental};
let map = NotesMap::get();
assert_eq!(map.get_by_note(NoteName::F, Accidental::DoubleFlat), 3);Implementations
sourceimpl NotesMap
impl NotesMap
pub fn get() -> &'static NotesMap
pub fn get_by_midi(&self, midi: &u8) -> &HashMap<Accidental, NoteName>
pub fn get_by_note(&self, note: NoteName, acc: Accidental) -> u8
sourcepub fn resolve_note_for_midi(
&self,
note: (NoteName, Accidental),
midi: u8
) -> Option<(NoteName, Accidental)>
pub fn resolve_note_for_midi(
&self,
note: (NoteName, Accidental),
midi: u8
) -> Option<(NoteName, Accidental)>
Accidental of “root” is not counted.
For the given note and MIDI-byte finds only possible enharmonic variant, or returns None.
For example: with the given NoteName::C and midi 2, only possible
enharmonic variant is (NoteName::C, Accidental::DoubleSharp), which
will be returned.
If None is returned — something goes very wrong and it is better to panic.
pub fn resolve_enharmonic(
&self,
accidental: Option<Accidental>,
midi: u8
) -> (NoteName, Accidental)
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for NotesMap
impl Send for NotesMap
impl Sync for NotesMap
impl Unpin for NotesMap
impl UnwindSafe for NotesMap
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more