Skip to main content

MosScale

Struct MosScale 

Source
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

Source

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.

Source

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.

Source

pub fn generator(self) -> FloatType

The generator, in cents, folded into the period.

Source

pub fn period(self) -> FloatType

The period, in cents.

Source

pub fn notes(self) -> UnsignedIntegerType

How many notes there are to a period.

Source

pub fn degrees(self) -> Vec<FloatType>

The scale’s degrees in cents, rising from nought inside one period.

Source

pub fn steps(self) -> Vec<FloatType>

The width of each step in cents, from the tonic round to the period.

Source

pub fn is_moment_of_symmetry(self) -> bool

Whether the scale really is a moment of symmetry — two step sizes, no more.

Source

pub fn is_equal(self) -> bool

Whether every step came out the same width, which is an equal division.

Source

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.

Source

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§

Source§

impl Clone for MosScale

Source§

fn clone(&self) -> MosScale

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 MosScale

Source§

impl Debug for MosScale

Source§

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

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

impl<'de> Deserialize<'de> for MosScale

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 PartialEq for MosScale

Source§

fn eq(&self, other: &MosScale) -> 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 MosScale

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 MosScale

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.