music21.analysis.harmonicFunction

HarmonicFunction

class music21.analysis.harmonicFunction.HarmonicFunction(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

HarmonicFunction bases

Functions

music21.analysis.harmonicFunction.functionToRoman(thisHarmonicFunction: HarmonicFunction, keyOrScale: Key | ConcreteScale | str = 'C') RomanNumeral | None

Takes harmonic function labels (such as ‘T’ for major tonic) with a key (keyOrScale, default = ‘C’) and returns the corresponding RomanNumeral object.

>>> analysis.harmonicFunction.functionToRoman('T')
<music21.roman.RomanNumeral I in C major>

The harmonicFunction argument can be a string (as shown), though strictly speaking, it’s handled through a special HarmonicFunction enum object.

>>> fn = analysis.harmonicFunction.HarmonicFunction.TONIC_MAJOR
>>> str(fn)
'T'
>>> analysis.harmonicFunction.functionToRoman(fn).figure
'I'

As with Roman numerals, this is case sensitive. For instance, ‘t’ indicates a minor tonic as distinct from the major tonic, ‘T’.

>>> analysis.harmonicFunction.functionToRoman('t').figure
'i'

There are 18 main functional labels supported in all, for the three functional categories (T for tonic, S for subdominant, and D for dominant) and three relevant transformation types (none, P, and G) all in upper and lower case (for major/minor): T, Tp, Tg, t, tP, tG, S, Sp, Sg, s, sP, sG, D, Dp, Dg, d, dP, dG.

Note that this module uses terminology from modern German music theory where Functional notation (‘HarmonicFunctionstheorie’) is typically used throughout the curriculum in preference over Roman numerals (‘Stufentheorie’).

First, note the false friend: here ‘P’ for ‘Parallel’ connects a major triad with the minor triad a minor third below (e.g. C-a). (in English-speaking traditions this would usually be ‘relative’).

Second, note that this module uses ‘G’ (and ‘g’), standing for ‘Gegenklänge’ or ‘Gegenparallelen’. ‘L’ (and ‘l’) for Leittonwechselklänge is equivalent to this. (Again, ‘G’ is more common in modern German-language music theory).

Use the keyOrScale argement to specify a key. This makes a difference where 6th and 7th degrees of minor are involved.

>>> analysis.harmonicFunction.functionToRoman('sP', keyOrScale='C').figure
'bVI'
>>> analysis.harmonicFunction.functionToRoman('sP', keyOrScale='a').figure
'VI'

Some of the 18 main functions overlap, with two functional labels referring to the same Roman numeral figure. For instance both ‘Tg’ and ‘Dp’ simply map to ‘iii’:

>>> analysis.harmonicFunction.functionToRoman('Tp').figure
'vi'
>>> analysis.harmonicFunction.functionToRoman('Sg').figure
'vi'

The reverse operation is handled by the complementary romanToFunction(). In this case, romanToFunction() follows the convention of preferring the P-version over alternatives.

>>> rn = roman.RomanNumeral('vi')
>>> str(analysis.harmonicFunction.romanToFunction(rn))
'Tp'
music21.analysis.harmonicFunction.romanToFunction(rn: RomanNumeral, onlyHauptHarmonicFunction: bool = False) HarmonicFunction | None

Takes a Roman numeral and returns a corresponding harmonic function label.

>>> rn1 = roman.RomanNumeral('VI', 'a')
>>> fn1 = analysis.harmonicFunction.romanToFunction(rn1)
>>> fn1
<HarmonicFunction.SUBDOMINANT_MINOR_PARALLELKLANG_MAJOR>

This can be converted into a string:

>>> str(fn1)
'sP'

Optionally, set onlyHauptHarmonicFunction to True to return a simplified version with only the HauptHarmonicFunction (one of t, T, s, S, d, D: major and minor forms of the tonic, subdominant and dominant).

>>> fn1 = analysis.harmonicFunction.romanToFunction(rn1, onlyHauptHarmonicFunction=True)
>>> fn1
<HarmonicFunction.SUBDOMINANT_MINOR>
>>> str(fn1)
's'

Inversions are not currently considered (they may be in a future version of this). This function simply uses the romanNumeral attribute of the roman.RomanNumeral object. This excludes inversions, but includes, where applicable, the frontAlterationAccidental.modifier.

>>> rn2 = roman.RomanNumeral('bII6', 'g')
>>> fn2 = analysis.harmonicFunction.romanToFunction(rn2)
>>> fn2
<HarmonicFunction.SUBDOMINANT_MINOR_GEGENKLANG_MAJOR>
>>> str(fn2)
'sG'

See further notes on the complementary functionToRoman().