#[repr(transparent)]pub struct Frequency<T = f64>(pub T);Expand description
The Frequency type is a generic wrapper around type T that implements the
RawFrequency trait. This implementation is designed to provide a consistent interface
for dealing with frequencies within the crate, enabling conversion, arithmetic operations,
and other utilities that are common to frequency values.
Tuple Fields§
§0: TImplementations§
Source§impl<T> Frequency<T>where
T: RawFrequency,
impl<T> Frequency<T>where
T: RawFrequency,
Sourcepub const fn new(index: T) -> Self
pub const fn new(index: T) -> Self
returns a new instance of the Frequency wrapping the given value
Sourcepub fn from_class_with_scale<N>(note: N, root: T) -> Self
pub fn from_class_with_scale<N>(note: N, root: T) -> Self
calculate the frequency (in hertz) of a given pitch class, using the formula:
F=\gamma\cdot{2^\frac{n}{12}}Sourcepub fn from_class_on_a4<N>(note: N) -> Self
pub fn from_class_on_a4<N>(note: N) -> Self
a shorthand method for creating a new frequency from the given pitch class using A4 as the base frequency
Sourcepub fn from_pitch_class<P, K>(class: PitchClass<P, K>, root: T) -> Self
pub fn from_pitch_class<P, K>(class: PitchClass<P, K>, root: T) -> Self
a method for directly converting an instance of the PitchClass into a frequency
Sourcepub fn init<F>(f: F) -> Selfwhere
F: FnOnce() -> T,
pub fn init<F>(f: F) -> Selfwhere
F: FnOnce() -> T,
initializes a new frequency by capturing the result of the given function
Sourcepub const fn as_mut_ptr(&mut self) -> *mut T
pub const fn as_mut_ptr(&mut self) -> *mut T
returns a mutable pointer to the inner value
Sourcepub fn map<U, F>(self, f: F) -> Frequency<U>where
F: FnOnce(T) -> U,
pub fn map<U, F>(self, f: F) -> Frequency<U>where
F: FnOnce(T) -> U,
apply a function to the inner value and returns a new Frequency wrapping the result
Sourcepub fn apply<U, F>(&self, f: F) -> Frequency<U>
pub fn apply<U, F>(&self, f: F) -> Frequency<U>
apply a function to a reference of the current frequency, capturing the result in a new instance
Sourcepub fn apply_inplace<F>(&mut self, f: F) -> &mut Self
pub fn apply_inplace<F>(&mut self, f: F) -> &mut Self
applies the given function to m
Sourcepub const fn replace(&mut self, index: T) -> T
pub const fn replace(&mut self, index: T) -> T
replaces the inner value with the given one and returns the old value
Sourcepub fn take(&mut self) -> Twhere
T: Default,
pub fn take(&mut self) -> Twhere
T: Default,
takes and returns the inner value, replacing it with the logical default
of the type T
Sourcepub fn with<U>(self, other: U) -> Frequency<U>
pub fn with<U>(self, other: U) -> Frequency<U>
consumes the current instance to create another with the given value
Sourcepub const fn view(&self) -> Frequency<&T>
pub const fn view(&self) -> Frequency<&T>
returns a new instance containing a reference to the inner value
Sourcepub const fn view_mut(&mut self) -> Frequency<&mut T>
pub const fn view_mut(&mut self) -> Frequency<&mut T>
returns a new instance containing a mutable reference to the inner value
Sourcepub fn classify_by<Z>(&self, base: T) -> Zwhere
Self: ClassifyBy<T, Output = Z>,
pub fn classify_by<Z>(&self, base: T) -> Zwhere
Self: ClassifyBy<T, Output = Z>,
Compute the pitch class of a frequency (in hertz), using the formula:
n = 12\cdot\log_2(\frac{F}{\gamma})Source§impl<T> Frequency<&T>where
T: RawFrequency,
impl<T> Frequency<&T>where
T: RawFrequency,
Source§impl<T> Frequency<&mut T>where
T: RawFrequency,
impl<T> Frequency<&mut T>where
T: RawFrequency,
Trait Implementations§
Source§impl<'a, _A, _B, _C> Add<&'a mut Frequency<_B>> for Frequency<_A>where
_A: Add<&'a mut _B, Output = _C>,
impl<'a, _A, _B, _C> Add<&'a mut Frequency<_B>> for Frequency<_A>where
_A: Add<&'a mut _B, Output = _C>,
Source§impl<'a, _A, _B, _C> Add<Frequency<_B>> for &'a mut Frequency<_A>where
&'a mut _A: Add<_B, Output = _C>,
impl<'a, _A, _B, _C> Add<Frequency<_B>> for &'a mut Frequency<_A>where
&'a mut _A: Add<_B, Output = _C>,
Source§impl<_A, _B> AddAssign<Frequency<_B>> for Frequency<_A>where
_A: AddAssign<_B>,
impl<_A, _B> AddAssign<Frequency<_B>> for Frequency<_A>where
_A: AddAssign<_B>,
Source§fn add_assign(&mut self, rhs: Frequency<_B>)
fn add_assign(&mut self, rhs: Frequency<_B>)
+= operation. Read moreSource§impl<'a, _A, _B, _C> BitAnd<&'a mut Frequency<_B>> for Frequency<_A>where
_A: BitAnd<&'a mut _B, Output = _C>,
impl<'a, _A, _B, _C> BitAnd<&'a mut Frequency<_B>> for Frequency<_A>where
_A: BitAnd<&'a mut _B, Output = _C>,
Source§impl<'a, _A, _B, _C> BitAnd<Frequency<_B>> for &'a mut Frequency<_A>where
&'a mut _A: BitAnd<_B, Output = _C>,
impl<'a, _A, _B, _C> BitAnd<Frequency<_B>> for &'a mut Frequency<_A>where
&'a mut _A: BitAnd<_B, Output = _C>,
Source§impl<_A, _B> BitAndAssign<Frequency<_B>> for Frequency<_A>where
_A: BitAndAssign<_B>,
impl<_A, _B> BitAndAssign<Frequency<_B>> for Frequency<_A>where
_A: BitAndAssign<_B>,
Source§fn bitand_assign(&mut self, rhs: Frequency<_B>)
fn bitand_assign(&mut self, rhs: Frequency<_B>)
&= operation. Read moreSource§impl<'a, _A, _B, _C> BitOr<&'a mut Frequency<_B>> for Frequency<_A>where
_A: BitOr<&'a mut _B, Output = _C>,
impl<'a, _A, _B, _C> BitOr<&'a mut Frequency<_B>> for Frequency<_A>where
_A: BitOr<&'a mut _B, Output = _C>,
Source§impl<'a, _A, _B, _C> BitOr<Frequency<_B>> for &'a mut Frequency<_A>where
&'a mut _A: BitOr<_B, Output = _C>,
impl<'a, _A, _B, _C> BitOr<Frequency<_B>> for &'a mut Frequency<_A>where
&'a mut _A: BitOr<_B, Output = _C>,
Source§impl<_A, _B> BitOrAssign<Frequency<_B>> for Frequency<_A>where
_A: BitOrAssign<_B>,
impl<_A, _B> BitOrAssign<Frequency<_B>> for Frequency<_A>where
_A: BitOrAssign<_B>,
Source§fn bitor_assign(&mut self, rhs: Frequency<_B>)
fn bitor_assign(&mut self, rhs: Frequency<_B>)
|= operation. Read moreSource§impl<'a, _A, _B, _C> BitXor<&'a mut Frequency<_B>> for Frequency<_A>where
_A: BitXor<&'a mut _B, Output = _C>,
impl<'a, _A, _B, _C> BitXor<&'a mut Frequency<_B>> for Frequency<_A>where
_A: BitXor<&'a mut _B, Output = _C>,
Source§impl<'a, _A, _B, _C> BitXor<Frequency<_B>> for &'a mut Frequency<_A>where
&'a mut _A: BitXor<_B, Output = _C>,
impl<'a, _A, _B, _C> BitXor<Frequency<_B>> for &'a mut Frequency<_A>where
&'a mut _A: BitXor<_B, Output = _C>,
Source§impl<_A, _B> BitXorAssign<Frequency<_B>> for Frequency<_A>where
_A: BitXorAssign<_B>,
impl<_A, _B> BitXorAssign<Frequency<_B>> for Frequency<_A>where
_A: BitXorAssign<_B>,
Source§fn bitxor_assign(&mut self, rhs: Frequency<_B>)
fn bitxor_assign(&mut self, rhs: Frequency<_B>)
^= operation. Read moreSource§impl<T> BorrowMut<T> for Frequency<T>
impl<T> BorrowMut<T> for Frequency<T>
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ClassifyBy<T> for Frequency<T>
impl<T> ClassifyBy<T> for Frequency<T>
Source§impl<'a, _A, _B, _C> Div<&'a mut Frequency<_B>> for Frequency<_A>where
_A: Div<&'a mut _B, Output = _C>,
impl<'a, _A, _B, _C> Div<&'a mut Frequency<_B>> for Frequency<_A>where
_A: Div<&'a mut _B, Output = _C>,
Source§impl<'a, _A, _B, _C> Div<Frequency<_B>> for &'a mut Frequency<_A>where
&'a mut _A: Div<_B, Output = _C>,
impl<'a, _A, _B, _C> Div<Frequency<_B>> for &'a mut Frequency<_A>where
&'a mut _A: Div<_B, Output = _C>,
Source§impl<_A, _B> DivAssign<Frequency<_B>> for Frequency<_A>where
_A: DivAssign<_B>,
impl<_A, _B> DivAssign<Frequency<_B>> for Frequency<_A>where
_A: DivAssign<_B>,
Source§fn div_assign(&mut self, rhs: Frequency<_B>)
fn div_assign(&mut self, rhs: Frequency<_B>)
/= operation. Read moreSource§impl<T> From<T> for Frequency<T>where
T: RawFrequency,
impl<T> From<T> for Frequency<T>where
T: RawFrequency,
Source§impl<'a, _A, _B, _C> Mul<&'a mut Frequency<_B>> for Frequency<_A>where
_A: Mul<&'a mut _B, Output = _C>,
impl<'a, _A, _B, _C> Mul<&'a mut Frequency<_B>> for Frequency<_A>where
_A: Mul<&'a mut _B, Output = _C>,
Source§impl<'a, _A, _B, _C> Mul<Frequency<_B>> for &'a mut Frequency<_A>where
&'a mut _A: Mul<_B, Output = _C>,
impl<'a, _A, _B, _C> Mul<Frequency<_B>> for &'a mut Frequency<_A>where
&'a mut _A: Mul<_B, Output = _C>,
Source§impl<_A, _B> MulAssign<Frequency<_B>> for Frequency<_A>where
_A: MulAssign<_B>,
impl<_A, _B> MulAssign<Frequency<_B>> for Frequency<_A>where
_A: MulAssign<_B>,
Source§fn mul_assign(&mut self, rhs: Frequency<_B>)
fn mul_assign(&mut self, rhs: Frequency<_B>)
*= operation. Read moreSource§impl<T> Num for Frequency<T>where
T: Num,
impl<T> Num for Frequency<T>where
T: Num,
type FromStrRadixErr = <T as Num>::FromStrRadixErr
Source§fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>
fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>
2..=36). Read moreSource§impl<T: Ord> Ord for Frequency<T>
impl<T: Ord> Ord for Frequency<T>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<'a, T> PartialOrd<&'a T> for Frequency<T>where
T: PartialOrd,
impl<'a, T> PartialOrd<&'a T> for Frequency<T>where
T: PartialOrd,
Source§impl<'a, T> PartialOrd<&'a mut T> for Frequency<T>where
T: PartialOrd,
impl<'a, T> PartialOrd<&'a mut T> for Frequency<T>where
T: PartialOrd,
Source§impl<T> PartialOrd<T> for Frequency<T>where
T: PartialOrd,
impl<T> PartialOrd<T> for Frequency<T>where
T: PartialOrd,
Source§impl<T: PartialOrd> PartialOrd for Frequency<T>
impl<T: PartialOrd> PartialOrd for Frequency<T>
Source§impl<'a, _A, _B, _C> Rem<&'a mut Frequency<_B>> for Frequency<_A>where
_A: Rem<&'a mut _B, Output = _C>,
impl<'a, _A, _B, _C> Rem<&'a mut Frequency<_B>> for Frequency<_A>where
_A: Rem<&'a mut _B, Output = _C>,
Source§impl<'a, _A, _B, _C> Rem<Frequency<_B>> for &'a mut Frequency<_A>where
&'a mut _A: Rem<_B, Output = _C>,
impl<'a, _A, _B, _C> Rem<Frequency<_B>> for &'a mut Frequency<_A>where
&'a mut _A: Rem<_B, Output = _C>,
Source§impl<_A, _B> RemAssign<Frequency<_B>> for Frequency<_A>where
_A: RemAssign<_B>,
impl<_A, _B> RemAssign<Frequency<_B>> for Frequency<_A>where
_A: RemAssign<_B>,
Source§fn rem_assign(&mut self, rhs: Frequency<_B>)
fn rem_assign(&mut self, rhs: Frequency<_B>)
%= operation. Read moreSource§impl<'a, _A, _B, _C> Shl<&'a mut Frequency<_B>> for Frequency<_A>where
_A: Shl<&'a mut _B, Output = _C>,
impl<'a, _A, _B, _C> Shl<&'a mut Frequency<_B>> for Frequency<_A>where
_A: Shl<&'a mut _B, Output = _C>,
Source§impl<'a, _A, _B, _C> Shl<Frequency<_B>> for &'a mut Frequency<_A>where
&'a mut _A: Shl<_B, Output = _C>,
impl<'a, _A, _B, _C> Shl<Frequency<_B>> for &'a mut Frequency<_A>where
&'a mut _A: Shl<_B, Output = _C>,
Source§impl<_A, _B> ShlAssign<Frequency<_B>> for Frequency<_A>where
_A: ShlAssign<_B>,
impl<_A, _B> ShlAssign<Frequency<_B>> for Frequency<_A>where
_A: ShlAssign<_B>,
Source§fn shl_assign(&mut self, rhs: Frequency<_B>)
fn shl_assign(&mut self, rhs: Frequency<_B>)
<<= operation. Read moreSource§impl<'a, _A, _B, _C> Shr<&'a mut Frequency<_B>> for Frequency<_A>where
_A: Shr<&'a mut _B, Output = _C>,
impl<'a, _A, _B, _C> Shr<&'a mut Frequency<_B>> for Frequency<_A>where
_A: Shr<&'a mut _B, Output = _C>,
Source§impl<'a, _A, _B, _C> Shr<Frequency<_B>> for &'a mut Frequency<_A>where
&'a mut _A: Shr<_B, Output = _C>,
impl<'a, _A, _B, _C> Shr<Frequency<_B>> for &'a mut Frequency<_A>where
&'a mut _A: Shr<_B, Output = _C>,
Source§impl<_A, _B> ShrAssign<Frequency<_B>> for Frequency<_A>where
_A: ShrAssign<_B>,
impl<_A, _B> ShrAssign<Frequency<_B>> for Frequency<_A>where
_A: ShrAssign<_B>,
Source§fn shr_assign(&mut self, rhs: Frequency<_B>)
fn shr_assign(&mut self, rhs: Frequency<_B>)
>>= operation. Read moreSource§impl<'a, _A, _B, _C> Sub<&'a mut Frequency<_B>> for Frequency<_A>where
_A: Sub<&'a mut _B, Output = _C>,
impl<'a, _A, _B, _C> Sub<&'a mut Frequency<_B>> for Frequency<_A>where
_A: Sub<&'a mut _B, Output = _C>,
Source§impl<'a, _A, _B, _C> Sub<Frequency<_B>> for &'a mut Frequency<_A>where
&'a mut _A: Sub<_B, Output = _C>,
impl<'a, _A, _B, _C> Sub<Frequency<_B>> for &'a mut Frequency<_A>where
&'a mut _A: Sub<_B, Output = _C>,
Source§impl<_A, _B> SubAssign<Frequency<_B>> for Frequency<_A>where
_A: SubAssign<_B>,
impl<_A, _B> SubAssign<Frequency<_B>> for Frequency<_A>where
_A: SubAssign<_B>,
Source§fn sub_assign(&mut self, rhs: Frequency<_B>)
fn sub_assign(&mut self, rhs: Frequency<_B>)
-= operation. Read moreimpl<T: Copy> Copy for Frequency<T>
impl<T: Eq> Eq for Frequency<T>
impl<T> StructuralPartialEq for Frequency<T>
Auto Trait Implementations§
impl<T> Freeze for Frequency<T>where
T: Freeze,
impl<T> RefUnwindSafe for Frequency<T>where
T: RefUnwindSafe,
impl<T> Send for Frequency<T>where
T: Send,
impl<T> Sync for Frequency<T>where
T: Sync,
impl<T> Unpin for Frequency<T>where
T: Unpin,
impl<T> UnwindSafe for Frequency<T>where
T: UnwindSafe,
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,
Source§impl<U, T> IntoFrequency<T> for U
impl<U, T> IntoFrequency<T> for U
Source§fn into_frequency(self) -> Frequency<T>
fn into_frequency(self) -> Frequency<T>
Frequency instance.