pub struct Scale {
pub root: Pitch,
pub kind: ScaleKind,
}Fields§
§root: Pitch§kind: ScaleKindImplementations§
Source§impl Scale
impl Scale
pub fn new(root: Pitch, kind: ScaleKind) -> Self
Sourcepub fn from_key(key: &KeySignature) -> Self
pub fn from_key(key: &KeySignature) -> Self
Build a scale from a key signature (uses major or natural minor based on mode).
Sourcepub fn pitches(&self) -> Vec<Pitch>
pub fn pitches(&self) -> Vec<Pitch>
All pitches of this scale in ascending order (root octave preserved).
Sourcepub fn contains(&self, pitch: &Pitch) -> bool
pub fn contains(&self, pitch: &Pitch) -> bool
True if pitch is a member of this scale (octave-independent, by pitch class).
Sourcepub fn degree(&self, pitch: &Pitch) -> Option<usize>
pub fn degree(&self, pitch: &Pitch) -> Option<usize>
Scale degree of pitch (1-based), or None if not in the scale.
Sourcepub fn best_fit(pitches: &[Pitch]) -> Option<Scale>
pub fn best_fit(pitches: &[Pitch]) -> Option<Scale>
Find the scale that best fits the given pitches (octave-independent).
Tries all 12 roots × all non-Chromatic ScaleKinds and picks the one
with the most pitches covered, breaking ties by preferring scales with
more degrees (7-note > 6-note > 5-note) then by ScaleKind declaration
order (Major first). Returns None if pitches is empty.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Scale
impl<'de> Deserialize<'de> for Scale
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Scale
Auto Trait Implementations§
impl Freeze for Scale
impl RefUnwindSafe for Scale
impl Send for Scale
impl Sync for Scale
impl Unpin for Scale
impl UnsafeUnpin for Scale
impl UnwindSafe for Scale
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