pub struct ChordSymbol { /* private fields */ }Expand description
Parsed chord symbol.
Implementations§
Source§impl ChordSymbol
impl ChordSymbol
Sourcepub fn parse(figure: impl Into<String>) -> Result<Self>
pub fn parse(figure: impl Into<String>) -> Result<Self>
Parses a chord symbol such as "Cmaj7", "F#m7b5", or "Bb7#11".
A b after the root’s letter is read as a flat, as a lead sheet
writes one; Self::parse_music21 reads a figure as music21 does.
Sourcepub fn parse_music21(figure: impl Into<String>) -> Result<Self>
pub fn parse_music21(figure: impl Into<String>) -> Result<Self>
Parses a figure exactly as music21’s ChordSymbol reads one, where
a root or a bass is a letter with only # and - after it. A b
is not a flat there: Bb7 is a B major triad with a flattened
seventh added, and Ebmaj7 is no figure at all, since bmaj7 names
no kind.
The root is the letter at the front, or everything before a comma;
the bass is a / and a letter wherever it stands, so C/B- add 2
adds a second to a C triad over B flat; and what is left names one
of music21’s kinds and its modifications, or is a list of degrees
over no kind at all — C35b7 is a root with a third, a fifth and a
flat seventh added to it. Anything else is refused with music21’s
words.
Sourcepub fn no_chord(text: Option<String>) -> Self
pub fn no_chord(text: Option<String>) -> Self
A symbol saying nothing sounds, written N.C. unless text says
otherwise: music21’s NoChord, whose kind is none. It has a root
only because every symbol has one; it sounds no pitches at all.
Sourcepub fn lyrics_mut(&mut self) -> &mut Vec<Lyric>
pub fn lyrics_mut(&mut self) -> &mut Vec<Lyric>
The same, for editing in place.
Sourcepub fn add_lyric(
&mut self,
text: &str,
number: Option<IntegerType>,
apply_raw: bool,
)
pub fn add_lyric( &mut self, text: &str, number: Option<IntegerType>, apply_raw: bool, )
Adds a syllable as a verse, as crate::note::Note::add_lyric does:
music21’s addLyric.
Sourcepub fn is_no_chord(&self) -> bool
pub fn is_no_chord(&self) -> bool
Whether this says nothing sounds: music21’s NoChord.
Sourcepub fn kind_text(&self) -> Option<&str>
pub fn kind_text(&self) -> Option<&str>
How the kind is written where a score says, as M for a major
triad: music21’s chordKindStr.
Sourcepub fn set_kind_text(&mut self, text: Option<String>)
pub fn set_kind_text(&mut self, text: Option<String>)
Says how the kind is written.
Sourcepub fn placement(&self) -> Option<Placement>
pub fn placement(&self) -> Option<Placement>
Which side of the staff the symbol is written on, where a score says.
Sourcepub fn set_placement(&mut self, placement: Option<Placement>)
pub fn set_placement(&mut self, placement: Option<Placement>)
Says which side of the staff the symbol is written on.
Sourcepub fn duration(&self) -> &Duration
pub fn duration(&self) -> &Duration
How long the symbol holds. A symbol as written takes no time, which
is music21’s default; realize_chord_symbol_durations gives each
one in a stream the time until the next.
Sourcepub fn set_duration(&mut self, duration: Duration)
pub fn set_duration(&mut self, duration: Duration)
Says how long the symbol holds.
Sourcepub fn with_duration(self, duration: Duration) -> Self
pub fn with_duration(self, duration: Duration) -> Self
The same symbol holding for a given time.
Sourcepub fn kind(&self) -> Option<&str>
pub fn kind(&self) -> Option<&str>
music21’s chordKind: the kind the shorthand names, where it is one
of music21’s abbreviations, so Cmaj7 is major-seventh and CN6
the Neapolitan. None for a shorthand the crate reads on its own.
Sourcepub fn quality(&self) -> ChordQuality
pub fn quality(&self) -> ChordQuality
Returns the parsed chord quality.
Sourcepub fn extensions(&self) -> &[u8] ⓘ
pub fn extensions(&self) -> &[u8] ⓘ
Returns parsed extension degrees.
Sourcepub fn alterations(&self) -> &[ChordAlteration]
pub fn alterations(&self) -> &[ChordAlteration]
Returns parsed alterations.
Sourcepub fn additions(&self) -> &[ChordAlteration]
pub fn additions(&self) -> &[ChordAlteration]
Returns parsed added tones from add(...) groups.
Sourcepub fn find_figure(&self) -> String
pub fn find_figure(&self) -> String
Rebuilds the figure from the parsed parts in one canonical spelling:
music21’s findFigure. Whatever was typed, a half-diminished seventh
comes back as m7b5, an augmented triad as aug, an added ninth as
add(9), and the result parses back to the same chord.
Sourcepub fn transpose(&self, interval: &Interval) -> Result<ChordSymbol>
pub fn transpose(&self, interval: &Interval) -> Result<ChordSymbol>
The same chord on a transposed root and bass, its figure rebuilt by
Self::find_figure: music21’s transpose, so B-/D up a major
second is C/E.
Sourcepub fn inversion_is_valid(&self, inversion: u8) -> bool
pub fn inversion_is_valid(&self, inversion: u8) -> bool
Whether the chord can stand in the given inversion: music21’s
inversionIsValid, which reads the kind — first and second
inversions for anything but a pedal, a third for the sevenths and
the stacked kinds above them, a fourth for the ninths and up, a fifth
for the elevenths and thirteenths. A shorthand naming no kind of
music21’s is read by the extensions the crate found in it. Root
position is not an inversion.
Sourcepub fn chord_step_modifications(&self) -> &[ChordStepModification]
pub fn chord_step_modifications(&self) -> &[ChordStepModification]
The degrees added to, taken from or altered in the kind: music21’s
chordStepModifications, read off the figure or handed over.
Sourcepub fn add_chord_step_modification(
&mut self,
modification: ChordStepModification,
)
pub fn add_chord_step_modification( &mut self, modification: ChordStepModification, )
Adds a chord-step modification, which the next realization applies:
music21’s addChordStepModification. One already there is not added
twice.
Sourcepub fn set_chord_step_modifications(
&mut self,
modifications: Vec<ChordStepModification>,
)
pub fn set_chord_step_modifications( &mut self, modifications: Vec<ChordStepModification>, )
Replaces every chord-step modification at once.
Sourcepub fn from_kind(root: Pitch, kind: &str, bass: Option<Pitch>) -> Result<Self>
pub fn from_kind(root: Pitch, kind: &str, bass: Option<Pitch>) -> Result<Self>
A symbol given as MusicXML gives one: a root, one of music21’s chord kinds, and a bass where it is not the root, rather than a figure. The figure is written as music21 would write that kind.
Sourcepub fn with_kind(self, kind: &str) -> Self
pub fn with_kind(self, kind: &str) -> Self
The same symbol as a chord of another kind, with no modifications: a kind music21’s table has been given while a program runs, which the crate’s own table has not got.
Sourcepub fn to_chord(&self) -> Result<Chord>
pub fn to_chord(&self) -> Result<Chord>
Realizes the symbol as a chord: Self::pitches, sounding
together.
Sourcepub fn pitches(&self) -> Result<Vec<Pitch>>
pub fn pitches(&self) -> Result<Vec<Pitch>>
The pitches the symbol sounds, with their octaves, lowest first:
music21’s ChordSymbol._updatePitches.
The root is taken from octave three and the kind laid out above it; a
ninth, eleventh or thirteenth has its upper notes lifted an octave; a
bass the kind can invert onto is put under the chord by raising the
notes below it, and one it cannot is added an octave under the root;
the chord-step modifications are applied; and the whole is moved down
until nothing is above the D over middle C, or up until nothing is
below the piano’s lowest A. So C/E is E3 G3 C4, C11 is C2 E2 G2 Bb2 D3 F3, and Gm/F# is F#2 G3 Bb3 D4.
A shorthand naming none of music21’s kinds is laid out the same way from the crate’s own reading of it.
Trait Implementations§
Source§impl Clone for ChordSymbol
impl Clone for ChordSymbol
Source§impl Debug for ChordSymbol
impl Debug for ChordSymbol
Source§impl<'de> Deserialize<'de> for ChordSymbol
Available on crate feature serde only.
impl<'de> Deserialize<'de> for ChordSymbol
serde only.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>,
Source§impl From<ChordSymbol> for StreamElement
impl From<ChordSymbol> for StreamElement
Source§fn from(value: ChordSymbol) -> Self
fn from(value: ChordSymbol) -> Self
Source§impl FromStr for ChordSymbol
impl FromStr for ChordSymbol
Source§impl PartialEq for ChordSymbol
impl PartialEq for ChordSymbol
Source§impl Serialize for ChordSymbol
Available on crate feature serde only.
impl Serialize for ChordSymbol
serde only.impl StructuralPartialEq for ChordSymbol
Source§impl TryFrom<&str> for ChordSymbol
impl TryFrom<&str> for ChordSymbol
Auto Trait Implementations§
impl Freeze for ChordSymbol
impl RefUnwindSafe for ChordSymbol
impl Send for ChordSymbol
impl Sync for ChordSymbol
impl Unpin for ChordSymbol
impl UnsafeUnpin for ChordSymbol
impl UnwindSafe for ChordSymbol
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more