Struct tune::tuning::ConcertPitch

source ·
pub struct ConcertPitch { /* private fields */ }
Expand description

A ConcertPitch enables Notes to sound at a Pitch different to what would be expected in 440 Hz standard tuning.

To access the full potential of ConcertPitches have a look at the Tuning and PitchedNote traits.

Implementations§

source§

impl ConcertPitch

source

pub fn from_a4_pitch(a4_pitch: impl Pitched) -> Self

Creates a ConcertPitch with the given a4_pitch.

source

pub fn from_note_and_pitch(note: Note, pitched: impl Pitched) -> Self

Creates a ConcertPitch from the given note and pitched value.

Examples
let c4 = NoteLetter::C.in_octave(4);
let fixed_c4_tuning = ConcertPitch::from_note_and_pitch(c4, Pitch::from_hz(260.0));
assert_approx_eq!(fixed_c4_tuning.a4_pitch().as_hz(), 437.266136);
source

pub fn a4_pitch(self) -> Pitch

Returns the Pitch of A4.

Trait Implementations§

source§

impl Clone for ConcertPitch

source§

fn clone(&self) -> ConcertPitch

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ConcertPitch

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for ConcertPitch

The default ConcertPitch is A4 sounding at 440 Hz.

Examples

assert_approx_eq!(ConcertPitch::default().a4_pitch().as_hz(), 440.0);
source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl PartialEq for ConcertPitch

source§

fn eq(&self, other: &ConcertPitch) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for ConcertPitch

source§

fn partial_cmp(&self, other: &ConcertPitch) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Tuning<Note> for ConcertPitch

A ConcertPitch maps Notes to Pitches and is considered a Tuning.

Examples

use tune::tuning::Tuning;

let c4 = NoteLetter::C.in_octave(4);
let a4 = NoteLetter::A.in_octave(4);

let standard_tuning = ConcertPitch::default();
assert_approx_eq!(standard_tuning.pitch_of(c4).as_hz(), 261.625565);
assert_approx_eq!(standard_tuning.pitch_of(a4).as_hz(), 440.0);

let healing_tuning = ConcertPitch::from_a4_pitch(Pitch::from_hz(432.0));
assert_approx_eq!(healing_tuning.pitch_of(c4).as_hz(), 256.868737);
assert_approx_eq!(healing_tuning.pitch_of(a4).as_hz(), 432.0);
source§

fn pitch_of(&self, note: Note) -> Pitch

Returns the Pitch of the given key or note K in the current Tuning. Read more
source§

fn find_by_pitch(&self, pitch: Pitch) -> Approximation<Note>

Finds a closest key or note Approximation for the given Pitch in the current Tuning. Read more
source§

fn as_linear_mapping(self) -> LinearMapping<Self>
where Self: Sized,

Wraps self in a type adapter s.t. it can be used in functions that are generic over KeyboardMapping<K>.
source§

impl Copy for ConcertPitch

source§

impl StructuralPartialEq for ConcertPitch

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.