Skip to main content

ScaleType

Enum ScaleType 

Source
#[non_exhaustive]
pub enum ScaleType {
Show 20 variants Major, Minor, Dorian, Phrygian, Lydian, Mixolydian, Locrian, Hypodorian, Hypophrygian, Hypolydian, Hypomixolydian, Hypolocrian, Hypoaeolian, HarmonicMinor, MelodicMinor, Chromatic, WholeTone, Octatonic, RagAsawari, RagMarwa,
}
Expand description

A named scale from music21’s scale module.

Ordered as music21 defines them: the seven church modes, their plagal counterparts, the altered minors, then the symmetrical and non-Western scales.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Major

Major (Ionian).

§

Minor

Natural minor (Aeolian).

§

Dorian

Dorian mode.

§

Phrygian

Phrygian mode.

§

Lydian

Lydian mode.

§

Mixolydian

Mixolydian mode.

§

Locrian

Locrian mode.

§

Hypodorian

Hypodorian mode. Shares Dorian’s pitches; the ambitus differs.

§

Hypophrygian

Hypophrygian mode. Shares Phrygian’s pitches.

§

Hypolydian

Hypolydian mode. Shares Lydian’s pitches.

§

Hypomixolydian

Hypomixolydian mode. Shares Mixolydian’s pitches.

§

Hypolocrian

Hypolocrian mode. Shares Locrian’s pitches.

§

Hypoaeolian

Hypoaeolian mode. Shares natural minor’s pitches.

§

HarmonicMinor

Harmonic minor, with a raised seventh.

§

MelodicMinor

Ascending melodic minor.

§

Chromatic

Twelve-tone chromatic scale.

§

WholeTone

Six-tone whole-tone scale.

§

Octatonic

Eight-tone octatonic scale, alternating tone and semitone.

§

RagAsawari

Rag Asawari, as a five-tone ascending scale.

§

RagMarwa

Rag Marwa, as a seven-step ascending scale.

Not monotonic: music21’s ascending network dips back down a major second from the sixth degree before rising a minor third to the octave, so the realized pitches repeat a note and briefly descend.

Implementations§

Source§

impl ScaleType

Source

pub const ALL: [ScaleType; 20]

Every scale type, in declaration order.

Source

pub fn music21_name(self) -> &'static str

Returns the music21 class name for this scale.

Source

pub fn music21_descriptive_name(self) -> &'static str

The words music21 puts after the tonic when it names a scale: "C major", "C harmonic minor", "C Rag Asawari".

The capitalisation is upstream’s and is not consistent — the modes are lower case, the others are not — which is why this is a table rather than something derived from the class name.

Source

pub fn from_music21_name(name: &str) -> Option<Self>

The scale type music21 calls by this class name, such as "MajorScale".

Source

pub fn tonic_degree(self) -> usize

Which degree of the realized scale is its final: music21’s tonicDegree.

A plagal mode — the six that music21 prefixes Hypo — runs from a fourth below its final to a fifth above it, so the note the music comes to rest on is its fourth degree and not its first. Every other scale here starts on its own tonic.

Source

pub fn dominant_degree(self) -> usize

Which degree is the reciting tone: music21’s dominantDegree.

A fifth above the final in the authentic modes. The plagal ones took theirs a third above the authentic dominant and then moved it off any B, which is why hypophrygian and hypomixolydian differ from the rest.

Source

pub fn realization_steps(self) -> Vec<&'static str>

The steps walked from the pitch the scale is realized from, which for a plagal mode is not its final.

steps is the collection written from the final, which is how every one of these scales is named. A plagal mode is realized from a fourth below that, so its walk starts three steps earlier in the same cycle — the rotation that puts the final at the degree Self::tonic_degree names.

Source

pub fn beyond_terminus(self) -> Option<&'static str>

The step a scale carries on past its own octave, where it has one.

Rag Marwa is the only one here: its network keeps going a semitone above the terminus, so the collection realized from C closes on the octave and then sounds the D- above it. music21 calls it “a pitch beyond the terminus” and gives it whenever the realization is not bounded by a range.

Source

pub fn descending_form(self) -> Option<Self>

The collection this scale uses coming down, where that is not the one it uses going up.

The melodic minor is the familiar case — it raises its sixth and seventh degrees ascending and lets them fall descending, which is the natural minor — and Rag Asawari’s avaroha is that same collection. Every other scale here descends through the notes it ascends through, and answers None.

Source

pub fn ascending_degrees(self) -> Option<&'static [u8]>

The degrees the notes of this scale’s ascent stand on, where they are not simply counted off one to a note.

Rag Asawari’s aroha leaves out the third and the seventh, so its five notes stand on the first, second, fourth, fifth and sixth degrees. It has no third going up at all — which is what music21 answers when asked for one — and its fourth degree is its third note.

Source

pub fn descending_steps(self) -> Option<&'static [&'static str]>

The steps this scale is walked by coming down, where coming down is not simply the ascending pattern read backwards and no other named scale is that pattern.

Rag Marwa’s avarohana is the one: from its tonic it rises a semitone to the flat second above the octave and falls from there, which is music21’s network edge from the high terminus upward before anything descends. Written as a rising list from the tonic it closes by falling back onto it, so the flat second is both the second degree and the seventh — which is what music21 answers when asked which degree a D- is coming down.

Source

pub fn is_plagal(self) -> bool

Whether this is a plagal mode, whose range sits below its final.

Source

pub fn degree_count(self) -> usize

Returns the number of distinct degrees in one octave.

Source§

impl ScaleType

Source

pub fn derive_ranked( self, pitches: &[Pitch], limit: Option<usize>, ) -> Result<Vec<(usize, Scale)>>

Ranks every candidate tonic by how many of pitches fall in this scale type built on it, best first, as music21’s deriveRanked does. Pitches are compared by pitch class and duplicates count separately.

Source

pub fn derive_ranked_by( self, pitches: &[Pitch], limit: Option<usize>, comparison: DegreeComparison, ) -> Result<Vec<(usize, Scale)>>

The same, saying how a pitch is matched against a scale degree.

By pitch class an E# is in C major, since the scale has an F; by name it is not. music21 offers both, and its deriveRanked defaults to the first.

Source

pub fn derive(self, pitches: &[Pitch]) -> Result<Scale>

Returns this scale type on the tonic that fits pitches best.

Source

pub fn derive_all(self, pitches: &[Pitch]) -> Result<Vec<Scale>>

Returns every tonic on which this scale type contains all of pitches, best-ranked first.

Trait Implementations§

Source§

impl Clone for ScaleType

Source§

fn clone(&self) -> ScaleType

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ScaleType

Source§

impl Debug for ScaleType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ScaleType

Available on crate feature serde only.
Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for ScaleType

Source§

impl Hash for ScaleType

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ScaleType

Source§

fn eq(&self, other: &ScaleType) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for ScaleType

Available on crate feature serde only.
Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ScaleType

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.