All research ideas

Ongoing · Part II · 2026 · Richard Sharp

A Language for Finding Patterns and Rule Violations in Musical Scores

https://anil.recoil.org/ideas/scour-music-patternsimage

Musicologists and music theory teachers often want to find instances of musical patterns, or of broken rules, in a body of scores. They may be doing research or looking for teaching examples. A pattern might be a perfect cadence, and a violation might be parallel fifths, where two voices move in the same direction while staying a perfect fifth apart. Rules are usually stated informally in prose, which leaves room for ambiguity, and manual searching does not scale to large volumes of music.

Four approaches exist today. Humdrum works through text and regular expressions and has a steep learning curve[1]. Python libraries such as music21[2] and the VIS framework[3] need imperative code for any query beyond their built-in ones. Notation-based query prototypes such as MusicQuery[4] handle only monophonic music. PatternFinder[5] searches by example passage and not by a stated pattern or rule. None of these appears to offer a purpose-built language for stating polyphonic patterns, whether voice-leading or chord-level, declaratively and searching a corpus for them.

This project will design Scour, a language for specifying patterns and rules, and write a compiler in OCaml that turns each query into a program that finds where each pattern or rule violation occurs in scores. Declarative languages compiled into program analysers are already established for finding bugs and rule violations in source code, as in QL[6] and Soufflé[7]. Each Scour query will have a precise, documented meaning, and can be shared as a file and rerun on other scores. Queries can refer to chords and cadences, which are detected from the score. The chord detector will be benchmarked for speed and accuracy against labelled chords from the When in Rome dataset[8].

  1. Huron, D., 2002. Music information processing using the Humdrum toolkit: Concepts, examples, and lessons. Computer Music Journal, 26(2), pp.11-26.

    ↩︎︎
  2. Cuthbert, M.S. and Ariza, C., 2010. music21: A toolkit for computer-aided musicology and symbolic music data. ISMIR.

    ↩︎︎
  3. Antila, C. and Cumming, J., 2014. The VIS Framework: Analyzing Counterpoint in Large Datasets. In ISMIR, pp.71-76.

    ↩︎︎
  4. Gover, M. and Fujinaga, I., 2019. A notation-based query language for searching in symbolic music. In Proceedings of the 6th International Conference on Digital Libraries for Musicology, pp.79-83.

    ↩︎︎
  5. Garfinkle, D., Arthur, C., Schubert, P., Cumming, J. and Fujinaga, I., 2017. PatternFinder: Content-based music retrieval with music21. In Proceedings of the 4th International Workshop on Digital Libraries for Musicology, pp.5-8.

    ↩︎︎
  6. Avgustinov, P., De Moor, O., Jones, M.P. and Schäfer, M., 2016. QL: Object-oriented queries on relational data. In 30th European Conference on Object-Oriented Programming (ECOOP 2016).

    ↩︎︎
  7. Jordan, H., Scholz, B. and Subotić, P., 2016. Soufflé: On synthesis of program analyzers. In International Conference on Computer Aided Verification, pp.422-430.

    ↩︎︎
  8. Gotham, M., Micchi, G., López, N.N. and Sailor, M., 2023. When in Rome: A meta-corpus of functional harmony. Transactions of the International Society for Music Information Retrieval, 6(1), pp.150-166.

    ↩︎︎