pub struct ScaleLock {
pub allowed_classes: Vec<u8>,
}Expand description
A set of allowed pitch classes that incoming notes are snapped to.
Holds the permitted pitch classes (0..12); apply maps any pitch
to the nearest allowed class.
§Examples
use sim_lib_music_core::{Pitch, ScaleLock};
let lock = ScaleLock::major();
// C-sharp (class 1) is not in C major and snaps down to C.
assert_eq!(lock.apply(Pitch::from_semitone(1)).semitone(), 0);
// A pitch already in the scale is left unchanged.
assert_eq!(lock.apply(Pitch::from_semitone(2)).semitone(), 2);Fields§
§allowed_classes: Vec<u8>Sorted, deduplicated allowed pitch classes (each in 0..12).
Implementations§
Trait Implementations§
impl Eq for ScaleLock
impl StructuralPartialEq for ScaleLock
Auto Trait Implementations§
impl Freeze for ScaleLock
impl RefUnwindSafe for ScaleLock
impl Send for ScaleLock
impl Sync for ScaleLock
impl Unpin for ScaleLock
impl UnsafeUnpin for ScaleLock
impl UnwindSafe for ScaleLock
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more