Chord Distance Metrics

\label{chordmet}

Considerations

To begin to compare progressions of chords, it is essential to first have metrics to compare individual chords. Recall that a chord has the following components: root, quality, bass, and nochord. There are multiple approaches to comparing two chords. Both chords can be represented as the set of their pitch classes and set operations can be performed to formulate a distance; another approach may emphasize different structures such as the relationship between two chords’ \(root\) notes and \(bass\) notes.

It can be helpful to outline some basic comparisons of chords and describe how the chord metric should perform to outline the utility of a distance function. Assume a chord distance function \(C_d\) takes two chords and returns a real number from \(0\), indicating no similarity, to \(1\), indicating perfect similarity.

\(C_d(C,Cm)\) should have a good similarity score since a common chord extraction error is to confuse the major and minor versions of a given chord based on the similarity of overtone content or ambiguity that is frequently used as a musical device. In terms of the pitch classes of \(C\) major and \(C\) minor, they are similar in that both have \(C\) and \(G\) but differ in that the former has \(E\) and the latter \(Eb\).

\(C_d(C,Am)\) should compare similarly as the chords are relatively similar, which means that the key signatures formed by taking their roots and using their qualities as modes describe the same set of pitch classes. The pitch classes in \(A\) minor have two overlapping elements with those in \(C\) major.

\(C_d(C,Cmaj7)\) should score well as \(C\) major 7 is an extension of \(C\) major, which means it has the same root and bass and contains a superset of the pitch classes in \(C\). Likewise, \(C_d(C6, Am7)\) should compare nearly perfectly since both chords have the exact same set of pitch classes but differ in root and bass, which could be an error in chord extraction.

\(C_d(C7, C7/Bb)\) also can be expected to perform well as both chords describe identical sets of pitch classes and have the same root but differ in bass note.

Notation

\(P_c\) represents all the pitch classes in a given chord. If the nochord boolean is true this is the empty set \({}\). \(root\) is a function that returns the pitch class of the root of the given chord. \(quality\) is a function that returns the qualitative label of a chord that can be used with other functions to extract intervals and other factors. \(bass\) is a function that returns the pitch class of the bass of the chord. \(nochord\) is a function that returns whether the given chord is nochord or not. \(I\) is a function that takes a quality and returns a set of intervals in semitones modulus 12 from the root (excluding the root). \(V\) is a function that takes a quality and returns the 5th interval in the chord. For chords with major, minor, and dominant qualities, regardless of extension, this is the semitone \(7\) steps above the root. For diminished chords and minor 7 flat 5 chords this is the semitone \(6\) steps above the root. Finally, for augmented chords this is the semitone \(8\) steps above the root.

Simple equality test

This is the most basic implementation of a distance metric. Essentially, it tests whether two chords are equal, returning \(1.0\) if so and \(0.0\) otherwise. Equality can be tested in multiple ways, but exact equality tests first if both chords are nochord and returns \(1.0\) should that check out. Otherwise, it returns whether the root, quality, and bass of the two chords are identical. It can be expressed:

\[C_d(c_1,c_2) = \begin{cases} 1.0 & \text{if }(nochord(c_1) \land nochord(c_2)) \lor \\ & \hspace{0.8cm}(root(c_1) = root(c_2) \land quality(c_1) = quality(c_2) \land bass(c_1) = bass(c_2)) \\ 0.0 & \text{otherwise} \end{cases}\]

There are other ways to test equality. For instance, only root can be considered if one wishes to reduce a chord to its simplest element as follows:

\[C_d(c_1,c_2) = \begin{cases} 1.0 & \text{if }(nochord(c_1) \land nochord(c_2)) \lor root(c_1) = root(c_2) \\ 0.0 & \text{otherwise} \end{cases}\]

Another reasonable implementation is to consider the set of pitch classes of both chords and whether they are equal. This is expressed:

\[C_d(c_1,c_2) = \begin{cases} 1.0 & \text{if }P_c(c_1) = P_c(c_2) \\ 0.0 & \text{otherwise} \end{cases}\]

These simple equality metrics are useful distance functions for simple implementations and computations and were handy in assessing preliminary results before more detailed distance functions had been implemented.

Harte Distance Metric

This chord function is presented without a name in Christopher Harte’s PhD thesis about extraction of harmony from audio\cite{harte2010towards}, but I use the name “Harte distance metric” to refer to it. The method is deceptively simple but effective, consisting of taking the size of the intersection of both chords’ pitch class sets and dividing it by the size of the union of their pitch class sets, as follows:

\[C_d(c_1, c_2) = \frac{P_c(c_1) \cap P_c(c_2)}{P_c(c_1) \cup P_c(c_2)}\]

Using the Harte distance metric, the score of comparing minor and major chords of the same root (e.g. \(C_d(C,Cm)\)) and a major chord with its relative minor (e.g. \(C_d(C,Am)\)) both have the same value of \(0.5\). A major chord compared with a major 7th of the same root (e.g. \(C_d(C,Cmaj7)\)) that contains a superset of the first chord’s pitch classes has a score of \(0.75\). Comparing chords with identical pitch sets, even if root or bass notes vary (e.g. \(C_d(C6, Am7)\) \(C_d(C7, C7/Bb)\)), results in a perfect score of \(1.0\).

This metric has the advantage that it is very versatile and fast, but potentially loses some information about a chord in disregarding distinctions of elements within the chord, instead focusing only on the pitch classes within.

Tonal Pitch Step

Tonal Pitch Step is a distance measure that is grounded in cognitive psychology, algebra, and tonal music theory, proposed by Fred Lerdahl in \cite{lerdahl1988tonal}. The measure is unique from the others in that it takes into account the key of a song, which can be recalled as:

\[\begin{aligned} Key &\to Root\ Mode \\ Root &\to NoteName \\ Mode &\to \text{Major Minor} \\\end{aligned}\]

Given all possible combinations of a pitch class describing \(root\) and \(mode\), there are 24 distinct key signatures. It is important to note that the acceptable pitch classes within relative keys are identical, such as \(C\) major and \(A\) minor.

The tonal pitch step algorithm is calculated, with revisions courtesy of \cite{de2008tonal} to only include one key, as \[C_d(c_1, c_2) = i(root(c_1), root(c_2)) + j(c_1, c_2)\] where \(i\) calculates the circle-of-fifths distance between two pitch classes. The circle-of-fifths (see figure \ref{fig:circlefifths}) distance describes how many \(\pm7\) semitone traversals are needed to reach one note from another. It can be calculated for any two pitches \(p1\) and \(p2\) as \[i({p1}, {p2}) = \min((({p1} - {p2}) \cdot 7) \mod 12, (({p2} - {p1}) \cdot 7) \mod 12)\] where the difference between \({p1}\) and \({p2}\) is the number of semitones between them.