pub struct Scale {
pub tonic: PitchClass,
pub mode: Mode,
}Expand description
Fields§
§tonic: PitchClassThe tonic pitch class.
mode: ModeThe mode of the scale.
Implementations§
Source§impl Scale
impl Scale
Sourcepub const fn new(tonic: PitchClass, mode: Mode) -> Self
pub const fn new(tonic: PitchClass, mode: Mode) -> Self
Constructs a scale from a tonic and mode.
Sourcepub const fn major(tonic: PitchClass) -> Self
pub const fn major(tonic: PitchClass) -> Self
Constructs a major scale on tonic.
Sourcepub const fn minor_natural(tonic: PitchClass) -> Self
pub const fn minor_natural(tonic: PitchClass) -> Self
Constructs a natural minor scale on tonic.
Sourcepub const fn minor_harmonic(tonic: PitchClass) -> Self
pub const fn minor_harmonic(tonic: PitchClass) -> Self
Constructs a harmonic minor scale on tonic.
Sourcepub const fn minor_melodic(tonic: PitchClass) -> Self
pub const fn minor_melodic(tonic: PitchClass) -> Self
Constructs a melodic minor scale on tonic.
Sourcepub const fn dorian(tonic: PitchClass) -> Self
pub const fn dorian(tonic: PitchClass) -> Self
Constructs a Dorian scale on tonic.
Sourcepub const fn phrygian(tonic: PitchClass) -> Self
pub const fn phrygian(tonic: PitchClass) -> Self
Constructs a Phrygian scale on tonic.
Sourcepub const fn lydian(tonic: PitchClass) -> Self
pub const fn lydian(tonic: PitchClass) -> Self
Constructs a Lydian scale on tonic.
Sourcepub const fn mixolydian(tonic: PitchClass) -> Self
pub const fn mixolydian(tonic: PitchClass) -> Self
Constructs a Mixolydian scale on tonic.
Sourcepub const fn aeolian(tonic: PitchClass) -> Self
pub const fn aeolian(tonic: PitchClass) -> Self
Constructs an Aeolian scale on tonic.
Sourcepub const fn locrian(tonic: PitchClass) -> Self
pub const fn locrian(tonic: PitchClass) -> Self
Constructs a Locrian scale on tonic.
Sourcepub const fn whole_tone(tonic: PitchClass) -> Self
pub const fn whole_tone(tonic: PitchClass) -> Self
Constructs a whole-tone scale on tonic.
Sourcepub const fn diminished(tonic: PitchClass) -> Self
pub const fn diminished(tonic: PitchClass) -> Self
Constructs a diminished (octatonic) scale on tonic.
Sourcepub const fn chromatic(tonic: PitchClass) -> Self
pub const fn chromatic(tonic: PitchClass) -> Self
Constructs a chromatic scale on tonic.
Sourcepub fn pitch_classes(self) -> Vec<PitchClass>
pub fn pitch_classes(self) -> Vec<PitchClass>
Returns the scale’s pitch classes in ascending degree order from the tonic.
Sourcepub fn mask(self) -> PitchClassMask
pub fn mask(self) -> PitchClassMask
Returns the scale’s pitch classes as a PitchClassMask.
Sourcepub fn degree_of(self, pitch_class: PitchClass) -> Option<usize>
pub fn degree_of(self, pitch_class: PitchClass) -> Option<usize>
Returns the one-based scale degree of pitch_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 transpose_diatonic(
self,
pitch: Pitch,
steps: i32,
) -> Result<Pitch, PitchScaleError>
pub fn transpose_diatonic( self, pitch: Pitch, steps: i32, ) -> Result<Pitch, PitchScaleError>
Transposes pitch by steps scale degrees, staying within the scale and
adjusting octaves as needed.
Returns PitchScaleError::PitchClassOutOfScale if pitch is not a member
of the scale.
Sourcepub fn chord_tone_to_scale_tone(
chord_tone: usize,
) -> Result<usize, PitchScaleError>
pub fn chord_tone_to_scale_tone( chord_tone: usize, ) -> Result<usize, PitchScaleError>
Maps a one-based chord-tone index (root, third, fifth, …) to the one-based scale degree it occupies in tertian stacking.
Sourcepub fn scale_tone_to_diatonic(scale_tone: usize) -> Result<i32, PitchScaleError>
pub fn scale_tone_to_diatonic(scale_tone: usize) -> Result<i32, PitchScaleError>
Maps a one-based scale degree to its zero-based diatonic step offset from the tonic.