Towards a topological fingerprint of music

Towards a topological fingerprint of music

Mattia G. Bergomi Champalimaud Neuroscience Programme, Champalimaud Centre for the Unknown, Lisbon, Portugal,
   Adriano Baratè Università degli Studi di Milano, Laboratorio di Informatica Musicale
Milano, Italy
   Barbara Di Fabio Università di Modena e Reggio Emilia, Dipartimento di Scienze e Metodi dell’Ingegneria
Reggio Emilia, Italy

Can music be represented as a meaningful geometric and topological object? In this paper, we propose a strategy to describe some music features as a polyhedral surface obtained by a simplicial interpretation of the Tonnetz. The Tonnetz is a graph largely used in computational musicology to describe the harmonic relationships of notes in equal tuning. In particular, we use persistent homology in order to describe the persistent properties of music encoded in the aforementioned model. Both the relevance and the characteristics of this approach are discussed by analyzing some paradigmatic compositional styles. Eventually, the task of automatic music style classification is addressed by computing the hierarchical clustering of the topological fingerprints associated with some collections of compositions.

Music, classification, clustering, Tonnetz, persistent homology

1 Introduction

Generally, the core of a piece of music consists of a small collection of strong, recognizable concepts, that are grasped by the majority of the listeners [13, 17, 29]. These core concepts are developed during the composition by varying levels of tension over time, drawing the attention of the listener to particular moments thanks to specific choices, frustrating his/her intuition through unexpected changes, or confirming his/her expectation with, for instance, a well-known cadence leading to resolution.

As the models for the analysis of audio signals take advantage of the strategies developed for image analysis [27, 30, 22], it is possible to borrow some tools from the topological analysis of shapes and data to tackle the problem of music analysis and classification. The main aim of this paper is the introduction of a low-dimensional geometric-topological model in order to describe, albeit in an extremely simplified form, music styles.

Loosely speaking, we introduce a metric representation of music as a planar polyhedral surface, whose vertices are then translated along a third dimension in basis on a specific function. The shapes obtained via these deformations are fingerprinted by computing their persistent homology [15]. Afterwards, the musical meaning of this topological representation of music is discussed and applied to automatic style classification on three different datasets.

2 Background on persistent homology

In computational topology [14], persistent homology is actually considered an invaluable tool to describe both geometry and topology of a certain space, not only because of the simplicity of the method, but also because all the properties are ranked by importance, allowing us to choose the level of detail at which to perform such a description [15, 18].

Figure 1: Left: The height function on the topological space . Right: The associated persistence diagrams , with .

In more formal terms, given a topological space , we define a continuous function to obtain a family of subspaces , nested by inclusion, i.e. a filtration of . The map , called therefore a filtering function, is chosen according to the geometrical properties of interest (e.g., height, distance from center of mass, curvature). Applying homology to the filtration, births and deaths of topological features can be algebraically detected and their lifetime measured. The scale at which a feature is significant is measured by its longevity. Formally, given , we consider the inclusion of into . This inclusion induces a homomorphism of homology groups for every . The image of such a homomorphism consists of the -homology classes that live at least from to along the filtration, and is called the th persistent homology group of the pair at . When, for every , the th persistent homology groups are finitely generated, we can compactly describe them using the so-called persistence diagrams. A persistence diagram is the subset of consisting of points (called proper points) and vertical lines (called points at infinity) encoding the levels of at which the birth or the death of homological classes occur, union all the points belonging to the diagonal . In particular, if there exists at least one -homology class that is born at the level and is dead at the level along the filtration induced by , then is a proper point of ; if there exists at least one -homology class that is born at the level and never dies along the filtration induced by , then is a point at infinity of . A point at infinity is usually represented as the vertical line . Both points and lines are equipped with a multiplicity that depends on the number of classes with the same lifetime [19]. An example of persistence diagrams is displayed in  Fig. 1. The surface is endowed with the height function . The associated persistence diagrams and are displayed on the right. consists of one point at infinity , whose abscissa detects the absolute minimum of , and one proper point , whose abscissa and ordinate detect, respectively, the level at which the new connected component appears and merges with the existing one. consists of one proper point, whose abscissa and ordinate detect, respectively, the level at which a new tunnel is created and disappears along the filtration.

One of the main reasons behind the usage of persistence diagrams in applications consists in the possibility of estimating the degree of dissimilarity of two spaces with respect to a certain geometrical property through an appropriate comparison of these shape descriptors. Because of its properties of optimality [10] and stability [7], the most used instrument to compare persistence diagrams is given by the so called bottleneck distance (a.k.a. matching distance[9].

Definition 1

The bottleneck distance between two persistence diagrams and is defined as

where varies among all the bijections between and and

for every .

(a) Pitch space.
(b) Pitch-class space.
Figure 2: Fundamental music representation spaces.

3 Musical setting

In order to safely introduce the main model presented in this paper, we start by defining some basic musical objects.

We model a note in equal tuning as a pair , where is called the pitch of the note, and is its duration in seconds. In particular, if denotes the fundamental frequency of , the pitch is defined as , where is the fundamental frequency of the note (the la of the fourth octave of the piano). For further details on pitches, see, e.g., [11].

On a perceptual level, two notes an octave apart are really similar [4], thus, it is common to identify pitches modulo octave, by considering pitch classes . A representation of both the pitch and pitch-class spaces is depicted in Fig. 2.

3.1 The simplicial Tonnetz

(a) Planar simplicialTonnetz.
(b) Tonnetz torus.
Figure 3: (a) A finite subcomplex of the Tonnetz. (b) The Tonnetz torus obtained by identifying vertices in (a) equipped with the same labels.

The Tonnetz was originally introduced in [16] as a simple matrix representing both the acoustical and harmonic relationships among pitch classes. Later, it has been largely generalized to several formalisms, see, e.g., [8, 32, 12]. We will focus on its interpretation as a simplicial complex [2]. In this setting, the Tonnetz is modeled as an infinite planar simplicial complex, whose -simplices are labeled with pitch classes in a way that -simplices form either perfect fifth, major, or minor third intervals, and -simplices correspond to either major or minor triads. A finite subcomplex of the Tonnetz is depicted in Fig. (a)a. We observe that the labels on its vertices are periodic with respect to the transposition of both minor and major third. This feature allows to work with the more comfortable toroidal representation displayed in Fig. (b)b.

(a) The lydian mode.
(b) The locrian mode.
(c) Ionian subcomplex.
(d) Locrian subcomplex.
Figure 4: Two different modes represented by isomorphic subcomplexes of the Tonnetz.

It is possible to analyze and classify music by considering the subcomplexes of generated by a sequence of pitch classes [2]. However, this approach does not allow to discriminate musical styles in a geometric or topological sense. In fact, as the example in Fig. 4 shows, two perceptively distinct sonorities can be represented by isomorphic subcomplexes.

3.2 A deformed Tonnetz for music analysis

In order to capture both the temporal and harmonic information encoded in a musical phrase, the vertices of the Tonnetz shall be displaced depending both on the pitch which is played and its duration.

Let be the -skeleton of and a finite collection of notes of a musical phrase. Assume that is the subset whose pitches belong to . We define a map that takes each vertex labeled with to the point , where , and then extend it linearly to all the simplices. The Tonnetz deformed under the action of this map will be denoted by , and will be used as the main object of our topological description of music style. An example of deformation induced by a major triad played for seconds is depicted in Fig. 5, while a -dimensional interactive animation showing how the Tonnetz is deformed by a musical phrase is available at

Figure 5: The Tonnetz deformed with a major triad (a) and its -skeleton (b). The triad appears as a maximal triangle with respect to the height function.

4 A topological fingerprint of music styles

In order to describe the deformed Tonnetz, we use persistent homology.

We define the height function on to induce a lower level set filtration on the torus . The persistence diagrams obtained with this process are descriptors of the style characterizing the composition represented as a shape.

Figure 6: The (first row) and st persistence diagrams (second row) representing the topological fingerprints associated with three different compositions.

th persistence diagrams. The connectedness of is retrieved by the presence of only one point at infinity. Let be its equation: is the absolute minimum of on the deformed Tonnetz. If , then there exists at least one pitch-class set that does not have a relevant role in the composition, suggesting that it is based on a stable tonal or modal choice. On the contrary, if , then all the pitch classes have been used in the composition for a relevant time. This configuration suits a more atonal or chromatic style. The presence of proper points is due to the existence of minima of the height function, that are subcomplexes of the Tonnetz not connected by an edge, and hence, representing a dissonant interval [26]. Furthermore, the structure of the Tonnetz torus allows to retrieve a maximum of three connected components. To create this particular configuration, it is necessary to play a chromatic cluster: for instance, , that is not usually used in a tonal or modal context.

st persistence diagrams. The lifespan of -dimensional holes traversing the filtration provides symmetrical information with respect to the th persistence analysis. In this case, two points at infinity detect the two generators of the st homology group of the torus and, if there exists, proper points detect the presence of maxima of the height function, that are subcomplexes of the Tonnetz not connected by an edge.

As an example, we consider the persistence diagrams associated with Debussy’s Arabesque, Jeux d’Eau by Ravel, and Klavierstück 1 by Schönberg, shown in Fig. 6. In the th persistence diagram describing Arabesque, there are no proper points. This is an evidence of the pentatonic and diatonic/modal inspiration of the composition [28]. We also observe that the entire chromatic scale has been used, since . The abscissa of the point at infinity in the th persistence diagram of Jeux d’Eau is characterized by a high value, thus the entire set of pitch classes has been largely used in the composition. Moreover, the presence of a proper point highlights the ante-litteram use of the Petrushka chord, a superposition of a major triad and its tritone substitute: for instance, . Finally, the diagram associated with the Klavierstück 1 has two relevant proper points: this last feature points out the atonal nature of the composition.

The second row of Fig. 6 shows the st persistence diagrams associated with the same compositions. The tonal nature of Arabesque is highlighted by the a large distance between the points at infinity and the absence of proper points. The chromatic style of Jeux d’Eau implies the reduction of the distance between the two points at infinity. This last feature appears also in the diagram describing the Klavierstück 1, whose atonal tendency is stressed by a proper point representing the relevant lifespan of a third non-connected subcomplex.

Figure 7: Persistence-based clustering of nine classical and contemporary pieces.

4.1 Applications

In the following applications, we show how the persistence diagrams associated with a collection of compositions can effectively classify them according to their style. For , let be the set of th persistence diagrams. Let , for , be their distance matrix. The hierarchical clustering analysis [25] allows us to describe the configuration of the diagrams with respect to the bottleneck distance. We will represent the organization of all their possible clusters as a dendrogram [21, 23]. In this type of diagram, the abscissa of each splitting (vertical line) measures the distance between two clusters. Such distance is computed through elementary operations on the elements of .

Tonal and Atonal Music. We consider a dataset composed by nine pieces selected among the compositions by Beethoven, Debussy, Mozart, Ravel and Schönberg available at

The clustering computed using the th persistence of these pieces is depicted in Fig. 7. Data are organized in two main clusters, that segregate the two first pieces of Schönberg’s Drei Klavierstücke and Ravel’s Jeux d’Eau, from the ones by Mozart, Beethoven and Debussy. The association between Klavierstück 2 and Jeux d’Eau mirrors the particular nature of this Schönberg’s composition, that lies at the crossroad of tonal and atonal music, as it is proven by its disparate tonal interpretations [3, 31, 24]. The two movements of Mozart’s KV311 form immediately a cluster reached at an increasing distance by the two first movements of the Sonata in C major by Beethoven. The third movement of Sonata in C major is grouped with Arabesque because both are characterized by a generous use of the pentatonic scale.

Figure 8: Comparing three different versions of All the Things You Are.

Comparing three versions of All the Things You Are. The three interpretations are structured as follows:

  1. Version is played by a quartet in a standard way. Its main sections are a introduction, a first exposition of the theme, and a bars interlude introducing the last theme enriched by short improvisations.

  2. Version is performed by a piano solo, and it is characterized by a rich chromatic playing style of both hands. The main theme is executed twice.

  3. Version is performed by a duo (piano and bass). Its structure consists of an introduction, an exposition of the theme, and a piano improvisation.

The dataset is composed by the complete versions of the standard labeled as and a transposed version (). Segments of each versions are included in the dataset and labeled as . In order to test the ability of the model to distinguish between a piece modulating in several tonalities, enriched with chromatic solos, and a non-structured sequence of pitches, a random version of each interpretation is also part of the dataset ().

The resulting dendrogram is displayed in Fig. 8. We observe that the transposed versions have distance zero from the original ones, as an effect of the invariance of the filtration induced on the Tonnetz torus by the height function under uniform transposition. The randomized versions of the songs are well segregated. A small cluster groups the interlude of the first and the introduction of the third version, because both fragments share a very similar structure in terms of intervallic leaps and rhythm. Finally, in the top cluster, the two complete songs are linked to the fragment of the third version containing the theme. Hence, the th persistence homology retrieves the fragments containing the whole structure of the standard. This feature is surprising when taking into account the several modulations of the piece.

Figure 9: A simplified representation of the clustering of pop songs generated from their st persistence diagrams.

Big Pop Clustering. Fig. 9 shows a simplification of the clustering resulting by the comparison of the st persistence diagrams associated with pop songs performed by artists, spacing from Ray Charles to Lady Gaga. In order to give a simplified representation of this dendrogram, we considered only the three biggest clusters detected by the algorithm. On the left of each cluster, we listed the artists whose songs belong to that group. Names written in black bold characters indicate artists whose songs are entirely grouped in the cluster at their right, while red bold characters identify the three artists whose songs are spread among the three groups. We observe how the entire collection of songs by Ringo Starr, Paul McCartney and Simon & Garfunkel are grouped together in the blue cluster with Ray Charles, Stevie Wonder and George Benson. Moreover, the heterogeneity that characterizes Sting’s compositions is mirrored by the presence of one of his songs in each cluster. The second and third clusters are less homogeneous, but promising, taking into account that so far each song is identified by a single persistence diagram.

5 Discussion and future works

We suggested a model describing music by taking into account the contribution of each pair (pitch class, duration) associated with the notes of a composition. The height function has been defined on the vertices the simplicial Tonnetz to induce a lower level set filtration on the Tonnetz torus. The th and st persistence diagrams associated with different musical pieces have been interpreted in musical terms and their bottleneck distance has been used to classify them hierarchically. The possible clusterings have been represented as dendrograms, showing that th and st persistence can be used to analyze and classify music.

The analysis and classification of music we performed has been realized by considering datasets composed by MIDI files. However, the extension of this model to audio files is straightforward. Given an audio signal, the chroma analysis [20] retrieves the contribution in time of each pitch class. Using a chromagram to define the height function, it would surely be affected by the noisy data coming form the signal. However, the stability of the persistence diagrams, when compared using the bottleneck distance, assures that a small perturbation of the function inducing the filtration corresponds to small variations of the persistence diagrams.

The model itself can be extended in several ways. For instance, it is possible to augment the dimensionality the simplicial Tonnetz. This would result in losing its property to be easily visualizable, but it would give the possibility to encode more information. This could be done by associating with each pitch class of the Tonnetz a velocity, or by adding information concerning whatever pitch-class related feature. Moreover, topological persistence offers further tools to improve the strategies we suggested. A natural development is the study of the multidimensional persistent homology [5, 6] of musical spaces and their time-varying nature [1].


  • [1] Bergomi, M.G.: Dynamical and Topological Tools for (Modern) Music Analysis. Ph.D. thesis, Université Pierre et Marie Curie (2015)
  • [2] Bigo, L., Andreatta, M., Giavitto, J.L., Michel, O., Spicher, A.: Computation and visualization of musical structures in chord-based simplicial complexes. In: Mathematics and Computation in Music, pp. 38–51. Springer (2013)
  • [3] Brinkmann, R.: Arnold Schönberg, drei Klavierstücke Op. 11: Studien zur frühen Atonalität bei Schönberg. Franz Steiner Verlag (1969)
  • [4] Burns, E.M., Ward, W.D.: Intervals, scales, and tuning. The psychology of music 2, 215–264 (1999)
  • [5] Carlsson, G., Zomorodian, A.: The theory of multidimensional persistence. Discrete & Computational Geometry 42(1), 71–93 (2009)
  • [6] Cerri, A., Di Fabio, B., Ferri, M., Frosini, P., Landi, C.: Betti numbers in multidimensional persistent homology are stable functions. Mathematical Methods in the Applied Sciences 36(12), 1543–1557 (2013)
  • [7] Cohen-Steiner, D., Edelsbrunner, H., Harer, J.: Stability of persistence diagrams. Discrete & Computational Geometry 37(1), 103–120 (2007)
  • [8] Cohn, R.: Neo-riemannian operations, parsimonious trichords, and their” tonnetz” representations. Journal of Music Theory pp. 1–66 (1997)
  • [9] d’Amico, M., Frosini, P., Landi, C.: Using matching distance in size theory: A survey. Int. J. Imag. Syst. Tech. 16(5), 154–161 (2006)
  • [10] d’Amico, M., Frosini, P., Landi, C.: Natural pseudo-distance and optimal matching between reduced size functions. Acta Applicandae Mathematicae 109(2), 527–554 (2010)
  • [11] De Cheveigne, A.: Pitch perception models. In: Pitch, pp. 169–233. Springer (2005)
  • [12] Douthett, J., Steinbach, P.: Parsimonious graphs: A study in parsimony, contextual transformations, and modes of limited transposition. Journal of Music Theory pp. 241–263 (1998)
  • [13] Dowling, W.J.: Recognition of melodic transformations: Inversion, retrograde, and retrograde inversion. Perception & Psychophysics 12(5), 417–421 (1972)
  • [14] Edelsbrunner, H., Harer, J.: Computational Topology: An Introduction. American Mathematical Society (2009)
  • [15] Edelsbrunner, H., Harer, J.: Persistent homology-a survey. Contemporary mathematics 453, 257–282 (2008)
  • [16] Euler, L.: De harmoniae veris principiis per speculum musicum repraesentatis. Opera Omnia 3(1), 568–586 (1774)
  • [17] Folgieri, R., Bergomi, M.G., Castellani, S.: EEG-Based Brain-Computer Interface for Emotional Involvement in Games Through Music. In: Digital Da Vinci, pp. 205–236. Springer (2014)
  • [18] Frosini, P., Landi, C.: Size theory as a topological tool for computer vision. Pattern Recogn. and Image Anal. 9, 596–603 (1999)
  • [19] Frosini, P., Landi, C.: Size functions and formal series. Appl. Algebra Engrg. Comm. Comput. 12(4), 327–349 (2001)
  • [20] Harte, C., Sandler, M.: Automatic chord identifcation using a quantised chromagram. In: Audio Engineering Society Convention 118. Audio Engineering Society (2005)
  • [21] Langfelder, P., Zhang, B., Horvath, S.: Defining clusters from a hierarchical cluster tree: the Dynamic Tree Cut package for R. Bioinformatics 24(5), 719–720 (2008)
  • [22] Li, T.L., Chan, A.B., Chun, A.: Automatic musical pattern feature extraction using convolutional neural network. In: Proc. Int. Conf. Data Mining and Applications (2010)
  • [23] Martinez, W.L., Martinez, A., Solka, J.: Exploratory data analysis with MATLAB. CRC Press (2010)
  • [24] Ogdon, W.: How Tonality Functions In Shoenberg Opus-11, Number-1. Journal of the Arnold Schoenberg Institute 5(2), 169–181 (1981)
  • [25] Ott, N.: Visualization of Hierarchical Clustering: Graph Types and Software Tools. GRIN Verlag (2009)
  • [26] Plomp, R., Levelt, W.J.: Tonal consonance and critical bandwidth. Journal of the Acoustical Society of America 38(4), 548–560 (1965)
  • [27] Smaragdis, P., Brown, J.C.: Non-negative matrix factorization for polyphonic music transcription. In: Applications of Signal Processing to Audio and Acoustics, 2003 IEEE Workshop on. pp. 177–180. IEEE (2003)
  • [28] Trezise, S.: The Cambridge Companion to Debussy. Cambridge University Press (2003)
  • [29] Tulipano, L., Bergomi, M.G.: Meaning, music and emotions: a neural activity analysis. In: NEA Science. pp. 105–108 (2015)
  • [30] Wang, A., et al.: An Industrial Strength Audio Search Algorithm. In: ISMIR. pp. 7–13 (2003)
  • [31] William, B.: Harmony in Radical European Music. Society of Music Theory (1984)
  • [32] Zabka, M.: Generalized Tonnetz and Well-Formed GTS: A Scale Theory Inspired by the Neo-Riemannians? Mathematics and Computation in Music p. 286 (2009)
Comments 0
Request Comment
You are adding the first comment!
How to quickly get a good reply:
  • Give credit where it’s due by listing out the positive aspects of a paper before getting into which changes should be made.
  • Be specific in your critique, and provide supporting evidence with appropriate references to substantiate general statements.
  • Your comment should inspire ideas to flow and help the author improves the paper.

The better we are at sharing our knowledge with each other, the faster we move forward.
The feedback must be of minimum 40 characters and the title a minimum of 5 characters
Add comment
Loading ...
This is a comment super asjknd jkasnjk adsnkj
The feedback must be of minumum 40 characters
The feedback must be of minumum 40 characters

You are asking your first question!
How to quickly get a good answer:
  • Keep your question short and to the point
  • Check for grammar or spelling errors.
  • Phrase it like a question
Test description