pub struct Scale<T = f32> {
pub root: Frequency<T>,
}Expand description
The Scale implementation uses the defined root or anchor frequency as the basis for
classfifications and other related computations.
Fields§
§root: Frequency<T>Implementations§
Source§impl<T> Scale<T>
impl<T> Scale<T>
pub const fn new(root: T) -> Scale<T>
Sourcepub fn a4() -> Scale<T>where
T: FromPrimitive,
pub fn a4() -> Scale<T>where
T: FromPrimitive,
initialize a new scale using A4 as the root
Sourcepub const fn from_freq(root: Frequency<T>) -> Scale<T>
pub const fn from_freq(root: Frequency<T>) -> Scale<T>
creates a new Scale from the given root frequency
Sourcepub const fn root_mut(&mut self) -> &mut Frequency<T>
pub const fn root_mut(&mut self) -> &mut Frequency<T>
returns a mutable reference to the base frequency
Sourcepub fn classify(&self, _: Frequency<T>) -> Option<isize>
pub fn classify(&self, _: Frequency<T>) -> Option<isize>
classifies the given frequency as a pitch class n, using the formula:
n=\text{round}(12\cdot\log_{2}(\frac{F}{\beta}))Sourcepub fn get_freq_of_class(&self, n: isize) -> Frequency<T>
pub fn get_freq_of_class(&self, n: isize) -> Frequency<T>
returns the frequency $F$, in hertz [Hz], of the given pitch class n, using:
F=\beta\cdot{2^{\frac{n}{12}}}Trait Implementations§
Source§impl<T> Ord for Scale<T>where
T: Ord,
impl<T> Ord for Scale<T>where
T: Ord,
Source§impl<T> PartialOrd for Scale<T>where
T: PartialOrd,
impl<T> PartialOrd for Scale<T>where
T: PartialOrd,
impl<T> Copy for Scale<T>where
T: Copy,
impl<T> Eq for Scale<T>where
T: Eq,
impl<T> StructuralPartialEq for Scale<T>
Auto Trait Implementations§
impl<T> Freeze for Scale<T>where
T: Freeze,
impl<T> RefUnwindSafe for Scale<T>where
T: RefUnwindSafe,
impl<T> Send for Scale<T>where
T: Send,
impl<T> Sync for Scale<T>where
T: Sync,
impl<T> Unpin for Scale<T>where
T: Unpin,
impl<T> UnwindSafe for Scale<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> AsWeight<T> for Twhere
T: Clone + IntoWeight<T>,
impl<T> AsWeight<T> for Twhere
T: Clone + IntoWeight<T>,
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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>
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 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>
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