Struct tune::scala::KbmRoot [−][src]
Defines an absolute horizontal and vertical location of a scale.
KbmRoot
is intended to be used in combination with Scl
to form a Tuning
.
The interesting thing about a Tuning
is that it offers a bidirectional key-to-pitch mapping.
This means it is possible to find the best matching PianoKey
for a given Pitch
input.
The pitch input can be a continuous value, e.g. the location of a mouse pointer.
In order to enable invertibility the mapping described by KbmRoot
is linear.
In other words, the keyboard mapping degree and the scale degree are the same number.
If the mapping is required to be non-linear KbmRoot
needs to be surrounded by the more general Kbm
struct.
Fields
origin: PianoKey
The PianoKey
that maps to degree 0 of the keyboard mapping.
If a Kbm
surrounding is used with the first entry being n, origin
maps to scale degree n.
ref_pitch: Pitch
A Pitch
that is guaranteed to be present in a Tuning
but which might be skipped in the KeyboardMapping
spanned by the Kbm
surrounding.
ref_degree: i32
The scale degree for which ref_pitch
is given as a reference.
Implementations
impl KbmRoot
[src]
pub fn shift_origin_by(self, num_degrees: i32) -> Self
[src]
Shifts the origin
of a scale by num_degrees
conserving the scale’s vertical location.
Examples
let kbm_root = KbmRoot { origin: PianoKey::from_midi_number(67), ref_pitch: Pitch::from_hz(432.0), ref_degree: 2, }; assert_eq!( kbm_root.shift_origin_by(-7), KbmRoot { origin: PianoKey::from_midi_number(60), ref_pitch: Pitch::from_hz(432.0), ref_degree: 9, } );
pub fn to_kbm(self) -> Kbm
[src]
Creates a quasi-equivalent Kbm
surrounding which can be exported.
Examples
let kbm_root = KbmRoot::from(Note::from_midi_number(62)); let kbm = kbm_root.to_kbm(); assert_eq!(kbm.kbm_root(), kbm_root); assert_eq!(kbm.range(), PianoKey::from_midi_number(0)..PianoKey::from_midi_number(128)); assert_eq!(kbm.formal_octave(), 1); assert_eq!(kbm.num_items(), 1); assert_eq!(kbm.scale_degree_of(PianoKey::from_midi_number(61)), Some(-1)); assert_eq!(kbm.scale_degree_of(PianoKey::from_midi_number(62)), Some(0)); assert_eq!(kbm.scale_degree_of(PianoKey::from_midi_number(63)), Some(1)); let exported = kbm.export();
Trait Implementations
impl Clone for KbmRoot
[src]
impl Copy for KbmRoot
[src]
impl Debug for KbmRoot
[src]
impl<N: PitchedNote> From<N> for KbmRoot
[src]
impl FromStr for KbmRoot
[src]
type Err = String
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>
[src]
impl PartialEq<KbmRoot> for KbmRoot
[src]
impl StructuralPartialEq for KbmRoot
[src]
Auto Trait Implementations
impl RefUnwindSafe for KbmRoot
impl Send for KbmRoot
impl Sync for KbmRoot
impl Unpin for KbmRoot
impl UnwindSafe for KbmRoot
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,