Skip to main content

TuningSystem

Enum TuningSystem 

Source
pub enum TuningSystem {
Show 26 variants Equal(EqualDivision), CarlosHarmonic, CarlosHarmonic24, PythagoreanTuning, FiveLimit, ElevenLimit, FortyThreeTone, Javanese, Thai, PtolemyIntenseDiatonic, IndianAlt, Indian22, QuarterCommaMeantone, WerckmeisterIII, Rameau, KirnbergerIII, Vallotti, YoungII, ThirdCommaMeantone, SixthCommaMeantone, WerckmeisterIV, WerckmeisterV, KirnbergerI, NeidhardtI, Silbermann, LehmanBach,
}
Expand description

Supported tuning systems and ratio tables.

Every system repeats at a period, and a degree past the end of one is the same degree a period up. The ratio tables repeat at the octave; an equal division repeats wherever its period is, so Bohlen-Pierce climbs by tritaves.

Variants§

§

Equal(EqualDivision)

Equal steps of one period. 12edo is ordinary equal temperament, 6edo the whole-tone scale and 24edo quarter tones, and the period need not be an octave: 13edt is Bohlen-Pierce.

§

CarlosHarmonic

Twelve-tone harmonic-series scale (Wendy Carlos’s Harmonic).

Not just intonation, despite its former name: the degrees are the harmonic series 16:17:18:19:20:21:22:24:26:27:28:30, which reaches the 19-limit. TuningSystem::FiveLimit is the classical 12-tone JI scale.

§

CarlosHarmonic24

Twenty-four-tone harmonic-series scale.

§

PythagoreanTuning

Twelve-tone Pythagorean tuning table.

§

FiveLimit

Twelve-tone five-limit table.

§

ElevenLimit

Twenty-nine-tone eleven-limit table.

§

FortyThreeTone

Forty-three-tone ratio table.

§

Javanese

Five-tone Javanese equal-temperament approximation.

§

Thai

Seven-tone Thai equal-temperament approximation.

§

PtolemyIntenseDiatonic

Ptolemy’s intense diatonic, also Zarlino’s just major scale.

Greek and Renaissance European, despite once being filed here as an Indian scale — the archive names it ptolemy.scl.

§

IndianAlt

Alternate seven-tone PtolemyIntenseDiatonic scale table.

§

Indian22

Twenty-two-tone PtolemyIntenseDiatonic scale table.

§

QuarterCommaMeantone

Twelve-tone quarter-comma meantone temperament (Aaron, 1523).

§

WerckmeisterIII

Twelve-tone Werckmeister III well temperament (1681).

§

Rameau

Twelve-tone Rameau modified meantone temperament (1725).

§

KirnbergerIII

Twelve-tone Kirnberger III well temperament (1744).

§

Vallotti

Twelve-tone Vallotti well temperament (c. 1754).

§

YoungII

Twelve-tone Thomas Young well temperament no. 2 (1799).

§

ThirdCommaMeantone

A twelve-tone third-comma meantone temperament (Salinas, 1577).

§

SixthCommaMeantone

A twelve-tone sixth-comma meantone temperament (Salinas, 1577).

§

WerckmeisterIV

A twelve-tone Werckmeister IV well temperament (1681).

§

WerckmeisterV

A twelve-tone Werckmeister V well temperament (1681).

§

KirnbergerI

A twelve-tone Kirnberger I well temperament (1766).

§

NeidhardtI

A twelve-tone Neidhardt I well temperament (1724).

§

Silbermann

A twelve-tone Gottfried Silbermann temperament no. 1 (c. 1730).

§

LehmanBach

A twelve-tone Lehman-Bach temperament (2005).

Implementations§

Source§

impl TuningSystem

Source

pub const EQUAL_TEMPERAMENT: Self

Twelve-tone equal temperament, 12edo.

Source

pub const WHOLE_TONE: Self

The whole-tone scale, six equal steps to the octave.

Source

pub const QUARTER_TONE: Self

Quarter tones, twenty-four equal steps to the octave.

Source

pub fn id(self) -> String

Returns the canonical identifier used by FromStr.

Source

pub fn display_name(self) -> String

Returns a compact display name for this tuning system.

Source

pub fn description(self) -> String

Returns a short description of this tuning system.

Source

pub fn ratio(self, index: usize) -> FloatType

The frequency ratio of a degree above the system’s starting pitch.

Source

pub fn ratio_at(self, index: FloatType) -> FloatType

The same for a fractional degree. A whole degree is the system’s own step exactly; between two, the pitch is interpolated as the equal division of the period with as many steps would place it.

Source

pub fn exact_ratio(self, index: usize) -> Option<Ratio>

The degree as an exact ratio, where it is one.

Every ratio table has one for each degree, and so does an equal division of a whole-number period, as a root of it: a step of 13edt is the thirteenth root of three. A division of an irrational period, Carlos Alpha’s 78 cents, has none.

Source

pub fn label(self, index: UnsignedIntegerType) -> String

A name for a degree, counted from C-1.

A system of twelve degrees to the octave names each degree for its key, C♯/D♭4, however it is tuned, and so does any other system on a degree that lands on a key. Every other degree is the pitch it sounds, as TuningSystem::pitch_at spells it, with its microtone: G0(+2c) is the thirteenth step of Bohlen-Pierce. Ptolemy’s intense diatonic and the Sa-grama are named in sargam, Re0.

Source

pub fn period_of(self, index: UnsignedIntegerType) -> UnsignedIntegerType

Which period a degree falls in, counting from nought.

Source

pub fn frequency(self, index: UnsignedIntegerType) -> FloatType

The frequency in hertz of a degree above C-1.

Source

pub fn frequency_at(self, index: FloatType) -> FloatType

The frequency in hertz of a fractional degree above C-1.

Source

pub fn nearest_degree(self, hertz: FloatType) -> Result<IntegerType>

The degree sounding nearest hertz, counted from C-1 as TuningSystem::frequency counts, and measured in cents. Errors on a frequency that is not a finite number above nought.

use music21_rs::tuningsystem::TuningSystem;

let nineteen = TuningSystem::edo(19);
// A4 at 440 Hz is nearest degree 5 of the fifth period above C-1.
assert_eq!(nineteen.nearest_degree(440.0)?, 5 * 19 + 14);
Source

pub fn pitch_at(self, index: IntegerType) -> Result<Pitch>

The pitch a degree sounds, counted from C-1: spelled as the nearest pitch-space value is spelled, with any remainder as a microtone.

use music21_rs::tuningsystem::TuningSystem;

// Degree 4 of the five-limit table is a just major third above C-1.
let e = TuningSystem::FiveLimit.pitch_at(64)?;
assert_eq!(e.name_with_octave(), "E4");
assert!((e.microtone().unwrap().cents() + 13.686).abs() < 1e-3);
Source

pub fn cents(self, index: UnsignedIntegerType) -> FloatType

How far a degree lies from the same degree of the equal division of the same period into as many steps, in cents. Nought all the way up for an equal division, which is its own reference.

Source

pub fn cents_at(self, index: FloatType) -> FloatType

The same for a fractional degree.

Source

pub fn degrees_per_period(self) -> UnsignedIntegerType

How many degrees the system has before it repeats: twelve for most of the tables, and the number of divisions for an equal one.

Source

pub fn period_cents(self) -> FloatType

The interval the system repeats at, in cents: an octave for every table, and whatever an equal division divides.

Source

pub fn repeats_at_the_octave(self) -> bool

Whether the system repeats at the octave.

Source

pub fn is_keyboard(self) -> bool

Whether the system has twelve degrees to the octave, one for each key of a keyboard.

Source

pub const fn edo(divisions: UnsignedIntegerType) -> Self

An equal division of the octave into a number of steps fixed where it is written, for naming one in a constant. It is a compile error in a constant, and a panic otherwise, to ask for no steps at all; a count read at runtime goes through EqualDivision::octave, which is an error instead.

Trait Implementations§

Source§

impl Clone for TuningSystem

Source§

fn clone(&self) -> Self

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 TuningSystem

Source§

impl Debug for TuningSystem

Source§

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

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

impl<'de> Deserialize<'de> for TuningSystem

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 TuningSystem

Source§

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

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

impl From<TuningSystem> for AnyTuningSystem

Source§

fn from(tuning_system: TuningSystem) -> Self

Converts to this type from the input type.
Source§

impl FromStr for TuningSystem

Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Reads a system’s id: a table’s name, or an equal division as it writes itself (19edo, 13edt, 9ed3/2). EqualTemperament, WholeTone and QuarterTone read as 12edo, 6edo and 24edo.

Source§

type Err = Error

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

impl PartialEq for TuningSystem

Source§

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

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 TuningSystem

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.