pub struct PlayerScale {
pub tonic: PitchClass,
/* private fields */
}Expand description
Fields§
§tonic: PitchClassThe tonic pitch class.
Implementations§
Source§impl PlayerScale
impl PlayerScale
Sourcepub fn from_scale(scale: Scale) -> Self
pub fn from_scale(scale: Scale) -> Self
Builds a player scale from a fixed Scale.
Sourcepub fn from_key(tonic: PitchClass, mode: Mode) -> Self
pub fn from_key(tonic: PitchClass, mode: Mode) -> Self
Builds a player scale from a tonic and Mode.
Sourcepub fn custom(
tonic: PitchClass,
intervals: impl Into<Vec<u8>>,
) -> Result<Self, PitchScaleError>
pub fn custom( tonic: PitchClass, intervals: impl Into<Vec<u8>>, ) -> Result<Self, PitchScaleError>
Builds a player scale from a custom interval list (semitone offsets from the tonic), which is sorted and deduplicated.
Returns PitchScaleError::EmptyScale if no intervals are given, or
PitchScaleError::InvalidScaleInterval if any interval is 12 or more.
Sourcepub fn intervals(&self) -> &[u8] ⓘ
pub fn intervals(&self) -> &[u8] ⓘ
Returns the scale’s semitone offsets from the tonic, in ascending order.
Sourcepub fn pitch_classes(&self) -> Vec<PitchClass>
pub fn pitch_classes(&self) -> Vec<PitchClass>
Returns the scale’s pitch classes in ascending degree order.
Sourcepub fn contains(&self, class: PitchClass) -> bool
pub fn contains(&self, class: PitchClass) -> bool
Returns true if class is a member of the scale.
Sourcepub fn degree_of(&self, class: PitchClass) -> Option<usize>
pub fn degree_of(&self, class: PitchClass) -> Option<usize>
Returns the one-based scale degree of class, or None if it is not in the
scale.
Sourcepub fn pitch_at_degree(
&self,
degree: usize,
) -> Result<PitchClass, PitchScaleError>
pub fn pitch_at_degree( &self, degree: usize, ) -> Result<PitchClass, PitchScaleError>
Returns the pitch class at the one-based degree, wrapping past the octave.
Sourcepub fn try_pitch_at_degree(
&self,
degree: usize,
) -> Result<PitchClass, PitchScaleError>
pub fn try_pitch_at_degree( &self, degree: usize, ) -> Result<PitchClass, PitchScaleError>
Returns the pitch class at the one-based degree, wrapping past the octave.
Sourcepub fn nearest_pitch(&self, pitch: Pitch) -> Pitch
pub fn nearest_pitch(&self, pitch: Pitch) -> Pitch
Returns the in-scale pitch nearest to pitch, breaking ties upward.
Sourcepub fn remap_pitch(&self, pitch: Pitch) -> Pitch
pub fn remap_pitch(&self, pitch: Pitch) -> Pitch
Remaps pitch onto the scale by treating its chromatic offset from the
tonic as a scale degree, preserving the octave.
Trait Implementations§
Source§impl Clone for PlayerScale
impl Clone for PlayerScale
Source§fn clone(&self) -> PlayerScale
fn clone(&self) -> PlayerScale
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more