Skip to main content

Chord

Struct Chord 

Source
pub struct Chord { /* private fields */ }
Expand description

A collection of notes analyzed as one vertical sonority.

Chord accepts several note-like inputs, including whitespace-separated pitch names, slices of pitches or notes, MIDI pitch numbers, vectors, and None for an empty chord.

Implementations§

Source§

impl Chord

Source

pub fn known_chord_types() -> Vec<KnownChordType>

Returns the unpitched chord types known to the music21-derived table.

Source

pub fn pitched_common_name(&self) -> String

Returns the primary music21-style common name with a pitch prefix.

Source

pub fn pitched_common_names(&self) -> Vec<String>

Returns every known music21-style common name with pitch prefixes.

Most chords have a single common name, while some Forte-table entries have aliases. This method exposes all of them in table order.

Source

pub fn chord_symbol(&self) -> Option<String>

Returns the preferred chord symbol, when available.

This is separate from Self::pitched_common_name: common names follow the music21/Forte tables, while chord symbols use music21-style figures such as Cmaj7, F#m7b5, or Ddom7dim5/CaddA,E-.

Source

pub fn chord_symbols(&self) -> Vec<String>

Returns ranked chord symbols for this pitch-class set.

Empty and microtonal chords return no symbols because this notation layer assumes twelve-tone equal-tempered pitch classes.

Source

pub fn chord_symbol_with_root( &self, root: impl Into<PitchClassSpecifier>, ) -> Result<Option<String>>

Returns the preferred chord symbol using an explicit root.

This is useful for pitch-class sets and browser tables where the caller already knows the harmonic spelling anchor and does not want an inversion/root inference pass to choose another chord member. String roots are parsed as pitch names; numeric roots are parsed as pitch classes, so use numbers for pitch-class-only values such as 10 or 11.

Source

pub fn chord_symbols_with_root( &self, root: impl Into<PitchClassSpecifier>, ) -> Result<Vec<String>>

Returns ranked chord symbols using an explicit root.

Empty, microtonal, and rootless-with-respect-to-the-given-root chords return no symbols. Non-integer roots are rejected because chord symbols are generated in twelve-tone pitch-class space.

Source

pub fn common_name(&self) -> String

Returns the primary unpitched music21-style common name.

For chords with multiple table aliases, this is the first common name in table order. Use Self::common_names to get every unpitched alias.

Source

pub fn common_names(&self) -> Vec<String>

Returns all unpitched common-name aliases known for this chord.

Source

pub fn root_pitch_name(&self) -> Option<String>

Returns the inferred root pitch name when the chord has one.

Returns None for empty chords, where there is no pitch from which a root can be inferred.

Source

pub fn bass_pitch_name(&self) -> Option<String>

Returns the lowest pitch name in the chord.

Returns None for empty chords, where there is no bass pitch.

Source

pub fn full_name(&self) -> String

Returns music21’s fullName: the pitches’ full names between braces, followed by the duration’s full name when the chord has a duration that music21 can name.

Source§

impl Chord

Source

pub fn has_component_volumes(&self) -> bool

Whether every note carries a volume of its own: music21’s hasComponentVolumes, which counts the notes that have one and compares the count against the whole chord. A chord where only some notes have been given a volume reads as having none.

Source

pub fn volume(&self) -> Volume

How loud the chord is. With volumes on its notes this is their average velocity, as music21 reads it; otherwise it is the chord’s own volume.

Source

pub fn set_volume(&mut self, volume: Option<Volume>)

Sets the chord’s own volume, which drops any the notes carried.

Source

pub fn set_volumes(&mut self, volumes: &[Volume]) -> Result<()>

Gives each note a volume from the list, cycling through it when the chord has more notes than the list has volumes: music21’s setVolumes. The chord’s own volume is dropped.

Source

pub fn color(&self) -> Option<&str>

The colour the chord is written in, when the chord itself carries one rather than its notes.

Source

pub fn set_color(&mut self, color: Option<String>)

Sets the colour the chord as a whole is written in.

Source

pub fn notehead(&self) -> Notehead

The shape the chord as a whole is drawn with: music21’s notehead, which a chord has in its own right and not only through its notes.

Source

pub fn set_notehead(&mut self, notehead: Notehead)

Sets that shape.

Source

pub fn notehead_fill(&self) -> Option<bool>

Whether the chord’s own note heads are filled, when it says.

Source

pub fn set_notehead_fill(&mut self, fill: Option<bool>)

Says whether they are filled.

Source

pub fn notehead_parenthesis(&self) -> bool

Whether the chord’s own note heads are bracketed.

Source

pub fn set_notehead_parenthesis(&mut self, parenthesis: bool)

Says whether they are bracketed.

Source

pub fn stem_direction(&self) -> StemDirection

Which way the chord’s own stem points.

Source

pub fn set_stem_direction(&mut self, direction: StemDirection)

Sets which way it points.

Source

pub fn beams(&self) -> &Beams

The beams joining the chord’s flags to its neighbours’.

Source

pub fn set_beams(&mut self, beams: Beams)

Replaces those beams.

Source

pub fn color_of_pitch(&self, pitch: &Pitch) -> Option<&str>

The colour a pitch is written in: the note’s own colour when it has one, and the chord’s otherwise, as music21’s getColor reads it.

Source

pub fn tie(&self) -> Option<&Tie>

The tie of the first note that carries one: music21’s chord-level tie.

Source

pub fn set_tie(&mut self, tie: Option<Tie>)

Ties every note in the chord, or unties them all with None.

Source

pub fn lyrics(&self) -> &[Lyric]

The syllables sung on the chord, kept on its first note as music21 keeps them on the chord itself.

Source

pub fn add_lyric( &mut self, text: &str, number: Option<IntegerType>, apply_raw: bool, ) -> Result<()>

Adds a syllable as the next verse: music21’s addLyric.

Source

pub fn annotate_intervals( &self, strip_specifiers: bool, sort_pitches: bool, ) -> Result<Vec<String>>

Names the interval from the chord’s lowest pitch up to each of the others, highest first: music21’s annotateIntervals.

With strip_specifiers the names are bare numbers (8, 5, 3) and sorted downward; without it they are full interval names (P8, P5, M3). Repeated pitches are dropped first, and sort_pitches measures from the lowest pitch rather than the written first one.

Source

pub fn annotated_with_intervals( &self, strip_specifiers: bool, sort_pitches: bool, ) -> Result<Self>

Writes the interval names of Self::annotate_intervals onto the chord as lyrics, one verse each.

Source

pub fn string_harmonic(&self) -> Result<Option<Self>>

Reads a string harmonic: given a chord whose second note is written with a diamond head, the sounding pitch is the harmonic of the first note that their distance picks out, and the chord comes back with it added on top. A chord not written as a harmonic answers None.

This is music21’s Pitch.getStringHarmonic, which reads the notehead off the chord rather than off the pitch it is called on.

Source§

impl Chord

Source

pub fn chord_step(&self, step: u8) -> Option<&Pitch>

Returns the first pitch lying at the given chord step above the root, so 3 is the third and 7 the seventh. Steps of eight and above are folded down by an octave, so 9 finds a second.

Source

pub fn third(&self) -> Option<&Pitch>

Returns the third above the root, if the chord has one.

Source

pub fn fifth(&self) -> Option<&Pitch>

Returns the fifth above the root, if the chord has one.

Source

pub fn seventh(&self) -> Option<&Pitch>

Returns the seventh above the root, if the chord has one.

Source

pub fn semitones_from_chord_step(&self, step: u8) -> Option<u8>

Returns the semitones from the root to the given chord step, within an octave, if the chord has that step.

Source

pub fn has_repeated_chord_step(&self, step: u8) -> bool

Returns whether the chord has the given step spelled two different ways, such as both E and E- above C.

Source

pub fn has_any_enharmonic_spelled_pitches(&self) -> bool

Returns whether two pitches share a pitch class under different names, such as C# and D-.

Source

pub fn is_triad(&self) -> bool

Returns whether the chord is exactly three distinct pitch names with a third and a fifth above the root, of any quality.

Source

pub fn is_seventh(&self) -> bool

Returns whether the chord is exactly four distinct pitch names with a third, fifth and seventh above the root, of any quality.

Source

pub fn is_major_triad(&self) -> bool

Returns whether the chord is a correctly spelled major triad.

Source

pub fn is_minor_triad(&self) -> bool

Returns whether the chord is a correctly spelled minor triad.

Source

pub fn is_diminished_triad(&self) -> bool

Returns whether the chord is a correctly spelled diminished triad.

Source

pub fn is_augmented_triad(&self) -> bool

Returns whether the chord is a correctly spelled augmented triad.

Source

pub fn is_seventh_of_type(&self, semitones: &[u8]) -> bool

Returns whether the chord is a seventh chord whose pitches all lie at the given semitone offsets above the root.

Source

pub fn is_dominant_seventh(&self) -> bool

Returns whether the chord is a dominant seventh: a major triad with a minor seventh.

Source

pub fn is_half_diminished_seventh(&self) -> bool

Returns whether the chord is a half-diminished seventh.

Source

pub fn is_diminished_seventh(&self) -> bool

Returns whether the chord is a fully diminished seventh.

Source

pub fn is_incomplete_major_triad(&self) -> bool

Returns whether the chord is only a root and a major third above it.

Source

pub fn is_incomplete_minor_triad(&self) -> bool

Returns whether the chord is only a root and a minor third above it.

Source

pub fn contains_triad(&self) -> bool

Returns whether the chord has a third and a fifth above its root. A dominant seventh is not a triad but contains one.

Source

pub fn contains_seventh(&self) -> bool

Returns whether the chord contains a triad and a seventh above its root.

Source

pub fn quality(&self) -> TriadQuality

Returns the quality of the triad above the root, following music21’s Chord.quality: incomplete triads still count, and a chord with a repeated or missing chord step is TriadQuality::Other.

Source

pub fn is_consonant(&self) -> bool

Returns whether the chord is consonant in the common-practice sense: one pitch name, two whose closed-position interval is consonant, or a major or minor triad not in second inversion.

Source

pub fn chord_step_with_root(&self, step: u8, root: &Pitch) -> Option<&Pitch>

The first pitch at the given chord step above a root the caller decided on, rather than the one the chord infers: music21’s getChordStep(step, testRoot).

Source

pub fn semitones_from_chord_step_with_root( &self, step: u8, root: &Pitch, ) -> Option<u8>

The semitone distance from a caller-supplied root to the pitch at the given chord step: music21’s semitonesFromChordStep(step, testRoot).

Source

pub fn inversion_from_root(&self, root: &Pitch) -> Option<u8>

The inversion measured from a root the caller decided on: music21’s inversion(testRoot=...).

Source

pub fn is_augmented_sixth(&self, permit_any_inversion: bool) -> bool

Returns whether the chord is an Italian, French, German or Swiss augmented sixth. Each must be in its conventional inversion unless permit_any_inversion is set.

Source

pub fn is_italian_augmented_sixth( &self, permit_any_inversion: bool, restrict_doublings: bool, ) -> bool

Returns whether the chord is an Italian augmented sixth, such as A- C F#.

Source

pub fn is_french_augmented_sixth(&self, permit_any_inversion: bool) -> bool

Returns whether the chord is a French augmented sixth, such as A- C D F#.

Source

pub fn is_german_augmented_sixth(&self, permit_any_inversion: bool) -> bool

Returns whether the chord is a German augmented sixth, such as A- C E- F#.

Source

pub fn is_swiss_augmented_sixth(&self, permit_any_inversion: bool) -> bool

Returns whether the chord is a Swiss augmented sixth, such as A- C D# F#.

Source

pub fn is_ninth(&self) -> bool

Returns whether the chord is five distinct pitch names with a third, fifth, seventh and ninth above the root.

Source

pub fn is_transpositionally_symmetrical( &self, require_intervallic_evenness: bool, ) -> bool

Returns whether some transposition other than the octave maps the pitch-class set onto itself. With require_intervallic_evenness only the evenly spaced sets count, the way Straus defines the property.

Source

pub fn has_any_repeated_diatonic_note(&self) -> bool

Returns whether two pitches share a letter under different accidentals, such as E and E-.

Source

pub fn interval_from_chord_step(&self, step: u8) -> Option<Interval>

Returns the interval from the root to the first pitch lying on the given chord step, compound intervals included, so the third of C3 G3 E4 C5 is a major tenth. None when the chord has no root or no pitch on that step.

Source§

impl Chord

Source

pub fn resolution_chord( &self, tonic: &str, mode: Option<&str>, ) -> Result<Option<Self>>

Returns the first likely tonal resolution chord in the given key.

This is intentionally conservative rather than a universal harmonic oracle. It covers the resolution families that music21 exposes most directly: dominant-function sonorities, leading-tone diminished sonorities, and contextual augmented-sixth sonorities. Unsupported chords return Ok(None).

Source

pub fn resolution_chords( &self, tonic: &str, mode: Option<&str>, ) -> Result<Vec<Self>>

Returns likely tonal resolution chords in the given key.

Dominant-function chords resolve by root motion up a perfect fourth to a diatonic triad in the supplied key, so secondary dominants such as D7 in C major resolve to the G-major triad. Leading-tone diminished sonorities resolve up by semitone to a diatonic triad. Italian, French, German, and Swiss-style augmented-sixth sonorities in context resolve to the dominant triad.

Source

pub fn resolution_chords_in_key(&self, key: &Key) -> Result<Vec<Self>>

Returns likely tonal resolution chords in the supplied key.

Source

pub fn resolution_suggestions_in_key( &self, key: &Key, ) -> Result<Vec<ChordResolutionSuggestion>>

Returns likely tonal resolution suggestions in the supplied key.

Source

pub fn resolution_suggestions(&self) -> Result<Vec<ChordResolutionSuggestion>>

Returns likely tonal resolution chords with inferred key contexts.

This is a convenience wrapper around Self::resolution_chords for exploratory tools: dominant-function sonorities are tested against the key a perfect fourth above their root, leading-tone sonorities against the key a semitone above their root, and augmented-sixth sonorities against all built-in major/minor tonic spellings.

Source

pub fn can_be_dominant_v(&self) -> bool

Returns whether the chord could serve as a dominant: a major triad or a dominant seventh.

Source

pub fn can_be_tonic(&self) -> bool

Returns whether the chord could serve as a tonic: a major or minor triad.

Source§

impl Chord

Source

pub fn from_forte_class(notation: &str) -> Result<Self>

Builds the chord of a Forte set class from its name, 3-11 or 4-27B: music21’s fromForteClass. The pitches are the transposed normal form from C, without octaves, so 3-11 is C E- G and 3-11B is C E G.

Source

pub fn from_forte_address( cardinality: u8, index: u8, inversion: Option<i8>, ) -> Result<Self>

Builds the chord of a Forte set class from its table address: the cardinality, the number within it, and 1, -1 or None for the inversion, where None takes the form the table lists first.

Source

pub fn from_interval_vector(vector: &[u8; 6], z_relation: bool) -> Option<Self>

Builds the chord whose interval-class vector this is: music21’s fromIntervalVector. Z-related pairs share a vector; the first of the pair is returned unless z_relation asks for the second. None when no set class has the vector.

Source

pub fn forte_class(&self) -> Option<String>

Returns the Forte class, such as "3-11B", when available.

Returns None when the chord’s pitch-class set has no Forte-table entry, including empty or otherwise unsupported pitch-class sets.

Source

pub fn normal_form(&self) -> Option<Vec<u8>>

Returns the normal form transposed to start on zero, [0, 3, 6, 8] for C E G B-. This is the Forte-table form music21 reads off the chord’s table address; Self::normal_order is music21’s normalOrder, on the chord’s own pitch classes.

Returns None when the chord’s pitch-class set cannot be found in the chord tables, including empty or otherwise unsupported pitch-class sets.

Source

pub fn interval_class_vector(&self) -> Option<Vec<u8>>

Returns the interval-class vector when table metadata is available.

Returns None when the chord’s pitch-class set cannot be found in the chord tables, including empty or otherwise unsupported pitch-class sets.

Source

pub fn invariance_vector(&self) -> Option<Vec<u8>>

Returns Robert Morris’s eight-entry invariance vector, when available.

The values are taken from the same music21 Forte table as Self::forte_class and Self::interval_class_vector.

Source

pub fn z_relation(&self) -> Option<String>

Returns this chord’s Z-related Forte class, when music21 records one.

Source

pub fn prime_form(&self) -> Vec<u8>

Returns the Forte prime form of the pitch-class set, such as [0, 3, 7] for any major or minor triad. Empty when the chord has no table entry.

Source

pub fn prime_form_string(&self) -> String

Returns the prime form in music21’s angle-bracket notation, such as "<037>", with A and B standing for ten and eleven.

Source

pub fn forte_class_tni(&self) -> Option<String>

Returns the Forte class without the A/B inversion suffix, such as "3-11" for both major and minor triads.

Source

pub fn pitch_class_cardinality(&self) -> usize

Returns the number of distinct pitch classes.

Source

pub fn ordered_pitch_classes_string(&self) -> String

Returns the distinct pitch classes in ascending order in music21’s angle-bracket notation, such as "<047>".

Source

pub fn chord_tables_address_entry(&self) -> ChordTableAddress

Where this chord’s set class sits in the Forte tables.

An empty chord answers all zeros rather than failing, which is the one place music21’s Chord.chordTablesAddress differs from the seekChordTablesAddress underneath it.

Source

pub fn geometric_normal_form(&self) -> Vec<u8>

Returns music21’s geometricNormalForm: the distinct pitch classes rotated so the intervals between neighbours read smallest first, then written from zero, so both C E G and E G C are [0, 3, 8]. Empty for an empty chord.

Source

pub fn interval_vector_string(&self) -> String

Returns the interval-class vector in music21’s angle-bracket notation, <001110>; an empty chord reads <000000>.

Source

pub fn normal_order(&self) -> Vec<u8>

Returns music21’s normalOrder: the most compact rotation of the pitch classes, on the chord’s own pitch classes rather than transposed to zero, so C E G B- is [4, 7, 10, 0] where Self::normal_form is [0, 3, 6, 8]. Empty for an empty chord.

Source

pub fn normal_order_string(&self) -> String

Returns Self::normal_order in music21’s angle-bracket notation, <47A0>.

Source

pub fn forte_class_number(&self) -> Option<u8>

Returns the Forte class number within the cardinality, 11 for a major or minor triad. None for an empty chord.

Source

pub fn forte_class_tn(&self) -> Option<String>

Returns the Forte class under transposition equivalence, with the A/B inversion suffix: music21’s forteClassTn, the same as Self::forte_class.

Source

pub fn multiset_cardinality(&self) -> usize

Returns the number of notes, counting repeated pitch classes: music21’s multisetCardinality.

Source

pub fn is_prime_form_inversion(&self) -> bool

Returns whether the pitch-class set is the inversion of its prime form, so its Forte class carries a B suffix.

Source

pub fn has_z_relation(&self) -> bool

Returns whether music21 records a Z-related set class for this chord.

Source

pub fn are_z_relations(&self, other: &Chord) -> bool

Returns whether other belongs to the set class Z-related to this chord’s, so the two share an interval vector without being related by transposition or inversion.

Source

pub fn is_false_diminished_seventh(&self) -> bool

Returns whether the pitch classes form a fully diminished seventh however it is spelled: music21’s isFalseDiminishedSeventh, true for C E- G- A where Self::is_diminished_seventh is not.

Source§

impl Chord

Source

pub fn new<T>(notes: T) -> Result<Self>
where T: IntoNotes,

Builds a chord from any supported note collection.

Empty inputs are valid: pass "", an empty vector or slice, or Option::<&str>::None to construct an empty chord.

Source

pub fn empty() -> Self

Builds an empty chord.

Source

pub fn guitar_fingering(&self) -> Option<GuitarFingering>

Returns a suggested standard-tuning guitar fingering.

The fingering is a compact voicing on six-string guitar in E2-A2-D3-G3-B3-E4 tuning. It prefers shapes that cover all chord pitches, place the root in the bass when possible, avoid internal muted strings, and stay within a small fret span.

Source

pub fn guitar_fingering_with_tuning( &self, tuning: &GuitarTuning, ) -> Option<GuitarFingering>

Returns a suggested guitar fingering for the supplied tuning.

The tuning strings must be ordered from low to high. Fingering generation uses exact pitch spaces, so both the chord pitches and open-string octaves affect the result.

Source

pub fn pitch_classes(&self) -> Vec<u8>

Returns the distinct pitch classes in ascending order.

Source

pub fn polyrhythm_components(&self) -> Vec<UnsignedIntegerType>

Maps this chord’s pitch classes to a reduced integer polyrhythm ratio.

Pitch classes are measured from the inferred root when possible, or from the lowest pitch class otherwise. Each semitone offset is mapped to a compact just-intonation ratio and reduced to whole-number components.

Source

pub fn polyrhythm_ratio_string(&self) -> String

Returns Self::polyrhythm_components formatted as a:b:c.

Source

pub fn add<T>(&mut self, notes: T) -> Result<()>
where T: IntoNotes,

Adds pitches or notes to the end of the chord, as music21’s Chord.add does. The chord is not re-sorted: the new notes sit after the ones already there.

Source

pub fn remove(&mut self, pitch: &Pitch) -> Result<()>

Removes the first note whose pitch equals this one, as music21’s Chord.remove does, and errors when the chord has no such pitch.

Source

pub fn remove_named(&mut self, name_with_octave: &str) -> Result<()>

Removes the first note whose written pitch name matches, as music21’s Chord.remove does with a string.

Source

pub fn pitches(&self) -> Vec<Pitch>

Returns cloned pitches for every note in the chord, in input order.

Source

pub fn iter_pitches(&self) -> impl Iterator<Item = &Pitch> + '_

Borrows the pitches in input order.

Chord::pitches is music21’s accessor and clones each pitch; an Accidental owns two Strings, so that is two allocations a pitch a caller that only reads them does not need.

Source

pub fn notes(&self) -> &[Note]

Returns the notes in input order.

Source

pub fn notes_mut(&mut self) -> &mut [Note]

The notes in input order, for editing in place. This is how a note’s notation is changed through the chord: chord.notes_mut()[1] .set_notehead(Notehead::Diamond).

Source

pub fn len(&self) -> usize

How many notes the chord holds: what len(chord) answers upstream.

Source

pub fn is_empty(&self) -> bool

Whether the chord holds no notes at all.

Source

pub fn note_for_pitch(&self, pitch: &Pitch) -> Option<&Note>

The first note whose pitch equals this one: music21’s per-note accessors take a pitch this way.

Source

pub fn note_for_pitch_mut(&mut self, pitch: &Pitch) -> Option<&mut Note>

The first note whose pitch equals this one, for editing in place.

Source

pub fn duration(&self) -> Option<&Duration>

Returns the chord duration when one has been assigned.

Source

pub fn set_duration(&mut self, duration: Duration)

Assigns a duration to the chord.

Source

pub fn with_duration(self, duration: Duration) -> Self

Returns a copy of this chord with the supplied duration.

Source

pub fn inversion(&self) -> Option<u8>

Returns the inversion number the way music21 finds it: root position is 0, and the number climbs with the chord step the bass sits on, so a bass on the seventh is 3. None only for an empty chord.

Source

pub fn inversion_name(&self) -> Result<Option<IntegerType>>

Returns a human-readable inversion label.

Returns None whenever Self::inversion returns None. The figured-bass number music21’s inversionName answers: 53, 6 and 64 for a triad, 7, 65, 43 and 42 for a seventh. None when the chord has no inversion, and an error when it is neither a triad nor a seventh, as music21 raises there. For the words, see Self::inversion_text.

Source

pub fn simplify_enharmonics( &self, key_context: Option<KeySignature>, ) -> Result<Self>

Returns a copy with simplified enharmonic spellings.

This mirrors music21’s explicit enharmonic simplification workflow: construction stays side-effect free, and callers can request simpler spellings with an optional key-signature context.

Source

pub fn simplify_enharmonics_in_place( &mut self, key_context: Option<KeySignature>, ) -> Result<()>

Simplifies this chord’s pitch spellings in place.

Source

pub fn root(&self) -> Option<&Pitch>

Returns the root, found the way music21’s Chord.root finds it.

Source

pub fn found_root(&self) -> Option<&Pitch>

The root the pitches imply, ignoring any override.

Source

pub fn set_root(&mut self, root: Option<Pitch>)

Fixes the root the chord reports, or clears the override with None: music21’s root(newroot). The pitch need not be in the chord, which is the point of it for oddly spelled or added-note chords.

Source

pub fn bass(&self) -> Option<&Pitch>

Returns the lowest pitch, or the bass a caller fixed with Self::set_bass.

Source

pub fn found_bass(&self) -> Option<&Pitch>

The lowest pitch, ignoring any override.

Source

pub fn overridden_bass(&self) -> Option<&Pitch>

The bass a caller fixed with Self::set_bass, and nothing when none was.

Source

pub fn overridden_root(&self) -> Option<&Pitch>

The root a caller fixed with Self::set_root, and nothing when none was.

Source

pub fn set_bass(&mut self, bass: Option<Pitch>)

Fixes the bass the chord reports, or clears the override with None: music21’s bass(newbass). A pitch the chord does not already carry is added below the others, as music21 adds it.

Source

pub fn set_inversion(&mut self, inversion: u8) -> Result<()>

Rearranges the chord so it stands in the given inversion, raising the bass by octaves until it does: music21’s inversion(newInversion). An inversion the chord cannot reach is an error.

Source

pub fn closed_position( &self, force_octave: Option<IntegerType>, leave_redundant_pitches: bool, ) -> Self

Returns a copy with every pitch brought within an octave above the bass, duplicates removed and the notes sorted, as music21’s closedPosition does. force_octave moves the bass to that octave first, carrying the rest of the chord with it.

Source

pub fn remove_redundant_pitches_reporting(&self) -> (Self, Vec<Pitch>)

The chord with duplicate pitches removed, and the pitches that went: music21’s removeRedundantPitches, which hands back what it dropped.

Source

pub fn remove_redundant_pitch_names_reporting(&self) -> (Self, Vec<Pitch>)

The chord with pitches of the same name removed, and the ones that went: music21’s removeRedundantPitchNames.

Source

pub fn remove_redundant_pitch_classes_reporting(&self) -> (Self, Vec<Pitch>)

The chord with pitches of the same pitch class removed, and the ones that went: music21’s removeRedundantPitchClasses.

Source

pub fn remove_redundant_pitches(&self) -> Self

Returns a copy keeping the first of every pitch that appears more than once with the same name and octave. B-1 (B-flat, octave 1) and B in octave -1 print alike but are different pitches, and so are C with no octave of its own and C4.

Source

pub fn remove_redundant_pitch_names(&self) -> Self

Returns a copy keeping the first of every pitch name, regardless of octave.

Source

pub fn remove_redundant_pitch_classes(&self) -> Self

Returns a copy keeping the first of every pitch class, so C# and D- count as one.

Source

pub fn sort_ascending(&self) -> Self

Returns a copy sorted by staff position and then pitch space, so F## sorts below G-.

Source

pub fn transpose(&self, interval: &Interval) -> Result<Self>

Returns a copy with every note transposed by the interval.

Source

pub fn scale_degrees( &self, scale: &Scale, ) -> Result<Vec<(Option<usize>, Option<Accidental>)>>

Returns each pitch’s degree in scale with the accidental that separates it from the scale’s spelling, as music21’s scaleDegrees does: C E- G in C major is (1, None), (3, flat), (5, None). A pitch whose letter the scale lacks reports (None, None).

Source§

impl Chord

Source

pub fn inversion_text(&self) -> String

Returns music21’s inversionText: Root Position, First Inversion and so on, or Unknown Position for an empty chord.

Source

pub fn semi_closed_position( &self, force_octave: Option<IntegerType>, leave_redundant_pitches: bool, ) -> Self

Returns the chord in closed position with every repeated step raised an octave, so an eight-note cluster spreads into a scale: music21’s semiClosedPosition.

Source

pub fn sort_chromatic_ascending(&self) -> Self

Returns a copy sorted by pitch space alone, so enharmonic pairs keep their input order: music21’s sortChromaticAscending.

Source

pub fn sort_diatonic_ascending(&self) -> Self

Returns a copy sorted by staff position and then pitch space, so B#3 sorts below C4: music21’s sortDiatonicAscending, which is also what Self::sort_ascending does.

Source

pub fn sort_frequency_ascending(&self) -> Self

Returns a copy sorted by frequency: music21’s sortFrequencyAscending.

Source

pub fn pitch_names(&self) -> Vec<String>

Returns the pitch names in input order, without octaves.

Source

pub fn note_pitch_classes(&self) -> Vec<u8>

The pitch class of every note, in the order the chord holds them and with repeats kept: music21’s pitchClasses. For the sorted, distinct list see Self::pitch_classes.

Trait Implementations§

Source§

impl Clone for Chord

Source§

fn clone(&self) -> Chord

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Chord

Source§

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

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

impl<'de> Deserialize<'de> for Chord

Available on crate feature serde only.
Source§

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 Display for Chord

Source§

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

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

impl From<Chord> for StreamElement

Source§

fn from(value: Chord) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Chord

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(value: &str) -> Result<Self>

Parses a string s to return a value of this type. Read more
Source§

impl Index<usize> for Chord

Source§

type Output = Note

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl IntoIterator for Chord

Source§

type Item = Note

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<Note>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a> IntoIterator for &'a Chord

Source§

type Item = &'a Note

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, Note>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a> IntoIterator for &'a mut Chord

Source§

type Item = &'a mut Note

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'a, Note>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl Serialize for Chord

Available on crate feature serde only.
Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<&[&str]> for Chord

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &[&str]) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<&[Note]> for Chord

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &[Note]) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<&[Pitch]> for Chord

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &[Pitch]) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<&[String]> for Chord

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &[String]) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<&[i32]> for Chord

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &[IntegerType]) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<&str> for Chord

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &str) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<String> for Chord

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: String) -> Result<Self>

Performs the conversion.

Auto Trait Implementations§

§

impl Freeze for Chord

§

impl RefUnwindSafe for Chord

§

impl Send for Chord

§

impl Sync for Chord

§

impl Unpin for Chord

§

impl UnsafeUnpin for Chord

§

impl UnwindSafe for Chord

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.