Struct tune::tuning::ConcertPitch
source · [−]pub struct ConcertPitch { /* private fields */ }
Expand description
A ConcertPitch
enables Note
s to sound at a Pitch
different to what would be expected in 440 Hz standard tuning.
To access the full potential of ConcertPitch
es have a look at the Tuning
and PitchedNote
traits.
Implementations
sourceimpl ConcertPitch
impl ConcertPitch
sourcepub fn from_a4_pitch(a4_pitch: impl Pitched) -> Self
pub fn from_a4_pitch(a4_pitch: impl Pitched) -> Self
Creates a ConcertPitch
with the given a4_pitch
.
sourcepub fn from_note_and_pitch(note: Note, pitched: impl Pitched) -> Self
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);
Trait Implementations
sourceimpl Clone for ConcertPitch
impl Clone for ConcertPitch
sourcefn clone(&self) -> ConcertPitch
fn clone(&self) -> ConcertPitch
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for ConcertPitch
impl Debug for ConcertPitch
sourceimpl Default for ConcertPitch
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);
sourceimpl PartialEq<ConcertPitch> for ConcertPitch
impl PartialEq<ConcertPitch> for ConcertPitch
sourcefn eq(&self, other: &ConcertPitch) -> bool
fn eq(&self, other: &ConcertPitch) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &ConcertPitch) -> bool
fn ne(&self, other: &ConcertPitch) -> bool
This method tests for !=
.
sourceimpl PartialOrd<ConcertPitch> for ConcertPitch
impl PartialOrd<ConcertPitch> for ConcertPitch
sourcefn partial_cmp(&self, other: &ConcertPitch) -> Option<Ordering>
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 · sourcefn lt(&self, other: &Rhs) -> bool
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 · sourcefn le(&self, other: &Rhs) -> bool
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
sourceimpl Tuning<Note> for ConcertPitch
impl Tuning<Note> for ConcertPitch
A ConcertPitch
maps Note
s to Pitch
es 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);
sourcefn find_by_pitch(&self, pitch: Pitch) -> Approximation<Note>
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
sourcefn as_linear_mapping(self) -> LinearMapping<Self> where
Self: Sized,
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>
.
impl Copy for ConcertPitch
impl StructuralPartialEq for ConcertPitch
Auto Trait Implementations
impl RefUnwindSafe for ConcertPitch
impl Send for ConcertPitch
impl Sync for ConcertPitch
impl Unpin for ConcertPitch
impl UnwindSafe for ConcertPitch
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more