Trait tune::tuning::KeyboardMapping [−][src]
Similar to a Tuning
but not designed to be surjective or injecive.
An inversion operation is not provided.
In return, zero or multiple keys/notes can point to a Pitch
.
Required methods
fn maybe_pitch_of(&self, key: K) -> Option<Pitch>
[src]
Returns the Pitch
of the provided key or note.
Implementations on Foreign Types
impl<S: Borrow<Scl>, K: Borrow<Kbm>> KeyboardMapping<PianoKey> for (S, K)
[src]
An (Scl
, Kbm
) pair has the complete information to define a KeyboardMapping
.
Examples
use tune::tuning::KeyboardMapping; let scl = Scl::builder() .push_cents(100.0) .build() .unwrap(); let kbm = Kbm::builder(Note::from_midi_number(62)) .push_mapped_key(0) .push_mapped_key(4) .push_unmapped_key() .push_mapped_key(4) .formal_octave(12) .build() .unwrap(); let f = |midi_number| (&scl, &kbm).maybe_pitch_of(PianoKey::from_midi_number(midi_number)); assert_approx_eq!(f(62).unwrap().as_hz(), 293.664768); assert_approx_eq!(f(63).unwrap().as_hz(), 369.994423); assert!(f(64).is_none()); assert_approx_eq!(f(65).unwrap().as_hz(), 369.994423); assert_approx_eq!(f(66).unwrap().as_hz(), 587.329536);
fn maybe_pitch_of(&self, key: PianoKey) -> Option<Pitch>
[src]
impl<S: Borrow<Scl>, K: Borrow<Kbm>> KeyboardMapping<i32> for (S, K)
[src]
fn maybe_pitch_of(&self, mapping_degree: i32) -> Option<Pitch>
[src]
impl<K, T: KeyboardMapping<K> + ?Sized> KeyboardMapping<K> for &T
[src]
impl
forwarding for references.