Computational analysis of fuguesMathieu Giraud, Richard Groult, Emmanuel Leguy, Florence Levé
A fugue is a polyphonic piece built in imitation, where all voices appear successively sharing the same initial melodic material: a subject and, in most cases, a counter-subject. These patterns are repeated throughout the piece, either in their initial form or more often altered or transposed, building a complex harmonic texture.
We present here a computational analysis of fugues, trying to automatically analyze their structure. The diagrams below show the results of our algorithms on two sets of fugues:
- the 24 fugues of the first book of Bach's Well-Tempered Clavier (WTC I), BWV 846-893, analyzed from .krn files from KernScores.
- the 12 first fugues from Shostakovich 24 Preludes and Fugues (op. 57, 1952), analyzed from .mid files from José Oscar de Almeida Marques
The fugue dataset
This dataset gives a reference analysis for the 24 fugues of the first book of Bach's Well-Tempered Clavier (WTC I, BWV 846-893) and the 12 first fugues from Shostakovich 24 Preludes and Fugues (op. 57, 1952). These annotations are based on several musicological sources as well as on our own analysis. The file gives the symbolic position (measure number and position in measure) of subjects (S) and counter-subjects (CS), as well as cadences and pedals. We also report slight modifications of S/CS (actual start with respect to the time signature, delayed resolutions...).
As in any analytical work, there may be no consensus between musicologists for some analytic elements. This is true even for fundamental elements such as the exact definition of the subject: In 8 of the 24 Bach fugues, at least two sources disagree on the end of the subject. We indicate these alternative subject definitions in the file (but do not report alternative CS).
We collected these data firstly to evaluate our own algorithms on fugue analysis, but they might also be useful in other situations, for instance in evaluating algorithms for pattern extraction or structure analysis.
- Download the dataset from http://www.algomus.fr/data
- 2013.12: First release on 12 Shostakovitch fugues + minor updates on Bach fugues (960 annotations)
- 2013.05: First release on 24 Bach fugues (610 annotations)
- Other relevant data
The annotations include all complete subjects and counter-subjects, as well as pedals, and, for Bach, cadences. Further releases will also include also incomplete occurrences of S/CS. We welcome any feedback or suggestions.
Parameters and results
On the diagrams for Bach and Shostakovich fugues, you can switch between a ground truth analysis and the output of our method. For Bach fugues, clicking on any analysis links to a page where S/CS patterns can be displayed with the VexFlow notation engine. For more information, and discussion on this method and its results, please see the bibliographical references.
- Subject and counter-subject predictions 
All the output files are computed with a diatonic interval model and a threshold of (2 + 10%% length). See the full log for details on candidate subjects and counter-subjects. The end of the subject is exactly predicted in 16 of the 24 fugues (bad predictions: Mozart K.546, and Bach's WTC I fugues #5, #8, #9, #12, #19, #22, #23, #24). For Shostakovich fugues, starting from MIDI files, the pitch equivalence model is +/- 1 semitone. The end of the subject is exactly predicted in 13 of the 24 fugues (bad predictions or no predictions: fugues #2, #3, #4, #6, #7, #8, #11, #12, #13, #16, #21).
- Partial harmonic sequences in episodes 
The interval model is here QPI (quantized partially overlapping intervals) [Lemstrom and Laine 98]. Harmonic sequences in at least two voices are detected. See the full log for details on candidate episodes. In WTC fugues, good coverage of episodes with such sequences is obtained for fugues #2, #3, #7, #10, #18, #21.
The complete fugue pipeline (S/CS/CS2, cadences, pedals, structure), as well as the reference dataset, is described in the article . Please cite  if you use the fugue dataset. Principles for S/CS detection were described in , and detection of harmonic sequences in .
-  Mathieu Giraud, Richard Groult, Emmanuel Leguy, Florence Levé, Computational Fugue Analysis, Computer Music Journal, 39(2), 2015
-  Mathieu Giraud, Richard Groult, Florence Levé, Subject and counter-subject detection for analysis of the Well-Tempered Clavier fugues, Computer Music Modeling and Retrieval (CMMR 2012), 2012
-  Mathieu Giraud, Richard Groult, Florence Levé, Detecting episodes with harmonic sequences for fugue analysis, Int. Society for Music Information Retrieval Conf. (ISMIR 2012), 2012
- Siglind Bruhn, J. S. Bach's Wohltemperiertes Klavier, Analyse und Gestaltung, Edition Gorz, 2006, ISBN 3-938095-05-9
- Siglind Bruhn, J. S. Bach's Well-Tempered Clavier. In-depth Analysis and Interpretation, 1993, ISBN 962-580-017-4, 962-580-018-2, 962-580-019-0, 962-580-020-4.
- Claude Charlier, Pour une lecture alternative du Clavier bien tempéré, 2009, Éditions Jacquart
- Hermann Keller, Das Wohltemperierte Klavier von Johann Sebastiann Bach, 1965, Bärenreiter
- Ebenezer Prout, Analysis of J.S. Bach's forty-eight fugues (Das Wohltemperirte Clavier). E. Ashdown, London, 1910.
- Donald F. Tovey, Forty-Eight Preludes and Fugues, J.-S. Bach, 1924, Associated Board of the Royal Schools of Music
- Denis V. Plutalov, Dmitry Shostakovich's Twenty-Four Preludes and Fugues op. 87., Ph.D. thesis, Univ. Nebraska, 2010
- 48 Jewels and 24 Jewels, www.earsense.org