music21.harmony

An object representation of harmony, a subclass of chord, as encountered as chord symbols or roman numerals, or other chord representations with a defined root.

Harmony

class music21.harmony.Harmony(figure: str | None = None, root: str | Pitch | None = None, bass: str | Pitch | None = None, inversion: int | None = None, updatePitches: bool = True, **keywords)

Harmony objects in music21 are a special type of chord - they retain all the same functionality as a chord (and inherit from chord directly), although they have special representations symbolically. They contain a figure representation, a shorthand, for the actual pitches they contain. This shorthand is commonly used on musical scores rather than writing out the chord pitches. Thus, each harmony object has an attribute, self.writeAsChord that dictates whether the object will be written to a score as a chord (with pitches realized) or with just the figure (as in Chord Symbols).

Most users should start with the ChordSymbol class or the RomanNumeral class. The Harmony object is primarily a base object for defining other sorts of objects:

>>> c6 = harmony.ChordSymbol('C/E')
>>> c6
<music21.harmony.ChordSymbol C/E>

By default, Harmony objects just float above the score and are a sort of analytical object. To make them also count as pitches in a score, use writeAsChord=True

>>> c6.writeAsChord = True
>>> c6
<music21.harmony.ChordSymbol C/E: E G C>

Or individual components can be specified:

>>> c6_again = harmony.ChordSymbol(root='C', bass='E', kind='major')
>>> c6_again
<music21.harmony.ChordSymbol C/E>

It is also possible to instantiate an empty Harmony object and then set components later, but this is an advanced and delicate operation:

>>> h = harmony.ChordSymbol()
>>> h.root('B-3')
>>> h.bass('D', allow_add=True)
>>> h.inversion(1, transposeOnSet=False)
>>> h.addChordStepModification(harmony.ChordStepModification('add', 4))
>>> h
<music21.harmony.ChordSymbol B-/D add 4>
>>> h = harmony.ChordSymbol('C7/E')
>>> h.root()
<music21.pitch.Pitch C4>
>>> h.bass()
<music21.pitch.Pitch E3>
>>> h.inversion()
1
>>> h.isSeventh()
True
>>> [str(p) for p in h.pitches]
['E3', 'G3', 'B-3', 'C4']
>>> sus = harmony.ChordSymbol('Dsus4')
>>> sus.root()
<music21.pitch.Pitch D3>

Accepts a keyword ‘updatePitches’. By default, it is True, but can be set to False to initialize faster if pitches are not needed.

Harmony bases

Harmony read-only properties

Read-only properties inherited from Chord:

Read-only properties inherited from Music21Object:

Read-only properties inherited from ProtoM21Object:

Harmony read/write properties

Harmony.figure

Get or set the figure of the harmony object. The figure is the character (string) representation of the object. For example, ‘I’, ‘CM’, ‘3#’.

When you instantiate a harmony object, if you pass in a figure it is stored internally and returned when you access the figure property. If you don’t instantiate the object with a figure, this property calls music21.harmony.Harmony.findFigure() method which deduces the figure provided other information about the object, especially the chord.

If the pitches of the harmony object have been modified after being instantiated, call music21.harmony.Harmony.findFigure() to deduce the new figure.

>>> h = harmony.ChordSymbol('CM')
>>> h.figure
'CM'
>>> harmony.ChordSymbol(root='C', bass='A', kind='minor').figure
'Cm/A'
>>> h.bass(note.Note('E'))
>>> h.figure
'CM'
Harmony.key

Gets or sets the current Key (or Scale object) associated with this Harmony object.

For a given RomanNumeral object. Each sub-classed harmony object may treat this property differently, for example Roman Numeral objects update the pitches when the key is changed, but chord symbol objects do not and the key provides more information about the musical context from where the harmony object was extracted.

>>> r1 = roman.RomanNumeral('V')
>>> r1.pitches
(<music21.pitch.Pitch G4>, <music21.pitch.Pitch B4>, <music21.pitch.Pitch D5>)
>>> r1.key = key.Key('A')
>>> r1.pitches
(<music21.pitch.Pitch E5>, <music21.pitch.Pitch G#5>, <music21.pitch.Pitch B5>)

Changing the key for a ChordSymbol object does nothing to its pitches, since it’s not dependent on key:

>>> h1 = harmony.ChordSymbol('D-m11')
>>> [str(p) for p in h1.pitches]
['D-2', 'F-2', 'A-2', 'C-3', 'E-3', 'G-3']
>>> h1.key = 'CM'  # = C-Major
>>> [str(p) for p in h1.pitches]
['D-2', 'F-2', 'A-2', 'C-3', 'E-3', 'G-3']

But it should change the .romanNumeral object:

>>> y = harmony.ChordSymbol('F')
>>> y.key is None
True
>>> y.romanNumeral
<music21.roman.RomanNumeral I in F major>
>>> y.key = key.Key('C')
>>> y.romanNumeral
<music21.roman.RomanNumeral IV in C major>
Harmony.romanNumeral

Get or set the romanNumeral numeral function of the Harmony as a RomanNumeral object. String representations accepted by RomanNumeral are also accepted.

>>> h = harmony.ChordSymbol('Dmaj7')
>>> h.romanNumeral
<music21.roman.RomanNumeral I7 in D major>
>>> h.romanNumeral = 'III7'
>>> h.romanNumeral
<music21.roman.RomanNumeral III7>
>>> h.romanNumeral.key = key.Key('B')
>>> h.romanNumeral
<music21.roman.RomanNumeral III7 in B major>
>>> h.romanNumeral = roman.RomanNumeral('IV7', 'A')
>>> h.romanNumeral
<music21.roman.RomanNumeral IV7 in A major>
>>> h = harmony.ChordSymbol('B-/D')
>>> h.romanNumeral
<music21.roman.RomanNumeral I6 in B- major>
Harmony.writeAsChord

Boolean attribute of all harmony objects that specifies how this object will be written to the rendered output (such as musicxml). If True (default for romanNumerals), the chord with pitches is written. If False (default for ChordSymbols) the harmony symbol is written. For NoChord objects, writeAsChord means to write as a rest.

Read/write properties inherited from Chord:

Read/write properties inherited from ChordBase:

Read/write properties inherited from NotRest:

Read/write properties inherited from GeneralNote:

Read/write properties inherited from Music21Object:

Harmony methods

Harmony.addChordStepModification(degree, *, updatePitches=True)

Add a harmony degree specification to this Harmony as a ChordStepModification object.

>>> hd = harmony.ChordStepModification('add', 4)
>>> h = harmony.ChordSymbol()
>>> h.addChordStepModification(hd)
>>> h.addChordStepModification('juicy')
Traceback (most recent call last):
music21.harmony.HarmonyException: cannot add this object as a degree: juicy

Alteration will also impact the pitches, if the keyword argument updatePitches is given as True

>>> h = harmony.ChordSymbol('C')
>>> mod = harmony.ChordStepModification('alter', 5, -1)
>>> h.addChordStepModification(mod, updatePitches=True)
>>> h.pitches
(<music21.pitch.Pitch C3>, <music21.pitch.Pitch E3>, <music21.pitch.Pitch G-3>)
  • Changed in v7: updatePitches is True by default

Harmony.findFigure()
Harmony.getChordStepModifications()

Return all harmony degrees as a list.

Methods inherited from Chord:

Methods inherited from ChordBase:

Methods inherited from NotRest:

Methods inherited from GeneralNote:

Methods inherited from Music21Object:

Methods inherited from ProtoM21Object:

Harmony instance variables

Instance variables inherited from Chord:

Instance variables inherited from ChordBase:

Instance variables inherited from NotRest:

Instance variables inherited from GeneralNote:

Instance variables inherited from Music21Object:

ChordSymbol

class music21.harmony.ChordSymbol(figure=None, root: Pitch | str | None = None, bass: Pitch | str | None = None, inversion: int | None = None, kind='', kindStr='', **keywords)

Class representing the Chord Symbols commonly found on lead sheets. Chord Symbol objects can be instantiated one of two main ways:

  1. when music xml is parsed by the music21 converter, xml Chord Symbol tags are interpreted as Chord Symbol objects with a root and kind attribute. If bass is not specified, the bass is assumed to be the root

  2. by creating a chord symbol object with music21 by passing in the expression commonly found on leadsheets. Due to the relative diversity of lead sheet chord syntax, not all expressions are supported. Consult the examples for the supported syntax, or email us for help.

All ChordSymbol inherit from Chord so you can consider these objects as chords, although they have a unique representation in a score. ChordSymbols, unlike chords, by default appear as chord symbols in a score and have duration of 0.

To obtain the chord representation of the ChordSymbol in the score, change writeAsChord to True. Unless otherwise specified, the duration of this chord object will become 1.0. If you have a leadsheet, run music21.harmony.realizeChordSymbolDurations() on the stream to assign the correct (according to offsets) duration to each harmony object.)

The music xml-based approach to instantiating Chord Symbol objects:

>>> cs = harmony.ChordSymbol(kind='minor', kindStr='m', root='C', bass='E-')
>>> cs
<music21.harmony.ChordSymbol Cm/E->
>>> cs.chordKind
'minor'
>>> cs.root()
<music21.pitch.Pitch C4>
>>> cs.bass()
<music21.pitch.Pitch E-3>

The second approach to creating a Chord Symbol object, by passing a regular expression (this list is not exhaustive):

>>> symbols = ['', 'm', '+', 'dim', '7',
...            'M7', 'm7', 'dim7', '7+', 'm7b5',  # half-diminished
...            'mM7', '6', 'm6', '9', 'Maj9', 'm9',
...            '11', 'Maj11', 'm11', '13',
...            'Maj13', 'm13', 'sus2', 'sus4',
...            'N6', 'It+6', 'Fr+6', 'Gr+6', 'pedal',
...            'power', 'tristan', '/E', 'm7/E-', 'add2',
...            '7omit3',]
>>> for s in symbols:
...     chordSymbolName = 'C' + s
...     h = harmony.ChordSymbol(chordSymbolName)
...     pitchNames = [str(p) for p in h.pitches]
...     print('%-10s%s' % (chordSymbolName, '[' + (', '.join(pitchNames)) + ']'))
C         [C3, E3, G3]
Cm        [C3, E-3, G3]
C+        [C3, E3, G#3]
Cdim      [C3, E-3, G-3]
C7        [C3, E3, G3, B-3]
CM7       [C3, E3, G3, B3]
Cm7       [C3, E-3, G3, B-3]
Cdim7     [C3, E-3, G-3, B--3]
C7+       [C3, E3, G#3, B-3]
Cm7b5     [C3, E-3, G-3, B-3]
CmM7      [C3, E-3, G3, B3]
C6        [C3, E3, G3, A3]
Cm6       [C3, E-3, G3, A3]
C9        [C3, E3, G3, B-3, D4]
CMaj9     [C3, E3, G3, B3, D4]
Cm9       [C3, E-3, G3, B-3, D4]
C11       [C2, E2, G2, B-2, D3, F3]
CMaj11    [C2, E2, G2, B2, D3, F3]
Cm11      [C2, E-2, G2, B-2, D3, F3]
C13       [C2, E2, G2, B-2, D3, F3, A3]
CMaj13    [C2, E2, G2, B2, D3, F3, A3]
Cm13      [C2, E-2, G2, B-2, D3, F3, A3]
Csus2     [C3, D3, G3]
Csus4     [C3, F3, G3]
CN6       [C3, D-3, E3, G-3]
CIt+6     [C3, F#3, A-3]
CFr+6     [C3, D3, F#3, A-3]
CGr+6     [C3, E-3, F#3, A-3]
Cpedal    [C3]
Cpower    [C3, G3]
Ctristan  [C3, D#3, F#3, A#3]
C/E       [E3, G3, C4]
Cm7/E-    [E-3, G3, B-3, C4]
Cadd2     [C3, D3, E3, G3]
C7omit3   [C3, G3, B-3]

You can also create a Chord Symbol by writing out each degree, and any alterations to that degree: You must explicitly indicate EACH degree (a triad is NOT necessarily implied)

>>> [str(p) for p in harmony.ChordSymbol('C35b7b9#11b13').pitches]
['C2', 'E2', 'G2', 'D-3', 'F#3', 'A-3', 'B-3']
>>> [str(p) for p in harmony.ChordSymbol('C35911').pitches]
['C2', 'E2', 'G2', 'D3', 'F3']

to prevent ambiguity in notation…

…and in accordance with the rest of music21, if a root or bass is flat, the ‘-’ must be used, and NOT ‘b’. However, alterations and chord abbreviations are specified normally with the ‘b’ and ‘#’ signs.

>>> dFlat = harmony.ChordSymbol('D-35')
>>> [str(p) for p in dFlat.pitches]
['D-3', 'F3', 'A-3']
>>> [str(p) for p in harmony.ChordSymbol('Db35').pitches]
['D3', 'F3', 'A3']
>>> [str(p) for p in harmony.ChordSymbol('D,35b7b9#11b13').pitches]
['D2', 'F#2', 'A2', 'E-3', 'G#3', 'B-3', 'C4']
>>> harmony.ChordSymbol('Am').pitches
(<music21.pitch.Pitch A2>, <music21.pitch.Pitch C3>, <music21.pitch.Pitch E3>)
>>> harmony.ChordSymbol('A-m').pitches
(<music21.pitch.Pitch A-2>, <music21.pitch.Pitch C-3>, <music21.pitch.Pitch E-3>)
>>> harmony.ChordSymbol('A-m').pitches
(<music21.pitch.Pitch A-2>, <music21.pitch.Pitch C-3>, <music21.pitch.Pitch E-3>)
>>> harmony.ChordSymbol('F-dim7').pitches
(<music21.pitch.Pitch F-2>, <music21.pitch.Pitch A--2>,
 <music21.pitch.Pitch C--3>, <music21.pitch.Pitch E---3>)

Thanks to David Bolton for catching the bugs tested below:

>>> [str(p) for p in harmony.ChordSymbol('C3579').pitches]
['C2', 'E2', 'G2', 'D3', 'B3']
>>> [str(p) for p in harmony.ChordSymbol('C35b79').pitches]
['C2', 'E2', 'G2', 'D3', 'B-3']
>>> [str(p) for p in harmony.ChordSymbol('C357b9').pitches]
['C2', 'E2', 'G2', 'D-3', 'B3']

When bass is not in chord:

>>> cs = harmony.ChordSymbol(root='E', bass='C', kind='diminished-seventh')
>>> [str(p) for p in cs.pitches]
['C2', 'E3', 'G3', 'B-3', 'D-4']
>>> cs.figure
'Eo7/C'

And now, and example of parsing in the wild:

>>> s = corpus.parse('leadsheet/fosterBrownHair')
>>> initialSymbols = s.flatten().getElementsByClass(harmony.ChordSymbol)[0:5]
>>> [[str(c.name) for c in c.pitches] for c in initialSymbols]
[['F', 'A', 'C'], ['B-', 'D', 'F'], ['F', 'A', 'C'], ['C', 'E', 'G'], ['F', 'A', 'C']]

Test creating an empty chordSymbol:

>>> cs = harmony.ChordSymbol()
>>> cs
<music21.harmony.ChordSymbol>
>>> cs.root('E-')
>>> cs.bass('B-', allow_add=True)

important: we are not asking for transposition, merely specifying the inversion that the chord should be read in (transposeOnSet = False)

>>> cs.inversion(2, transposeOnSet=False)
>>> cs.romanNumeral = 'I64'
>>> cs.chordKind = 'major'
>>> cs.chordKindStr = 'M'
>>> cs
<music21.harmony.ChordSymbol E-/B->

ChordSymbol bases

ChordSymbol read-only properties

Read-only properties inherited from Chord:

Read-only properties inherited from Music21Object:

Read-only properties inherited from ProtoM21Object:

ChordSymbol read/write properties

Read/write properties inherited from Harmony:

Read/write properties inherited from Chord:

Read/write properties inherited from ChordBase:

Read/write properties inherited from NotRest:

Read/write properties inherited from GeneralNote:

Read/write properties inherited from Music21Object:

ChordSymbol methods

ChordSymbol.findFigure()

Return the chord symbol figure associated with this chord.

This method tries to deduce what information it can from the provided pitches.

>>> h = harmony.ChordSymbol(root='F', bass='D-', kind='Neapolitan')
>>> h.figure
'FN6/D-'

Thanks to Norman Schmidt for code sample and helping fix a bug

>>> foster = corpus.parse('leadsheet/fosterBrownHair.xml')
>>> foster = foster.parts[0].getElementsByClass(stream.Measure)
>>> for m in foster[12:17]:
...   c = m.getElementsByClass(harmony.ChordSymbol)
...   if c:
...     ch = c[0].figure
...     print(ch.replace('-', 'b'))
...   else:
...     print('n.c.')
F
G7
C
C
C

Thanks to David Bolton for catching the bugs tested below:

>>> h1 = harmony.ChordSymbol('C7 b9')
>>> for x in h1.pitches:
...     x
...
<music21.pitch.Pitch C3>
<music21.pitch.Pitch E3>
<music21.pitch.Pitch G3>
<music21.pitch.Pitch B-3>
<music21.pitch.Pitch D-4>
>>> h2 = harmony.ChordSymbol('C/B- add 2')
>>> for x in h2.pitches:
...     x
...
<music21.pitch.Pitch B-2>
<music21.pitch.Pitch C3>
<music21.pitch.Pitch D3>
<music21.pitch.Pitch E3>
<music21.pitch.Pitch G3>
ChordSymbol.inversionIsValid(inversion)

Returns true if the provided inversion exists for the given pitches of the chord. If not, it returns false and the getPitches method then appends the bass pitch to the chord.

ChordSymbol.transpose(value, *, inPlace=False) T | None

Overrides transpose() so that this ChordSymbol’s figure is appropriately cleared afterward.

>>> cs = harmony.ChordSymbol('Am')
>>> cs.figure
'Am'
>>> cs.transpose(1)
<music21.harmony.ChordSymbol B-m>
>>> cs.transpose(5, inPlace=True)
>>> cs
<music21.harmony.ChordSymbol Dm>
>>> cs.figure
'Dm'

Methods inherited from Harmony:

Methods inherited from Chord:

Methods inherited from ChordBase:

Methods inherited from NotRest:

Methods inherited from GeneralNote:

Methods inherited from Music21Object:

Methods inherited from ProtoM21Object:

ChordSymbol instance variables

Instance variables inherited from Chord:

Instance variables inherited from ChordBase:

Instance variables inherited from NotRest:

Instance variables inherited from GeneralNote:

Instance variables inherited from Music21Object:

ChordStepModification

class music21.harmony.ChordStepModification(modType=None, degree=None, intervalObj=None)

ChordStepModification objects define the specification of harmony degree alterations, subtractions, or additions, used in Harmony objects, which includes harmony.ChordSymbol objects (and will include harmony.RomanNumeral objects).

  • degree-value element: indicates degree in chord, positive integers only

  • degree-alter: indicates semitone alteration of degree, positive and negative integers only

  • degree-type: add, alter, or subtract
    • if add: degree-alter is relative to a dominant chord (major and perfect intervals except for a minor seventh)

    • if alter or subtract: degree-alter is relative to degree already in the chord based on its kind element

>>> hd = harmony.ChordStepModification('add', 4)
>>> hd
<music21.harmony.ChordStepModification modType=add
    degree=4 interval=<music21.interval.Interval P1>>
>>> hd = harmony.ChordStepModification('alter', 3, 1)
>>> hd
<music21.harmony.ChordStepModification modType=alter
    degree=3 interval=<music21.interval.Interval A1>>

ChordStepModification bases

ChordStepModification read-only properties

Read-only properties inherited from ProtoM21Object:

ChordStepModification read/write properties

ChordStepModification.degree

Returns or sets an integer specifying the scale degree that this ChordStepModification alters.

>>> hd = harmony.ChordStepModification()
>>> hd.degree = 3
>>> hd.degree
3
>>> hd.degree = 'juicy'
Traceback (most recent call last):
music21.harmony.ChordStepModificationException: not a valid degree: juicy
ChordStepModification.interval

Get or set the alteration of this degree as a Interval object, generally as a type of ascending or descending augmented unison.

>>> hd = harmony.ChordStepModification()
>>> hd.interval = 1
>>> hd.interval
<music21.interval.Interval A1>
>>> hd.interval = -2
>>> hd.interval
<music21.interval.Interval AA-1>
>>> hd.interval = 0
>>> hd.interval
<music21.interval.Interval P1>
>>> hd.interval = interval.Interval('m3')
>>> hd.interval
<music21.interval.Interval m3>

More than 3 half step alteration gets an interval that isn’t a prime.

>>> hd.interval = -4
>>> hd.interval
<music21.interval.Interval M-3>
ChordStepModification.modType

Get or set the ChordStepModification modification type, where permitted types are the strings add, subtract, or alter.

>>> hd = harmony.ChordStepModification()
>>> hd.modType = 'add'
>>> hd.modType
'add'
>>> hd.modType = 'juicy'
Traceback (most recent call last):
music21.harmony.ChordStepModificationException: not a valid degree modification type: juicy

ChordStepModification methods

ChordStepModification.__eq__(other)

Return self==value.

Methods inherited from ProtoM21Object:

NoChord

class music21.harmony.NoChord(figure=None, kind='none', kindStr=None, **keywords)

Class representing a special ‘no chord’ ChordSymbol used to explicitly encode absence of chords. This is especially useful to stop a chord without playing another.

>>> from music21.harmony import ChordSymbol, NoChord
>>> s = stream.Score()
>>> s.repeatAppend(note.Note('C'), 4)
>>> s.append(ChordSymbol('C'))
>>> s.repeatAppend(note.Note('C'), 4)
>>> s.append(NoChord())
>>> s.repeatAppend(note.Note('C'), 4)
>>> s = s.makeMeasures()

See how the chordSymbol of C stops at offset 8 rather than continuing, thanks to the NoChord object.

>>> s = harmony.realizeChordSymbolDurations(s)
>>> s.show('text', addEndTimes=True)
{0.0 - 0.0} <music21.clef.BassClef>
{0.0 - 0.0} <music21.meter.TimeSignature 4/4>
{0.0 - 1.0} <music21.note.Note C>
{1.0 - 2.0} <music21.note.Note C>
{2.0 - 3.0} <music21.note.Note C>
{3.0 - 4.0} <music21.note.Note C>
{4.0 - 8.0} <music21.harmony.ChordSymbol C>
{4.0 - 5.0} <music21.note.Note C>
{5.0 - 6.0} <music21.note.Note C>
{6.0 - 7.0} <music21.note.Note C>
{7.0 - 8.0} <music21.note.Note C>
{8.0 - 12.0} <music21.harmony.NoChord N.C.>
{8.0 - 9.0} <music21.note.Note C>
{9.0 - 10.0} <music21.note.Note C>
{10.0 - 11.0} <music21.note.Note C>
{11.0 - 12.0} <music21.note.Note C>
{12.0 - 12.0} <music21.bar.Barline type=final>
>>> c_major = s.getElementsByClass(ChordSymbol).first()
>>> c_major.duration
<music21.duration.Duration 4.0>
>>> c_major.offset
4.0

Other text than the default of ‘N.C.’ can be given:

>>> nc2 = NoChord('NC')
>>> nc2
<music21.harmony.NoChord NC>
>>> nc2.pitches
()

Note that even if the text is a valid chord abbreviation, no pitches are generated. This feature may be useful for adding the appearance of ChordSymbols in a piece without having them be realized.

>>> nc2 = NoChord('C7')
>>> nc2
<music21.harmony.NoChord C7>
>>> nc2.pitches
()

NoChord bases

NoChord read-only properties

Read-only properties inherited from Chord:

Read-only properties inherited from Music21Object:

Read-only properties inherited from ProtoM21Object:

NoChord read/write properties

Read/write properties inherited from Harmony:

Read/write properties inherited from Chord:

Read/write properties inherited from ChordBase:

Read/write properties inherited from NotRest:

Read/write properties inherited from GeneralNote:

Read/write properties inherited from Music21Object:

NoChord methods

NoChord.bass(newbass=None, *, find=None, allow_add=False)

Generally used to find and return the bass Pitch:

>>> cmaj1stInv = chord.Chord(['C4', 'E3', 'G5'])
>>> cmaj1stInv.bass()
<music21.pitch.Pitch E3>

Subclasses of Chord often have basses that are harder to determine.

>>> cmaj = harmony.ChordSymbol('CM')
>>> cmaj.bass()
<music21.pitch.Pitch C3>
>>> cmin_inv = harmony.ChordSymbol('Cm/E-')
>>> cmin_inv.bass()
<music21.pitch.Pitch E-3>

Can also be used in rare occasions to set the bass note to a new Pitch, so long as that note is found in the chord:

>>> strange_chord = chord.Chord('E##4 F-4 C5')
>>> strange_chord.bass()
<music21.pitch.Pitch E##4>
>>> strange_chord.bass('F-4')
>>> strange_chord.bass()
<music21.pitch.Pitch F-4>

If the note assigned to the bass is not found, it will default to raising a ChordException:

>>> strange_chord.bass('G--4')
Traceback (most recent call last):
music21.chord.ChordException: Pitch G--4 not found in chord

For the purposes of initializing from a ChordSymbol and in other cases, a new bass can be added to the chord by setting allow_add = True:

>>> strange_chord.bass('G--4', allow_add=True)
>>> strange_chord.bass()
<music21.pitch.Pitch G--4>

By default, if nothing has been overridden, this method uses a quick algorithm to find the bass among the chord’s pitches, if no bass has been previously specified. If this is not intended, set find to False when calling this method, and ‘None’ will be returned if no bass is specified

>>> em = chord.Chord(['E3', 'G3', 'B4'])
>>> print(em.bass(find=False))
None
  • Changed in v8: raise an exception if setting a new bass to a pitch not in the chord, unless new keyword allow_add is True.

NoChord.root(newroot=None, *, find=None)

Returns the root of the chord. Or if given a Pitch as the newroot will override the algorithm and always return that Pitch.

>>> cmaj = chord.Chord(['E3', 'C4', 'G5'])
>>> cmaj.root()
<music21.pitch.Pitch C4>

Examples:

>>> cmaj = chord.Chord(['E', 'G', 'C'])
>>> cmaj.root()
<music21.pitch.Pitch C>

For some chords we make an exception. For instance, this chord in B-flat minor:

>>> aDim7no3rd = chord.Chord(['A3', 'E-4', 'G4'])

…could be considered a type of E-flat 11 chord with a 3rd, but no 5th, 7th, or 9th, in 5th inversion. That doesn’t make sense, so we should call it an A dim 7th chord with no 3rd.

>>> aDim7no3rd.root()
<music21.pitch.Pitch A3>
>>> aDim7no3rdInv = chord.Chord(['E-3', 'A4', 'G4'])
>>> aDim7no3rdInv.root()
<music21.pitch.Pitch A4>

The root of a 13th chord (which could be any chord in any inversion) is designed to be the bass:

>>> chord.Chord('F3 A3 C4 E-4 G-4 B4 D5').root()
<music21.pitch.Pitch F3>

Multiple pitches in different octaves do not interfere with root.

>>> lotsOfNotes = chord.Chord(['E3', 'C4', 'G4', 'B-4', 'E5', 'G5'])
>>> r = lotsOfNotes.root()
>>> r
<music21.pitch.Pitch C4>
>>> r is lotsOfNotes.pitches[1]
True

Setting of a root may happen for a number of reasons, such as in the case where music21’s idea of a root differs from the interpreter’s.

To specify the root directly, pass the pitch to the root function:

>>> cSus4 = chord.Chord('C4 F4 G4')
>>> cSus4.root()  # considered by music21 to be an F9 chord in 2nd inversion
<music21.pitch.Pitch F4>

Change it to be a Csus4:

>>> cSus4.root('C4')
>>> cSus4.root()
<music21.pitch.Pitch C4>

Note that if passing in a string as the root, the root is set to a pitch in the chord if possible.

>>> cSus4.root() is cSus4.pitches[0]
True

You might also want to supply an “implied root.” For instance, some people call a diminished seventh chord (generally viio7) a dominant chord with an omitted root (Vo9) – here we will specify the root to be a note not in the chord:

>>> vo9 = chord.Chord(['B3', 'D4', 'F4', 'A-4'])
>>> vo9.root()
<music21.pitch.Pitch B3>
>>> vo9.root(pitch.Pitch('G3'))
>>> vo9.root()
<music21.pitch.Pitch G3>

When setting a root, the pitches of the chord are left untouched:

>>> [p.nameWithOctave for p in vo9.pitches]
['B3', 'D4', 'F4', 'A-4']

By default, this method uses an algorithm to find the root among the chord’s pitches, if no root has been previously specified. If a root has been explicitly specified, as in the Csus4 chord above, it can be returned to the original root() by setting find explicitly to True:

>>> cSus4.root(find=True)
<music21.pitch.Pitch F4>

Subsequent calls without find=True have also removed the overridden root:

>>> cSus4.root()
<music21.pitch.Pitch F4>

If for some reason you do not want the root-finding algorithm to be run (for instance, checking to see if an overridden root has been specified) set find=False. “None” will be returned if no root has been specified.

>>> c = chord.Chord(['E3', 'G3', 'B4'])
>>> print(c.root(find=False))
None

Chord symbols, for instance, have their root already specified on construction:

>>> d = harmony.ChordSymbol('CM/E')
>>> d.root(find=False)
<music21.pitch.Pitch C4>

There is no need to set find=False in this case, however, the algorithm will skip the slow part of finding the root if it has been specified (or already found and no pitches have changed).

A chord with no pitches has no root and raises a ChordException.

>>> chord.Chord().root()
Traceback (most recent call last):
music21.chord.ChordException: no pitches in chord <music21.chord.Chord ...>
  • Changed in v5.2: find is a keyword-only parameter, newroot finds Pitch in Chord

NoChord.transpose(_value, *, inPlace=False) NCT | None

Overrides transpose() to do nothing.

>>> nc = harmony.NoChord()
>>> nc.figure
'N.C.'
>>> nc.transpose(8, inPlace=True)
>>> nc.figure
'N.C.'

Methods inherited from ChordSymbol:

Methods inherited from Harmony:

Methods inherited from Chord:

Methods inherited from ChordBase:

Methods inherited from NotRest:

Methods inherited from GeneralNote:

Methods inherited from Music21Object:

Methods inherited from ProtoM21Object:

NoChord instance variables

Instance variables inherited from Chord:

Instance variables inherited from ChordBase:

Instance variables inherited from NotRest:

Instance variables inherited from GeneralNote:

Instance variables inherited from Music21Object:

Functions

music21.harmony.chordSymbolFigureFromChord(inChord: Chord, includeChordType=False)

Analyze the given chord, and attempt to describe its pitches using a standard chord symbol figure.

The pitches of the chord are analyzed based on intervals, and compared to standard triads, sevenths, ninths, elevenths, and thirteenth chords. The type of chord therefore is determined if it matches (given certain guidelines documented below) and the figure is returned. There is no standard “chord symbol” notation, so a typical notation is used that can be easily modified if desired by changing a dictionary in the source code.

Set includeChordType to true (default is False) to return a tuple, the first element being the figure and the second element the identified chord type.

>>> harmony.chordSymbolFigureFromChord(chord.Chord(['C3', 'E3', 'G3']))
'C'

THIRDS

>>> c = chord.Chord(['C3', 'E3', 'G3'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('C', 'major')
>>> c = chord.Chord(['B-3', 'D-4', 'F4'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('B-m', 'minor')
>>> c = chord.Chord(['F#3', 'A#3', 'C##4'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('F#+', 'augmented')
>>> c = chord.Chord(['C3', 'E-3', 'G-3'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('Cdim', 'diminished')

SEVENTHS

>>> c = chord.Chord(['E-3', 'G3', 'B-3', 'D-4'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('E-7', 'dominant-seventh')
>>> c = chord.Chord(['C3', 'E3', 'G3', 'B3'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('Cmaj7', 'major-seventh')
>>> c = chord.Chord(['F#3', 'A3', 'C#4', 'E#4'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('F#mM7', 'minor-major-seventh')
>>> c = chord.Chord(['F3', 'A-3', 'C4', 'E-4'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('Fm7', 'minor-seventh')
>>> c = chord.Chord(['F3', 'A3', 'C#4', 'E4'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('F+M7', 'augmented-major-seventh')
>>> c = chord.Chord(['C3', 'E3', 'G#3', 'B-3'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('C7+', 'augmented-seventh')
>>> c = chord.Chord(['G3', 'B-3', 'D-4', 'F4'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('Gø7', 'half-diminished-seventh')
>>> c = chord.Chord(['C3', 'E-3', 'G-3', 'B--3'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('Co7', 'diminished-seventh')
>>> c = chord.Chord(['B-3', 'D4', 'F-4', 'A-4'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('B-dom7dim5', 'seventh-flat-five')

NINTHS

>>> c = chord.Chord(['C3', 'E3', 'G3', 'B3', 'D3'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('CM9', 'major-ninth')
>>> c = chord.Chord(['B-3', 'D4', 'F4', 'A-4', 'C4'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('B-9', 'dominant-ninth')
>>> c = chord.Chord(['E-3', 'G-3', 'B-3', 'D4', 'F3'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('E-mM9', 'minor-major-ninth')
>>> c = chord.Chord(['C3', 'E-3', 'G3', 'B-3', 'D3'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('Cm9', 'minor-ninth')
>>> c = chord.Chord(['F#3', 'A#3', 'C##4', 'E#4', 'G#3'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('F#+M9', 'augmented-major-ninth')
>>> c = chord.Chord(['G3', 'B3', 'D#4', 'F4', 'A3'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('G9#5', 'augmented-dominant-ninth')
>>> c = chord.Chord(['C3', 'E-3', 'G-3', 'B-3', 'D3'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('Cø9', 'half-diminished-ninth')
>>> c = chord.Chord(['B-3', 'D-4', 'F-4', 'A-4', 'C-4'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('B-øb9', 'half-diminished-minor-ninth')
>>> c = chord.Chord(['C3', 'E-3', 'G-3', 'B--3', 'D3'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('Co9', 'diminished-ninth')
>>> c = chord.Chord(['F3', 'A-3', 'C-4', 'E--4', 'G-3'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('Fob9', 'diminished-minor-ninth')

This harmony can either be CmaddD or Csus2addE-. music21 prefers the former. Change the ordering of harmony.CHORD_TYPES to switch the preference. From Bach BWV380

>>> c = chord.Chord(['C3', 'D4', 'G4', 'E-5'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('CmaddD', 'minor')

ELEVENTHS

>>> c = chord.Chord(['E-3', 'G3', 'B-3', 'D-4', 'F3', 'A-3'] )
>>> harmony.chordSymbolFigureFromChord(c, True)
('E-11', 'dominant-11th')
>>> c = chord.Chord(['G3', 'B3', 'D4', 'F#4', 'A3', 'C4'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('GM11', 'major-11th')
>>> c = chord.Chord(['C3', 'E-3', 'G3', 'B3', 'D3', 'F3'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('CmM11', 'minor-major-11th')
>>> c = chord.Chord(['F#3', 'A3', 'C#4', 'E4', 'G#3', 'B3'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('F#m11', 'minor-11th')
>>> c = chord.Chord(['B-3', 'D4', 'F#4', 'A4', 'C4', 'E-4'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('B-+M11', 'augmented-major-11th')
>>> c = chord.Chord(['F3', 'A3', 'C#4', 'E-4', 'G3', 'B-3'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('F+11', 'augmented-11th')
>>> c = chord.Chord(['G3', 'B-3', 'D-4', 'F4', 'A3', 'C4'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('Gø11', 'half-diminished-11th')
>>> c = chord.Chord(['E-3', 'G-3', 'B--3', 'D--4', 'F3', 'A-3'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('E-o11', 'diminished-11th')

THIRTEENTHS these are so tricky…music21 needs to be told what the root is in these cases all tests here are ‘C’ chords, but any root will work:

>>> c = chord.Chord(['C3', 'E3', 'G3', 'B3', 'D4', 'F4', 'A4'])
>>> c.root('C3')
>>> harmony.chordSymbolFigureFromChord(c, True)
('CM13', 'major-13th')
>>> c = chord.Chord(['C3', 'E3', 'G3', 'B-3', 'D4', 'F4', 'A4'])
>>> c.root('C3')
>>> harmony.chordSymbolFigureFromChord(c, True)
('C13', 'dominant-13th')
>>> c = chord.Chord(['C3', 'E-3', 'G3', 'B3', 'D4', 'F4', 'A4'])
>>> c.root('C3')
>>> harmony.chordSymbolFigureFromChord(c, True)
('CmM13', 'minor-major-13th')
>>> c = chord.Chord(['C3', 'E-3', 'G3', 'B-3', 'D4', 'F4', 'A4'])
>>> c.root('C3')
>>> harmony.chordSymbolFigureFromChord(c, True)
('Cm13', 'minor-13th')
>>> c = chord.Chord(['C3', 'E3', 'G#3', 'B3', 'D4', 'F4', 'A4'])
>>> c.root('C3')
>>> harmony.chordSymbolFigureFromChord(c, True)
('C+M13', 'augmented-major-13th')
>>> c = chord.Chord(['C3', 'E3', 'G#3', 'B-3', 'D4', 'F4', 'A4'])
>>> c.root('C3')
>>> harmony.chordSymbolFigureFromChord(c, True)
('C+13', 'augmented-dominant-13th')
>>> c = chord.Chord(['C3', 'E-3', 'G-3', 'B-3', 'D4', 'F4', 'A4'])
>>> c.root('C3')
>>> harmony.chordSymbolFigureFromChord(c, True)
('Cø13', 'half-diminished-13th')

Pop chords are typically not always “strictly” spelled and often certain degrees are omitted. Therefore, the following common chord omissions are permitted and the chord will still be identified correctly:

  • triads: none

  • seventh chords: none

  • ninth chords: fifth

  • eleventh chords: third and/or fifth

  • thirteenth chords: fifth, eleventh, ninth

This Chord could be minor 7th with a C4, but because this 5th isn’t present, not identified

>>> c = chord.Chord(['F3', 'A-3', 'E-4'])
>>> harmony.chordSymbolFigureFromChord(c)
'Chord Symbol Cannot Be Identified'

Removing the fifth G3 (fifth of chord)

>>> c = chord.Chord(['C3', 'E3',  'B3', 'D3'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('CM9', 'major-ninth')

Chord with G3 and B-3 removed (3rd & 5th of chord)

>>> c = chord.Chord(['E-3', 'D-4', 'F3', 'A-3'] )

Without a 3rd and 5th, root() algorithm can’t locate the root, so we must tell it the root (or write an algorithm that assumes the root is the lowest note if the root can’t be found)

>>> c.root('E-3')
>>> harmony.chordSymbolFigureFromChord(c, True)
('E-11', 'dominant-11th')

Inversions are supported, and indicated with a ‘/’ between the root, type-string, and bass

>>> c = chord.Chord([ 'G#3', 'B-3', 'C4', 'E4',])
>>> harmony.chordSymbolFigureFromChord(c, True)
('C7+/G#', 'augmented-seventh')
>>> c = chord.Chord(['G#2', 'B2', 'F#3', 'A3', 'C#4', 'E4'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('F#m11/G#', 'minor-11th')

if the algorithm matches the chord, but omissions or subtractions are present, the chord symbol attempts to indicate this (although there is no standard way of doing this so the notation might be different from what you’re familiar with).

An example of using this algorithm for identifying chords “in the wild”:

>>> score = corpus.parse('bach/bwv380')
>>> excerpt = score.measures(2, 3)
>>> chfy = excerpt.chordify()
>>> for c in chfy.flatten().getElementsByClass(chord.Chord):
...   print(harmony.chordSymbolFigureFromChord(c))
B-7
E-maj7/B-
B-7
Chord Symbol Cannot Be Identified
B-7
E-
B-
Chord Symbol Cannot Be Identified
B-/D
B-7
CmaddD
Cm/D
E-+M7/D
Cm/E-
F7

Notice, however, that this excerpt contains many embellishment and non-harmonic tones, so an algorithm to truly identify the chord symbols must be as complex as any harmonic analysis algorithm, which this is not, so innately this method is flawed.

And for the sake of completeness, unique chords supported by musicxml that this method can still successfully identify. Notice that the root must often be specified for this method to work.

>>> c = chord.Chord(['C3', 'D3', 'G3'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('Csus2', 'suspended-second')
>>> c.root()
<music21.pitch.Pitch C3>
>>> c.bass()
<music21.pitch.Pitch C3>
>>> c = chord.Chord(['C3', 'F3', 'G3'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('Csus', 'suspended-fourth')
>>> c.root()
<music21.pitch.Pitch C3>
>>> c.inversion()
0
>>> c = chord.Chord(['C3', 'D-3', 'E3', 'G-3'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('CN6', 'Neapolitan')
>>> c = chord.Chord(['C3', 'F#3', 'A-3'])
>>> c.root('C3')
>>> harmony.chordSymbolFigureFromChord(c, True)
('CIt+6', 'Italian')
>>> c = chord.Chord(['C3', 'D3', 'F#3', 'A-3'])
>>> c.root('C3')
>>> harmony.chordSymbolFigureFromChord(c, True)
('CFr+6', 'French')
>>> c = chord.Chord(['C3', 'E-3', 'F#3', 'A-3'])
>>> c.root('C3')
>>> harmony.chordSymbolFigureFromChord(c, True)
('CGr+6', 'German')
>>> c = chord.Chord(['C3'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('Cpedal', 'pedal')
>>> c = chord.Chord(['C3', 'G3'])
>>> harmony.chordSymbolFigureFromChord(c, True)
('Cpower', 'power')
>>> c = chord.Chord(['F3', 'G#3', 'B3', 'D#4'] )
>>> c.root('F3')
>>> harmony.chordSymbolFigureFromChord(c, True)
('Ftristan', 'Tristan')

This algorithm works as follows:

  1. chord is analyzed for root (using chord’s root() ) if the root cannot be determined, error is raised be aware that the root() method determines the root based on which note has the most thirds above it this is not a consistent way to determine the root of 13th chords, for example

  2. a chord vector is extracted from the chord

    using music21.chord.Chord.semitonesFromChordStep() this vector extracts the following degrees: (2, 3, 4, 5, 6, 7, 9, 11, and 13)

  3. this vector is converted to fbNotationString (in the form of chord step,

    and a ‘-’ or ‘#’ to indicate semitone distance)

  4. the fbNotationString is matched against the CHORD_TYPES dictionary in this harmony module,

    although certain subtractions are permitted for example a 9th chord will still be identified correctly even if it is missing the 5th

  5. the type with the most identical matches is used, and if no type matches,

    “Chord Type Cannot Be Identified” is returned

  6. the output format for the chord symbol figure is the chord’s root (with ‘b’ instead of ‘-‘),

    the chord type’s Abbreviation (saved in CHORD_TYPES dictionary), a ‘/’ if the chord is in an inversion, and the chord’s bass

The chord symbol nomenclature is not entirely standardized. There are several ways to write each abbreviation.

For example, an augmented triad might be symbolized with ‘+’ or ‘aug’. Thus, by default the returned symbol is the first (element 0) in the CHORD_TYPES list. For example (Eb minor eleventh chord, second inversion):

root + chord-type-str + ‘/’ + bass = ‘Ebmin11/Bb’

Users who wish to change these defaults can simply change that entry in the CHORD_TYPES dictionary.

>>> harmony.chordSymbolFigureFromChord(chord.Chord(['C2', 'E2', 'G2']))
'C'
>>> harmony.changeAbbreviationFor('major', 'maj')
>>> harmony.chordSymbolFigureFromChord(chord.Chord(['C2', 'E2', 'G2']))
'Cmaj'
music21.harmony.addNewChordSymbol(chordTypeName, fbNotationString, AbbreviationList)

Add a new chord symbol:

>>> harmony.addNewChordSymbol('BethChord', '1,3,-6,#9', ['MH', 'beth'])
>>> [str(p) for p in harmony.ChordSymbol('BMH').pitches]
['B2', 'C##3', 'D#3', 'G3']
>>> harmony.ChordSymbol('Cbeth').pitches
(<music21.pitch.Pitch C3>, <music21.pitch.Pitch D#3>,
 <music21.pitch.Pitch E3>, <music21.pitch.Pitch A-3>)
>>> harmony.ChordSymbol('C-beth').pitches
(<music21.pitch.Pitch C-3>, <music21.pitch.Pitch D3>,
 <music21.pitch.Pitch E-3>, <music21.pitch.Pitch A--3>)
music21.harmony.changeAbbreviationFor(chordType, changeTo)

Change the current Abbreviation used for a certain music21.harmony.ChordSymbol chord type

>>> harmony.getCurrentAbbreviationFor('minor')
'm'
>>> harmony.changeAbbreviationFor('minor', 'min')
>>> harmony.getCurrentAbbreviationFor('minor')
'min'
music21.harmony.chordSymbolFromChord(inChord: Chord) ChordSymbol

Get the chordSymbol object from the chord, using music21.harmony.Harmony.chordSymbolFigureFromChord()

>>> c = chord.Chord(['D3', 'F3', 'A4', 'B-5'])
>>> symbol = harmony.chordSymbolFromChord(c)
>>> symbol
<music21.harmony.ChordSymbol B-maj7/D>
>>> c.pitches == symbol.pitches
True
music21.harmony.getAbbreviationListGivenChordType(chordType)

Get the Abbreviation list (all allowed Abbreviations that map to this music21.harmony.ChordSymbol object):

>>> harmony.getAbbreviationListGivenChordType('minor-major-13th')
['mM13', 'minmaj13']
music21.harmony.getCurrentAbbreviationFor(chordType)

Return the current Abbreviation for a given music21.harmony.ChordSymbol chordType:

>>> harmony.getCurrentAbbreviationFor('dominant-seventh')
'7'
music21.harmony.getNotationStringGivenChordType(chordType)

Get the notation string (fb-notation style) associated with this music21.harmony.ChordSymbol chordType

>>> harmony.getNotationStringGivenChordType('German')
'1,-3,#4,-6'
music21.harmony.realizeChordSymbolDurations(piece)

Returns music21 stream with duration attribute of chord symbols correctly set. Duration of chord symbols is based on the surrounding chord symbols; The chord symbol continues duration until another chord symbol is located or the piece ends.

>>> s = stream.Score()
>>> s.append(harmony.ChordSymbol('C'))
>>> s.repeatAppend(note.Note('C'), 4)
>>> s.append(harmony.ChordSymbol('C'))
>>> s.repeatAppend(note.Note('C'), 4)
>>> s = s.makeMeasures()
>>> harmony.realizeChordSymbolDurations(s).show('text')
{0.0} <music21.clef.BassClef>
{0.0} <music21.meter.TimeSignature 4/4>
{0.0} <music21.harmony.ChordSymbol C>
{0.0} <music21.note.Note C>
{1.0} <music21.note.Note C>
{2.0} <music21.note.Note C>
{3.0} <music21.note.Note C>
{4.0} <music21.harmony.ChordSymbol C>
{4.0} <music21.note.Note C>
{5.0} <music21.note.Note C>
{6.0} <music21.note.Note C>
{7.0} <music21.note.Note C>
{8.0} <music21.bar.Barline type=final>

If only one chord symbol object is present:

>>> s = stream.Score()
>>> s.append(harmony.ChordSymbol('C'))
>>> s.repeatAppend(note.Note('C'), 4)
>>> s = s.makeMeasures()
>>> harmony.realizeChordSymbolDurations(s).show('text')
{0.0} <music21.clef.BassClef>
{0.0} <music21.meter.TimeSignature 4/4>
{0.0} <music21.harmony.ChordSymbol C>
{0.0} <music21.note.Note C>
{1.0} <music21.note.Note C>
{2.0} <music21.note.Note C>
{3.0} <music21.note.Note C>
{4.0} <music21.bar.Barline type=final>

If a ChordSymbol object exists followed by many notes, duration represents all those notes (how else can the computer know to end the chord? if there’s no chord following it other than end the chord at the end of the piece?).

>>> s = stream.Score()
>>> s.repeatAppend(note.Note('C'), 4)
>>> s.append(harmony.ChordSymbol('C'))
>>> s.repeatAppend(note.Note('C'), 8)
>>> s = s.makeMeasures()
>>> harmony.realizeChordSymbolDurations(s).show('text')
{0.0} <music21.clef.BassClef>
{0.0} <music21.meter.TimeSignature 4/4>
{0.0} <music21.note.Note C>
{1.0} <music21.note.Note C>
{2.0} <music21.note.Note C>
{3.0} <music21.note.Note C>
{4.0} <music21.harmony.ChordSymbol C>
{4.0} <music21.note.Note C>
{5.0} <music21.note.Note C>
{6.0} <music21.note.Note C>
{7.0} <music21.note.Note C>
{8.0} <music21.note.Note C>
{9.0} <music21.note.Note C>
{10.0} <music21.note.Note C>
{11.0} <music21.note.Note C>
{12.0} <music21.bar.Barline type=final>
music21.harmony.removeChordSymbols(chordType)

Remove the given chord type from the CHORD_TYPES dictionary, so it can no longer be identified or parsed by harmony methods.