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
impl KeyboardMapping
Sourcepub fn read_kbm_file<P>(fname: P) -> Result<Self, TuningError>
pub fn read_kbm_file<P>(fname: P) -> Result<Self, TuningError>
Returns a KeyboardMapping or an error from a KBM file in fname
.
Sourcepub fn parse_kbm_data(kbm_contents: &str) -> Result<Self, TuningError>
pub fn parse_kbm_data(kbm_contents: &str) -> Result<Self, TuningError>
Returns a KeyboardMapping or an error from a KBM data in memory.
Sourcepub fn tune_a69_to(freq: f64) -> Self
pub fn tune_a69_to(freq: f64) -> Self
Creates a KeyboardMapping which keeps the MIDI note 60 (A4) set to a constant given frequency.
Sourcepub fn tune_note_to(midi_note: i32, freq: f64) -> Self
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.
Sourcepub fn start_scale_on_and_tune_note_to(
scale_start: i32,
midi_note: i32,
freq: f64,
) -> Self
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
impl Clone for KeyboardMapping
Source§fn clone(&self) -> KeyboardMapping
fn clone(&self) -> KeyboardMapping
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read more