[][src]Struct tune::pitch::Pitch

pub struct Pitch { /* fields omitted */ }

Struct representing the frequency of a pitch.

You can retrieve the absolute frequency of a Pitch in Hz via Pitch::as_hz. Alternatively, Pitches can interact with Ratios 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.

impl FromStr for Pitch[src]

type Err = String

The associated error which can be returned from parsing.

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.

impl PartialEq<Pitch> for Pitch[src]

impl PartialOrd<Pitch> for Pitch[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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.