Struct musical_note::ResolvedScale
source · pub struct ResolvedScale {
pub key: Key,
pub degree_midi: [u8; 7],
pub degree_notes: [(NoteName, Accidental); 7],
pub used_accidentals: Vec<Accidental>,
}Expand description
Concrete Scale representation, based on the given root note.
Used to estimate alteration for notes, can be alterated by scale rules.
Fields§
§key: Key§degree_midi: [u8; 7]0..12 midi bytes, representing every grade of the scale.
E.g. for C-Dur it would be: [0, 2, 4, 5, 7, 9, 11],
and for A-moll: [9, 11, 0, 2, 4, 5, 7]
degree_notes: [(NoteName, Accidental); 7]the same, but, holding Tuples of note names and accidentals.
used_accidentals: Vec<Accidental>Collects accidentals, used for degrees to estimate, which alteration of non-degree notes is preferable. TODO: think on using this as weight.
Implementations§
source§impl ResolvedScale
impl ResolvedScale
sourcepub fn resolve_pitch(
&self,
notes_map: &NotesMap,
midi_note: u8,
octave: Octave
) -> ResolvedNote
pub fn resolve_pitch(
&self,
notes_map: &NotesMap,
midi_note: u8,
octave: Octave
) -> ResolvedNote
Examples found in repository?
src/lib.rs (line 262)
252 253 254 255 256 257 258 259 260 261 262 263
pub fn resolve(&self, key: Key) -> ResolvedNote {
let (midi_note, octave) = Octave::split_midi(self.midi);
// let midi_note = self.midi % 12;
let notes_map = NotesMap::get();
let res = self.resolve_by_accident(¬es_map, midi_note, octave);
if res.is_some() {
return res.unwrap();
}
let scale = key.resolve_scale(¬es_map);
scale.resolve_pitch(notes_map, midi_note, octave)
}Trait Implementations§
source§impl Clone for ResolvedScale
impl Clone for ResolvedScale
source§fn clone(&self) -> ResolvedScale
fn clone(&self) -> ResolvedScale
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for ResolvedScale
impl Debug for ResolvedScale
source§impl<'de> Deserialize<'de> for ResolvedScale
impl<'de> Deserialize<'de> for ResolvedScale
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl PartialEq<ResolvedScale> for ResolvedScale
impl PartialEq<ResolvedScale> for ResolvedScale
source§fn eq(&self, other: &ResolvedScale) -> bool
fn eq(&self, other: &ResolvedScale) -> bool
This method tests for
self and other values to be equal, and is used
by ==.