[−][src]Struct tune::pitch::Pitch
Struct representing the frequency of a pitch.
You can retrieve the absolute frequency of a Pitch
in Hz via Pitch::as_hz
.
Alternatively, Pitch
es can interact with Ratio
s using Ratio::between_pitches
or the Mul
/Div
operators.
Implementations
impl Pitch
[src]
pub fn from(pitched: impl Pitched) -> Pitch
[src]
Shortcut for Pitched::pitch
.
Examples
use tune::pitch::Pitched; let note = NoteLetter::C.in_octave(4); assert_approx_eq!(Pitch::from(note).as_hz(), note.pitch().as_hz());
pub fn from_hz(hz: f64) -> Pitch
[src]
pub fn as_hz(self) -> f64
[src]
pub fn find_in<N, T: Tuning<N>>(self, approx: &T) -> Approximation<N>
[src]
Shortcut for Tuning::find_by_pitch
.
Examples
use tune::tuning::Tuning; let tuning = ConcertPitch::from_a4_pitch(Pitch::from_hz(432.0)); let pitch_to_find = Pitch::from_hz(100.0); let shortcut = pitch_to_find.find_in(&tuning); let regular = tuning.find_by_pitch(pitch_to_find); assert_eq!(shortcut.approx_value, regular.approx_value); assert_eq!(shortcut.deviation, regular.deviation);
Trait Implementations
impl Clone for Pitch
[src]
impl Copy for Pitch
[src]
impl Debug for Pitch
[src]
impl Div<Ratio> for Pitch
[src]
Lower a Pitch
by a given Ratio
.
Examples
assert_approx_eq!((Pitch::from_hz(330.0) / Ratio::from_float(1.5)).as_hz(), 220.0);
type Output = Pitch
The resulting type after applying the /
operator.
fn div(self, rhs: Ratio) -> Self::Output
[src]
impl FromStr for Pitch
[src]
type Err = String
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>
[src]
impl Mul<Ratio> for Pitch
[src]
Raise a Pitch
by a given Ratio
.
Examples
assert_approx_eq!((Pitch::from_hz(220.0) * Ratio::from_float(1.5)).as_hz(), 330.0);
type Output = Pitch
The resulting type after applying the *
operator.
fn mul(self, rhs: Ratio) -> Self::Output
[src]
impl PartialEq<Pitch> for Pitch
[src]
impl PartialOrd<Pitch> for Pitch
[src]
fn partial_cmp(&self, other: &Pitch) -> Option<Ordering>
[src]
fn lt(&self, other: &Pitch) -> bool
[src]
fn le(&self, other: &Pitch) -> bool
[src]
fn gt(&self, other: &Pitch) -> bool
[src]
fn ge(&self, other: &Pitch) -> bool
[src]
impl Pitched for Pitch
[src]
impl StructuralPartialEq for Pitch
[src]
Auto Trait Implementations
impl RefUnwindSafe for Pitch
impl Send for Pitch
impl Sync for Pitch
impl Unpin for Pitch
impl UnwindSafe for Pitch
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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
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>,