pub struct Val { /* private fields */ }Expand description
How many steps of a tuning each prime is worth.
⟨12 19 28] is twelve-tone equal temperament read to the 5-limit: twelve
steps to the octave, nineteen to the perfect twelfth, twenty-eight to the
major seventeenth. Applying it to a Monzo says how many steps that
interval comes to, and a comma it sends to nothing is a comma the tuning
tempers out.
use music21_rs::tuningsystem::{Monzo, Val};
let twelve = Val::patent(12, 5)?;
assert_eq!(twelve.entries(), [12, 19, 28]);
assert_eq!(twelve.map(&Monzo::from_ratio(3, 2)?), 7);
assert!(twelve.tempers_out(&Monzo::from_ratio(81, 80)?));Implementations§
Source§impl Val
impl Val
Sourcepub fn new(entries: impl Into<Vec<IntegerType>>) -> Self
pub fn new(entries: impl Into<Vec<IntegerType>>) -> Self
Builds a val from step counts, lowest prime first.
Trailing zeros are kept, unlike a monzo’s: a val saying the seventh harmonic is worth no steps at all has said something about it, while a val that stops before it has not.
Sourcepub fn patent(divisions: IntegerType, limit: IntegerType) -> Result<Self>
pub fn patent(divisions: IntegerType, limit: IntegerType) -> Result<Self>
The patent val of divisions equal steps, read up to limit.
Each prime is mapped to the nearest whole number of steps, which is what patent means: the obvious reading, before anyone chooses a warped one. Errors for a limit that is not a prime this module carries.
Sourcepub fn entries(&self) -> &[IntegerType] ⓘ
pub fn entries(&self) -> &[IntegerType] ⓘ
The step counts, lowest prime first.
Sourcepub fn map(&self, interval: &Monzo) -> IntegerType
pub fn map(&self, interval: &Monzo) -> IntegerType
How many steps the val makes interval come to.
A prime the val does not reach is read as nought steps, so ask
Val::reaches first where that would be a lie rather than an answer.
Sourcepub fn reaches(&self, interval: &Monzo) -> bool
pub fn reaches(&self, interval: &Monzo) -> bool
Whether the val says anything about every prime interval uses.
Sourcepub fn tempers_out(&self, comma: &Monzo) -> bool
pub fn tempers_out(&self, comma: &Monzo) -> bool
Whether the tuning tempers comma out — maps it to no steps at all.
Sourcepub fn divisions(&self) -> IntegerType
pub fn divisions(&self) -> IntegerType
How many steps the val divides the octave into.
That is its first entry, since the first prime is two.
Sourcepub fn limit(&self) -> Option<IntegerType>
pub fn limit(&self) -> Option<IntegerType>
The largest prime the val reaches, or None for an empty one.
Sourcepub fn error_cents(&self, interval: &Monzo) -> Result<FloatType>
pub fn error_cents(&self, interval: &Monzo) -> Result<FloatType>
How far off interval sounds in this tuning, in cents.
Positive is sharp of just. The step size comes from the val’s own octave, so a val mapping the octave to nothing has no answer and this is an error.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Val
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Val
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 Eq for Val
Source§impl Ord for Val
impl Ord for Val
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Val
impl PartialOrd for Val
impl StructuralPartialEq for Val
Auto Trait Implementations§
impl Freeze for Val
impl RefUnwindSafe for Val
impl Send for Val
impl Sync for Val
impl Unpin for Val
impl UnsafeUnpin for Val
impl UnwindSafe for Val
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