Struct KeyboardMapping

Source
pub struct KeyboardMapping {
    pub first_midi: i32,
    pub last_midi: i32,
    pub middle_note: i32,
    pub tuning_constant_note: i32,
    pub tuning_frequency: f64,
    pub tuning_pitch: f64,
    pub octave_degrees: i32,
    pub keys: Vec<i32>,
    pub raw_text: String,
    pub name: String,
    /* private fields */
}
Expand description

The KeyboardMapping struct represents a KBM file.

In most cases, the salient features are the KeyboardMapping::tuning_constant_note and KeyboardMapping::tuning_frequency, which allow you to pick a fixed note in the MIDI keyboard when retuning. The KBM file can also remap individual keys to individual points in a scale, which here is done with the keys vector.

Just as with Scale the KeyboardMapping::raw_text member contains the text of the KBM file used.

Fields§

§first_midi: i32

First MIDI note to be mapped.

§last_midi: i32

Last MIDI note to be mapped.

§middle_note: i32

Middle MIDI note.

§tuning_constant_note: i32

MIDI note to be tuned.

§tuning_frequency: f64

Frequency of the tuned note.

§tuning_pitch: f64

Pitch of the tuned note. Equal to tuning_frequency / MIDI_0_FREQ.

§octave_degrees: i32

Number of octave degrees.

§keys: Vec<i32>

Mapped keys. Rather than an ‘x’, we use a ‘-1’ for skipped notes (this should use Option or similar).

§raw_text: String

Raw text of the KBM file.

§name: String

Name of the mapping.

Implementations§

Source§

impl KeyboardMapping

Source

pub fn new() -> Self

Constructs a default KeyboardMapping.

Source

pub fn count(&self) -> usize

Number of keys in the mapping.

Source

pub fn read_kbm_file<P>(fname: P) -> Result<Self, TuningError>
where P: AsRef<Path>,

Returns a KeyboardMapping or an error from a KBM file in fname.

Source

pub fn parse_kbm_data(kbm_contents: &str) -> Result<Self, TuningError>

Returns a KeyboardMapping or an error from a KBM data in memory.

Source

pub fn tune_a69_to(freq: f64) -> Self

Creates a KeyboardMapping which keeps the MIDI note 60 (A4) set to a constant given frequency.

Source

pub fn tune_note_to(midi_note: i32, freq: f64) -> Self

Creates a KeyboardMapping which keeps the MIDI note given set to a constant given frequency.

Source

pub fn start_scale_on_and_tune_note_to( scale_start: i32, midi_note: i32, freq: f64, ) -> Self

Generates a KBM where scale_start is the note 0 of the scale, where midi_note is the tuned note, and where freq is the frequency.

Trait Implementations§

Source§

impl Clone for KeyboardMapping

Source§

fn clone(&self) -> KeyboardMapping

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for KeyboardMapping

Source§

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

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

impl Default for KeyboardMapping

Source§

fn default() -> KeyboardMapping

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

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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>,

Source§

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>,

Source§

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.