Skip to main content

EqualDivision

Struct EqualDivision 

Source
pub struct EqualDivision { /* private fields */ }
Expand description

An equal division of an arbitrary interval.

12edo is twelve equal divisions of the octave, 13edt thirteen of the tritave. Nothing here assumes the period is an octave, so a degree past the period simply carries on into the next one — which for Bohlen-Pierce means the pitches never line up with an octave at all.

Implementations§

Source§

impl EqualDivision

Source

pub fn new( divisions: UnsignedIntegerType, period_cents: FloatType, ) -> Result<Self>

Divides a period given in cents.

Errors on a period that is not a positive real number, or on no divisions at all.

Source

pub fn of_ratio( divisions: UnsignedIntegerType, numerator: IntegerType, denominator: IntegerType, ) -> Result<Self>

Divides the interval numerator/denominator.

The ratio is remembered, so the division names itself after it.

Source

pub fn octave(divisions: UnsignedIntegerType) -> Result<Self>

Divides the octave — an EDO, and what everyone means by default.

Source

pub fn tritave(divisions: UnsignedIntegerType) -> Result<Self>

Divides the tritave, 3/1 — an EDT, which is Bohlen-Pierce’s period.

Source

pub fn divisions(&self) -> UnsignedIntegerType

How many steps the period is divided into.

Source

pub fn period_cents(&self) -> FloatType

The period, in cents.

Source

pub fn period_ratio(&self) -> Option<(IntegerType, IntegerType)>

The ratio the period was given as, where it was given as one.

Source

pub fn repeats_at_the_octave(&self) -> bool

Whether the period is an octave, which is what makes this an ordinary EDO.

Source

pub fn step_cents(&self) -> FloatType

One step, in cents.

Source

pub fn cents_at(&self, degree: IntegerType) -> FloatType

How far above the tonic degree steps sit, in cents.

A degree past the period carries on into the next one, and a negative degree goes below the tonic.

Source

pub fn ratio_at(&self, degree: IntegerType) -> FloatType

The frequency ratio of degree steps above the tonic.

Source

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

Every degree of one period, in cents, from nought up to but not including the period.

Source

pub fn nearest_degree(&self, cents: FloatType) -> IntegerType

The degree nearest cents above the tonic.

Source

pub fn error_at_cents(&self, cents: FloatType) -> FloatType

How far the nearest degree sits from cents; positive is sharp.

Source

pub fn approximation_of(&self, interval: &Monzo) -> (IntegerType, FloatType)

The degree nearest interval, and how far off it sounds in cents.

This is how well the division does a just interval, which for an EDO is the whole question of whether it is worth using.

Source

pub fn patent_val(&self, limit: IntegerType) -> Result<Val>

The patent val of this division, read up to limit.

Each prime is mapped to the nearest whole number of steps, which for an octave division is the familiar patent val. For a period that is not an octave this is the generalized reading, and the octave itself then gets a mapping like any other prime rather than being the period. Errors for a limit that is not a prime the module carries.

Source

pub fn mos( &self, steps: UnsignedIntegerType, notes: UnsignedIntegerType, ) -> Result<MosScale>

The scale of notes notes made by stacking steps of this division.

This is the wiki’s 3\22 — three steps of twenty-two — handed to the moment-of-symmetry machinery.

Trait Implementations§

Source§

impl Clone for EqualDivision

Source§

fn clone(&self) -> EqualDivision

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 EqualDivision

Source§

impl Debug for EqualDivision

Source§

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

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

impl<'de> Deserialize<'de> for EqualDivision

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 Display for EqualDivision

Source§

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

Names the division the way the literature does: 12edo, 13edt, 9ed3/2.

Source§

impl FromStr for EqualDivision

Source§

fn from_str(text: &str) -> Result<Self>

Reads 12edo, 13edt, 13ed3 and 9ed3/2.

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

impl PartialEq for EqualDivision

Source§

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

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 EqualDivision

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.