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§

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(&notes_map, midi_note, octave);
        if res.is_some() {
            return res.unwrap();
        }
        let scale = key.resolve_scale(&notes_map);

        scale.resolve_pitch(notes_map, midi_note, octave)
    }

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Deserialize this value from the given Serde deserializer. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.