pub struct Alterations {
pub no: No,
pub seventh: Seventh,
pub slash: Option<Note>,
/* private fields */
}Expand description
Represents a list of all the alterations presented in a chord.
This struct provides a simple and intuitive way to add alterations using the safe included methods.
Fields§
§no: NoRepresents an omitted tone in the
seventh: SeventhRepresents a seventh in the chord
slash: Option<Note>Represents the bass note override (slash chord)
Implementations§
Source§impl Alterations
impl Alterations
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new empty instance of Alterations.
§Examples
use chord_parser::chord::*;
let mut alterations = Alterations::new();
// Do whatever
alterations.set_suspension(&AlteredInterval::Fourth);Sourcepub fn alters(&self) -> &Vec<ChordAlter>
pub fn alters(&self) -> &Vec<ChordAlter>
Returns a list of all the added alterations.
§Examples
use chord_parser::chord::*;
let mut alterations = Alterations::new();
alterations.set_note(&ChordNoteAlter {
interval: AlteredInterval::Ninth,
accidental: Accidental::Sharp,
});
alterations.set_suspension(&AlteredInterval::Fourth);
alterations.alters(); // Returns the added ninth and suspended fourthSourcepub fn get_note(&self, interval: &AlteredInterval) -> Option<&ChordNoteAlter>
pub fn get_note(&self, interval: &AlteredInterval) -> Option<&ChordNoteAlter>
Tries to get a note alteration associated with the passed interval.
§Examples
use chord_parser::chord::*;
let mut alterations = Alterations::new();
alterations.set_note(&ChordNoteAlter {
interval: AlteredInterval::Ninth,
accidental: Accidental::Sharp,
});
alterations.get_note(&AlteredInterval::Ninth); // Returns the interval and accidentalSourcepub fn get_accidental(&self, interval: &AlteredInterval) -> Option<Accidental>
pub fn get_accidental(&self, interval: &AlteredInterval) -> Option<Accidental>
Tries to get the accidental altered for an interval.
§Examples
use chord_parser::chord::*;
let mut alterations = Alterations::new();
alterations.set_note(&ChordNoteAlter {
interval: AlteredInterval::Ninth,
accidental: Accidental::Sharp,
});
alterations.get_accidental(&AlteredInterval::Ninth); // Returns Accidental::SharpSourcepub fn set_note(&mut self, alter: &ChordNoteAlter)
pub fn set_note(&mut self, alter: &ChordNoteAlter)
Set a new alteration for an interval.
If an alteration for the interval already exists, the accidental will be overwritten. If it doesn’t exist, a new alteration is added.
§Examples
use chord_parser::chord::*;
let mut alterations = Alterations::new();
alterations.set_note(&ChordNoteAlter {
interval: AlteredInterval::Ninth,
accidental: Accidental::Sharp,
});
// Now the 9th is flatten
alterations.set_note(&ChordNoteAlter {
interval: AlteredInterval::Ninth,
accidental: Accidental::Flat,
});
alterations.set_note(&ChordNoteAlter {
interval: AlteredInterval::Eleventh,
accidental: Accidental::Sharp,
});
// Get back all the 2 alterations added
alterations.alters();Sourcepub fn get_suspension(&self) -> Option<&AlteredInterval>
pub fn get_suspension(&self) -> Option<&AlteredInterval>
Tries to get the suspended note alteration in the chord
§Examples
use chord_parser::chord::*;
let mut alterations = Alterations::new();
alterations.set_suspension(&AlteredInterval::Fourth);
alterations.get_suspension(); // Returns Some(&AlteredInterval::Fourth)Sourcepub fn set_suspension(&mut self, interval: &AlteredInterval)
pub fn set_suspension(&mut self, interval: &AlteredInterval)
Set the new suspended interval.
Old suspended interval will be replaced with the new one, if the old interval is present.
§Examples
use chord_parser::chord::*;
let mut alterations = Alterations::new();
alterations.set_suspension(&AlteredInterval::Second);
alterations.get_suspension(); // Returns Some(&AlteredInterval::Second)Trait Implementations§
Source§impl Clone for Alterations
impl Clone for Alterations
Source§fn clone(&self) -> Alterations
fn clone(&self) -> Alterations
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more