pub struct MosScale { /* private fields */ }Expand description
A generator and a period, folded into a scale of so many notes.
The generator and period are cents, so nothing here assumes an octave:
Bohlen-Pierce generates inside a period of 1901.955 cents and works the
same way.
use music21_rs::tuningsystem::{MosScale, OCTAVE_CENTS};
// Seven fifths folded into an octave are the diatonic scale. Stacked
// upwards from the tonic they land in its brightest mode, Lydian.
let diatonic = MosScale::new(701.955, OCTAVE_CENTS, 7)?;
assert_eq!(diatonic.pattern()?.to_string(), "5L 2s");
assert_eq!(diatonic.word()?, "LLLsLLs");Implementations§
Source§impl MosScale
impl MosScale
Sourcepub fn new(
generator: FloatType,
period: FloatType,
notes: UnsignedIntegerType,
) -> Result<Self>
pub fn new( generator: FloatType, period: FloatType, notes: UnsignedIntegerType, ) -> Result<Self>
Builds a scale of notes notes from a generator inside a period.
The generator is folded into the period, so handing over a fifth of
701.955 and a fifth of 1901.955 build the same scale. Errors on a
period that is not positive, on a generator that folds to nothing, and
on a scale of no notes.
Sourcepub fn from_equal_division(
steps: UnsignedIntegerType,
divisions: UnsignedIntegerType,
period: FloatType,
notes: UnsignedIntegerType,
) -> Result<Self>
pub fn from_equal_division( steps: UnsignedIntegerType, divisions: UnsignedIntegerType, period: FloatType, notes: UnsignedIntegerType, ) -> Result<Self>
Builds a scale whose generator is steps of an equal division.
This is the wiki’s 3\22 — three steps of 22 equal divisions of the
period — which is how a generator is usually named once a temperament
has been pinned to an equal temperament that supports it.
Sourcepub fn notes(self) -> UnsignedIntegerType
pub fn notes(self) -> UnsignedIntegerType
How many notes there are to a period.
Sourcepub fn degrees(self) -> Vec<FloatType> ⓘ
pub fn degrees(self) -> Vec<FloatType> ⓘ
The scale’s degrees in cents, rising from nought inside one period.
Sourcepub fn steps(self) -> Vec<FloatType> ⓘ
pub fn steps(self) -> Vec<FloatType> ⓘ
The width of each step in cents, from the tonic round to the period.
Sourcepub fn is_moment_of_symmetry(self) -> bool
pub fn is_moment_of_symmetry(self) -> bool
Whether the scale really is a moment of symmetry — two step sizes, no more.
Sourcepub fn is_equal(self) -> bool
pub fn is_equal(self) -> bool
Whether every step came out the same width, which is an equal division.
Sourcepub fn pattern(self) -> Result<Mos>
pub fn pattern(self) -> Result<Mos>
How many large and small steps the scale has.
Errors when the scale is not a moment of symmetry at all: either every step is the same width, which is an equal division, or there are three widths or more, which is the note count between two moments.
Sourcepub fn word(self) -> Result<String>
pub fn word(self) -> Result<String>
The scale’s own step word, from its tonic rather than from its brightest mode.
Errors where MosScale::pattern does.
Trait Implementations§
impl Copy for MosScale
Source§impl<'de> Deserialize<'de> for MosScale
Available on crate feature serde only.
impl<'de> Deserialize<'de> for MosScale
serde only.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>,
impl StructuralPartialEq for MosScale
Auto Trait Implementations§
impl Freeze for MosScale
impl RefUnwindSafe for MosScale
impl Send for MosScale
impl Sync for MosScale
impl Unpin for MosScale
impl UnsafeUnpin for MosScale
impl UnwindSafe for MosScale
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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