amads.harmony.root_finding.parncutt#

class amads.harmony.root_finding.parncutt.ParncuttRootAnalysis(chord, root_support_weights='v2', exponent=0.5)[source]#

Parncutt’s (1988) model for finding the root of a chord.

Parameters:
  • chord (Union[List[int], Chord, PitchCollection]) – The chord to analyze. Can be represented as: - A list of MIDI pitches representing a chord, - A Chord object, - A PitchCollection object.

  • root_support_weights (Union[str, Dict[int, float]], optional) – Identifies the root support weights to use. “v1” uses the original weights from Parncutt (1988), “v2” uses the updated weights from Parncutt (2006), by default “v2”.

  • exponent (float, optional) – Exponent to be used when computing root ambiguities, by default 0.5.

pc_set#

The chord’s pitch class set.

Type:

set

root#

The pitch class of the derived chord root.

Type:

int

root_ambiguity#

A measure of how ambiguous the root is.

Type:

float

root_strengths#

Root support values for each pitch class.

Type:

List[float]

Examples

>>> # Major triad
>>> analysis = ParncuttRootAnalysis([60, 64, 67])  # C major triad
>>> analysis.root
0
>>> analysis.root_ambiguity
1.9
>>> # Minor triad
>>> analysis = ParncuttRootAnalysis([60, 63, 67])  # C minor triad
>>> analysis.root
0
>>> analysis.root_ambiguity
2.1
>>> # Dominant seventh
>>> analysis = ParncuttRootAnalysis([60, 64, 67, 70])  # C7
>>> analysis.root
0
>>> analysis.root_ambiguity
2.1
>>> # Diminished triad (more ambiguous)
>>> analysis = ParncuttRootAnalysis([60, 63, 66])  # C diminished
>>> analysis.root
0
>>> analysis.root_ambiguity
2.5
>>> # Using original Parncutt (1988) weights
>>> analysis = ParncuttRootAnalysis([60, 64, 67, 70], root_support_weights="v1")
>>> analysis.root
0
>>> analysis.root_ambiguity
2.1
>>> # Visualize the root strengths
>>> fig = analysis.plot(show=False)
>>> # plt.show() # in an interactive session, this will display the plot
>>> plt.close(fig) # in a non-interactive session, this is needed to close the plot
>>> # Using a Chord object as the input
>>> from amads.core.basics import Chord, Note
>>> chord = Chord(Note(pitch=60),  # C4
...               Note(pitch=64),  # E4
...               Note(pitch=67))  # G4
>>> analysis = ParncuttRootAnalysis(chord)
>>> analysis.root
0
>>> # Using a PitchCollection object as the input
>>> from amads.pitch import Pitch, PitchCollection
>>> pitch_collection = PitchCollection([Pitch.from_name(x) for x in ["D4", "F4", "A4"]])
>>> analysis = ParncuttRootAnalysis(pitch_collection)
>>> analysis.root
2

References

[1] Parncutt, R. (1988). Revision of Terhardt’s psychoacoustical model of the root(s) of a musical chord. Music Perception, 6(1), 65–93. https://doi.org/10.2307/40285416 [2] Parncutt, R. (2006). Commentary on Cook & Fujisawa’s “The Psychophysics of Harmony Perception: Harmony is a Three-Tone Phenomenon.” Empirical Musicology Review, 1(4), 204–209.

plot(title=None, show=True) tuple[ModuleType, Figure][source]#

Visualize the root support weights for a chord.

Parameters:

title (Optional[str], optional) – Title for the plot, by default None.

Returns:

A tuple containing the matplotlib pyplot module and the figure containing the visualization.

Return type:

tuple[ModuleType, Figure]

Examples

>>> analysis = ParncuttRootAnalysis([0, 4, 7])
>>> fig = analysis.plot(show=False)
>>> # plt.show() # in an interactive session, this will display the plot
>>> plt.close(fig) # in a non-interactive session, this is needed to close the plot