Trait tune::tuning::Tuning[][src]

pub trait Tuning<K> {
    fn pitch_of(&self, key: K) -> Pitch;
fn find_by_pitch(&self, pitch: Pitch) -> Approximation<K>; fn as_linear_mapping(self) -> LinearMapping<Self>
    where
        Self: Sized
, { ... } }

A Tuning maps keys or notes of type K to a Pitch or vice versa.

Required methods

fn pitch_of(&self, key: K) -> Pitch[src]

Returns the Pitch of the given key or note K in the current Tuning.

Examples

use tune::tuning::Tuning;

let standard_tuning = ConcertPitch::default();
let a5 = NoteLetter::A.in_octave(5);

assert_approx_eq!(standard_tuning.pitch_of(a5).as_hz(), 880.0);

fn find_by_pitch(&self, pitch: Pitch) -> Approximation<K>[src]

Finds a closest key or note Approximation for the given Pitch in the current Tuning.

Examples

use tune::tuning::Tuning;

let standard_tuning = ConcertPitch::default();
let a5 = NoteLetter::A.in_octave(5);
let detuned_a5_pitch = Pitch::of(a5) * Ratio::from_cents(10.0);

let approximation = standard_tuning.find_by_pitch(detuned_a5_pitch);
assert_eq!(approximation.approx_value, a5);
assert_approx_eq!(approximation.deviation.as_cents(), 10.0);
Loading content...

Provided methods

fn as_linear_mapping(self) -> LinearMapping<Self> where
    Self: Sized
[src]

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

Loading content...

Implementations on Foreign Types

impl<S: Borrow<Scl>, K: Borrow<KbmRoot>> Tuning<PianoKey> for (S, K)[src]

impl<S: Borrow<Scl>, K: Borrow<KbmRoot>> Tuning<i32> for (S, K)[src]

impl<K, T: Tuning<K> + ?Sized> Tuning<K> for &T[src]

impl forwarding for references.

impl Tuning<Note> for ()[src]

Convenience implementation enabling to write () instead of ConcertPitch::default().

Examples

use tune::pitch::Pitched;

assert_eq!(Pitch::from_hz(880.0).find_in_tuning(()).approx_value, Note::from_midi_number(81));
Loading content...

Implementors

impl Tuning<Note> for ConcertPitch[src]

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);

impl<S: Scale> Tuning<i32> for SortedTuning<S>[src]

Loading content...