[−][src]Struct tune::temperament::Val
A Val
is a sequence of step numbers that, multiplied by a fixed ratio, are to be considered equivalent to the prime number sequence [2, 3, 5, 7, ...].
Treating a number of steps to be equivalent to a specific total ratio is the core idea of tempering.
That said, a Val
is an irreducible representation of the arithmetic properties of a temperament.
Implementations
impl Val
[src]
pub fn patent(ratio: Ratio, prime_limit: u8) -> Self
[src]
Calculates the patent val for the given ratio
.
The patent val is the sequence of steps which, multiplied by ratio
, provide the best approxiation for the prime number ratios [2, 3, 5, 7, ..., prime_limit
].
Examples
let val_of_12_edo = Val::patent(Ratio::octave().divided_into_equal_steps(12), 13); assert_eq!(val_of_12_edo.values(), &[12, 19, 28, 34, 42, 44]); let val_of_17_edo = Val::patent(Ratio::octave().divided_into_equal_steps(17), 11); assert_eq!(val_of_17_edo.values(), &[17, 27, 39, 48, 59]); let val_of_boh_pier = Val::patent(Ratio::from_float(3.0).divided_into_equal_steps(13), 7); assert_eq!(val_of_boh_pier.values(), &[8, 13, 19, 23]);
pub fn from_values(values: impl Into<Vec<u16>>) -> Option<Self>
[src]
Creates a Val
from the given values.
None
is returned if the provided list is too long.
Examples
let still_okay = vec![1; 54]; assert!(Val::from_values(still_okay).is_some()); let too_long = vec![1; 55]; assert!(Val::from_values(too_long).is_none());
pub fn values(&self) -> &[u16]
[src]
Returns the values stored in this val.
Examples
let arbitrary_numbers = [5, 6, 7]; let val = Val::from_values(arbitrary_numbers).unwrap(); assert_eq!(val.values(), arbitrary_numbers);
pub fn prime_limit(&self) -> u8
[src]
Returns the prime limit of this val.
Examples
let custom_val = Val::from_values([12, 19, 28, 34, 42]).unwrap(); assert_eq!(custom_val.prime_limit(), 11);
Auto Trait Implementations
impl RefUnwindSafe for Val
impl Send for Val
impl Sync for Val
impl Unpin for Val
impl UnwindSafe for Val
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,