Alterations

Struct Alterations 

Source
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: No

Represents an omitted tone in the

§seventh: Seventh

Represents a seventh in the chord

§slash: Option<Note>

Represents the bass note override (slash chord)

Implementations§

Source§

impl Alterations

Source

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);
Source

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 fourth
Source

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 accidental
Source

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::Sharp
Source

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();
Source

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)
Source

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

Source§

fn clone(&self) -> Alterations

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

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Alterations

Source§

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

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

impl PartialEq for Alterations

Source§

fn eq(&self, other: &Alterations) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl ToString for Alterations

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl Eq for Alterations

Source§

impl StructuralPartialEq for Alterations

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.