music21.analysis.neoRiemannian

This module defines the L, P, and R objects and their related transformations as called on a chord.Chord, according to Neo-Riemannian theory.

Functions

music21.analysis.neoRiemannian.L(c, raiseException=True)

L is a function that takes a major or minor triad and returns a chord that is the L transformation. L transforms a chord to its Leading-Tone exchange.

Example 1: A C major chord, under L, will return an E minor chord

>>> c1 = chord.Chord("C4 E4 G4")
>>> c2 = analysis.neoRiemannian.L(c1)
>>> c2.pitches
(<music21.pitch.Pitch B3>, <music21.pitch.Pitch E4>, <music21.pitch.Pitch G4>)
>>> try:
...     c3 = chord.Chord("C4 D4 E4")
...     c4 = analysis.neoRiemannian.L(c3, raiseException=True)
... except analysis.neoRiemannian.LRPException:
...     pass
music21.analysis.neoRiemannian.LRP_combinations(c, transformationString, raiseException=True, leftOrdered=False, simplifyEnharmonics=False)

LRP_combinations takes a major or minor triad, tranforms it according to the list of L, R, and P transformations in the given transformationString, and returns the result in triad. Certain combinations, such as LPLPLP, are cyclical, and therefore will return the original chord if simplifyEnharmonics = True (see completeHexatonic, below).

leftOrdered allows a user to work with their preferred function notation. leftOrdered = False, the default, reads the transformationString from left to right, so “LPR” will start by transforming the chord by L, then P, then R. leftOrdered = True (set by user) works in the opposite direction (right to left), so “LPR” starts with R, then P, then L.

simplifyEnharmonics returns results removing multiple sharps and flats where they arise from combined transformations. If simplifyEnharmonics is True, the resulting chord will be simplified to notes with at most 1 flat or 1 sharp, in their most common form.

>>> c1 = chord.Chord("C4 E4 G4")
>>> c2 = analysis.neoRiemannian.LRP_combinations(c1, 'LP')
>>> c2
<music21.chord.Chord B3 E4 G#4>
>>> c3 = chord.Chord("C4 E4 G4 C5 E5")
>>> c4 = analysis.neoRiemannian.LRP_combinations(c3, 'RLP')
>>> c4
<music21.chord.Chord C4 F4 A-4 C5 F5>
>>> c5 = chord.Chord("B4 D#5 F#5")
>>> c6 = analysis.neoRiemannian.LRP_combinations(c5, 
...                        'LPLPLP', leftOrdered=True, simplifyEnharmonics=True)
>>> c6
<music21.chord.Chord B4 D#5 F#5>
>>> c5 = chord.Chord("C4 E4 G4")
>>> c6 = analysis.neoRiemannian.LRP_combinations(c5, 'LPLPLP', leftOrdered=True)
>>> c6
<music21.chord.Chord D--4 F-4 A--4>
>>> c5 = chord.Chord("A-4 C4 E-5")
>>> c6 = analysis.neoRiemannian.LRP_combinations(c5, 'LPLPLP')
>>> c6
<music21.chord.Chord G#4 B#3 D#5>
music21.analysis.neoRiemannian.LRP_transform(c, transposeInterval, changingPitch)
music21.analysis.neoRiemannian.P(c, raiseException=True)

P is a function that takes a major or minor triad and returns a chord that is the P transformation. P transforms a chord to its parallel, i.e. to the chord of the same diatonic name but opposite model.

Example 1: A C major chord, under P, will return an C minor chord

>>> c2 = chord.Chord("C4 E4 G4")
>>> c3 = analysis.neoRiemannian.P(c2)
>>> c3.pitches
(<music21.pitch.Pitch C4>, <music21.pitch.Pitch E-4>, <music21.pitch.Pitch G4>)
>>> try:
...     c3 = chord.Chord("C4 D4 E4")
...     c4 = analysis.neoRiemannian.P(c3, raiseException=True)
... except analysis.neoRiemannian.LRPException:
...     pass
music21.analysis.neoRiemannian.R(c, raiseException=True)

R is a function that takes a major or minor triad and returns a chord that is the R transformation. R transforms a chord to its relative, i.e. if major, to its relative minor and if minor, to its relative major.

Example 1: A C major chord, under R, will return an A minor chord

>>> c1 = chord.Chord("C4 E4 G4")
>>> c2 = analysis.neoRiemannian.R(c1)
>>> c2.pitches
(<music21.pitch.Pitch C4>, <music21.pitch.Pitch E4>, <music21.pitch.Pitch A4>)
>>> try:
...     c3 = chord.Chord("C4 D4 E4")
...     c4 = analysis.neoRiemannian.R(c3, raiseException=True)
... except analysis.neoRiemannian.LRPException:
...     pass
music21.analysis.neoRiemannian.completeHexatonic(c, simplifyEnharmonics=False, raiseException=True)

completeHexatonic returns the list of six triads generated by the operation PLPLPL. This six-part operation cycles between major and minor triads, ultimately returning to the input triad (or its enharmonic equivalent). This functions returns those six triads, ending with the original triad. simplifyEnharmonics=False, by default, giving double flats; simplifyEnharmonics can be set to True in order to avoid this.

>>> c1 = chord.Chord("C4 E4 G4")
>>> analysis.neoRiemannian.completeHexatonic(c1)
[<music21.chord.Chord C4 E-4 G4>,
 <music21.chord.Chord C4 E-4 A-4>,
 <music21.chord.Chord C-4 E-4 A-4>,
 <music21.chord.Chord C-4 F-4 A-4>,
 <music21.chord.Chord C-4 F-4 A--4>,
 <music21.chord.Chord D--4 F-4 A--4>]

Or with simplifyEnharmonics=True

>>> c2 = chord.Chord("C4 E4 G4")
>>> analysis.neoRiemannian.completeHexatonic(c2, simplifyEnharmonics=True)
[<music21.chord.Chord C4 E-4 G4>,
 <music21.chord.Chord C4 E-4 A-4>,
 <music21.chord.Chord B3 D#4 G#4>,
 <music21.chord.Chord B3 E4 G#4>,
 <music21.chord.Chord B3 E4 G4>,
 <music21.chord.Chord C4 E4 G4>]
music21.analysis.neoRiemannian.simplerEnharmonics(c)