Skip to main content

CRIM intervals package

Project description

CRIM Intervals: Python Tools for the Analysis of Encoded Music Scores

Current Version: 2.0.62

CRIM Intervals on github

Install CRIM Intervals and its Dependencies

Install with pypi package manager: pip install crim_intervals

About CRIM Intervals

Based on Python and Pandas, and Mike Cuthbert's excellent music21 (https://web.mit.edu/music21/), CRIM Intervals is a pattern finding engine for musical scores, with an emphasis on the kinds of melodic, harmonic, and contrapuntal patterns found in Renaissance polyphony. It has been developed as a primary data analysis tool for Citations: The Renaissance Imitation Mass (http://crimproject.org and https://sites.google.com/haverford.edu/crim-project/home), directed by Professor Richard Freedman (Haverford College, USA), in partnership with dozens of researchers and students around the world. Contact rfreedma at haverford.edu to learn more about the project, and how you can take part.

File Formats: CRIM Intervals will analyze scores encoded in several widely-used formats: MEI, MusicXML, and MIDI. Results will vary according to the editorial practices used in the underlying transcriptions and editions.

The CRIM Intervals Web Application: Get started quickly with the CRIM Intervals Streamlit Application, which requires no coding sklls. You can work with the CRIM Corpus, or import your own pieces, producing analytic tables, visualizations, and other results that you can download for use in publications and teaching. The web app is free and requires no special account or software installation. Tutorials are available on the site itself, with pointers back to the code and tutorials here on CRIM Intervals itself.

Learn How Others are Using CRIM Intervals via CRIM Essays and Experiments, which assembles recent work by over two-dozen scholars and students from around the world. Find out what is possible, what others are thinking about, and how you might use their work to advance your teaching and research.

Getting Started with CRIM Intervals

This respository contains the CRIM Intervals library itself, along with tutorials that explain the various methods, and Jupyter Notebooks make them easy to use for your research and teaching. There are various ways to get started:

  • The CRIM Intervals Streamlit Application, which requires no coding sklls. You can work with the CRIM Corpus, or import your own pieces, producing analytic tables, visualizations, and other results that you can download for use in publications and teaching.

  • Install and run CRIM Intervals (along with the Notebooks) locally with Anaconda Navigator, VS-Code, and Jupyter. See Richard Freedman's Encoding Music course page to learn how.

  • Install the latest version of CRIM Intervals library via pypi.org.

  • Run CRIM Intervals via a free Jupyter-hub maintained by Haverford College (contact rfreedma at haverford.edu) to obtain an account.

The Basics

CRIM Intervals begins by importing one (or more) MEI, MusicXML, and MIDI files, for example: piece = importScore('https://crimproject.org/mei/CRIM_Model_0008.mei') Once imported this piece object can be explored in various ways. piece.notes(), for instance, produces a dataframe in which each staff (voice part) is represented as a column of events--notes, rests, durations, lyrics, etc. Other methods (see the list below) in turn present these basic events in many different ways: as melodic intervals, harmonic intervals, n-grams, contrapuntal "modules", and so on.

There are many ways to configure these basic methods. For instance intervals can be diatonic, or chromatic, or with (and without) 'quality' (such as M3 vs m3). They can also be simple or compound (a tenth in the latter would be a third in the former).Unisons can be combined (something helpful for comparing similar melodies), or events can be taken at actual durations or 'sampled' at some regular durational span.

Complete documentation of each method capacities is available via doc.strings via this command print(model.YourMethod.__doc__), where you will replace 'YourMethod' with the name of the individual method, for example print(piece.melodic.__doc__).

Results are reported in Pandas dataframes (and thus exportable in a variey of standard formats for further analysis), and also via several visualizations methods.

Some methods in CRIM Intervals also work with CRIM Project data created by human observers.

Key Methods in CRIM Intervals

Melody, Harmony, Rhythm, Lyrics and NGrams

  • piece.notes(), which finds all the notes and rests in a score, with a tabular score-like representation of the pitches, pitch classes, and durations (expressed in music21 "offsets", in which each quarter note corresponds to the value of 1.0). It can also derminte the location of any note as a measure+beat reference with detailIndex
  • piece.melodic(), which finds melodic intervals in any voice part, with various options for diatonic, chromatic and zero-based distances. Intervals can be compound (distinguishing between tenths and thirds, for instance), or simple, and can include quality (distinguishing major and minor thirds, for instance), or not.
  • piece.harmonic(), which finds harmonic intervals between every combination of two voices in a piece, with various options for diatonic and chromatic. These intervals can also be directed (as when a tenor voice sounds above the altus), or not.
  • piece.lyrics() (for every note)
  • piece.durations(), with quarter-note = 1.0, as per music21.
  • piece.ngrams(), which finds n-grams of any length in each voice part. n-grams are frequently used in linguistic analysis (), and can help us find repeating patterns within and among works. The ngram tool can be used for any of the methods above: melodic, harmonic, durations, lyrics. By default it finds contrapuntal modules, which represent in numerical values a combination of the vertical intervals made between any two voices with the melodic intervals heard in the motion of the lower voice. A module of 7_Held 6_-2, 8 for instance, represents vertical intervals of 7, 6, 8 between two voices and in the lower voice a tied note followed by a descending second. Together these five events represent a typical cadence formula. Repeating modules are a key part of Renaissance contrapuntal style.

It is also possible to apply various edit distance tools to many of these patterns, thus allowing users to find exact and close matches.

Classification of Contrapuntal Types

CRIM Intervals also include advanced methods that use combinations of the methods detailed above to predict "contrapuntal types" commonly found in Renaissance polyphony.

  • Cadences are one such type: piece.cadences() can find them with a high degree of accuracy.
  • We have also developed a method that predict various imitative textures, including Fugas, Imitative Duos, Non-Imitative Duoes, and Periodic Entries (as Peter Schubert has named them): piece.presentationTypes().
  • It is also possible to accurately identify homorhythmic passages (where sets of voices move in the same durations and declaim the same lyrics): piece.homorhythm().

In each case we there are various options users can select to refine the searches, including various tools that allow for similar no less than exact matches. Melodic and rhythmic 'flexing' are key parts of Renaissance counterpoint. These methods are too complex to summarize in a short space. But they are powerful tools for machine prospecting of musical works.

Heatmaps, Graphs, and Networks

CRIM Intervals also features tools that help us visualize musical events in different ways, including:

  • bar charts and histograms of events (such as notes, or intervals), which are useful for understand ranges, distributions, and other large-scale distribution of categorical data
  • heatmaps, showing where in a piece patterns (such as repeating n-grams) occur
  • radar plots, used to show cadences in a radial plot that reveals the tonal profile of a composition (or a corpus of works)
  • progress charts, showing a cadences in a series (from start to finish)
  • network diagrams, showing related patterns or pieces

One Piece, or a Corpus

CRIM Intervals methods can also be applied to a corpus of pieces. We first define a corpus: corpus = CorpusBase(['https://crimproject.org/mei/CRIM_Mass_0006_1.mei', 'https://crimproject.org/mei/CRIM_Mass_0006_2.mei', 'https://crimproject.org/mei/CRIM_Mass_0006_3.mei']), then specify a method to run against each piece in the corpus: corpus.batch(func=ImportedPiece.cadences). The results are reported as a combined dataframe.

Render Scores (or Excertps) with Verovio

  • CRIM Intervals also has the capacity to render results as modern score with Laurent Pugin's Verovio (for example piece.verovioCadences()), as well as reporting them as data frames and visualizations.

Credits and Intellectual Property Statement

CRIM Intervals is the Work of Many Hands:

  • Andrew Janco (Haverford College/Universit of Pennsylvania)
  • Freddie Gould (Haverford College/Audible)
  • Trang Dang (Bryn Mawr College)
  • Alexander Morgan (EcoRate)
  • Daniel Russo-Batterham (Melbourne University)
  • Richard Freedman (Haverford College)
  • Oleh Shostak (Haverford College)
  • Edgar Leon (Haverford College)
  • Harrison West (Haverford College)
  • Patty Guardiola (Haverford College)
  • Anna Lacy (Haverford College)

CRIM Intervals is made possible generous support from:

  • Haverford College
  • The American Council of Learned Societies

All CRIM intervals tools are available via a Creative Commons license (Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)): https://creativecommons.org/licenses/by-sa/4.0/.

Sections in this guide

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crim_intervals-2.0.62.tar.gz (100.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

crim_intervals-2.0.62-py3-none-any.whl (100.1 kB view details)

Uploaded Python 3

File details

Details for the file crim_intervals-2.0.62.tar.gz.

File metadata

  • Download URL: crim_intervals-2.0.62.tar.gz
  • Upload date:
  • Size: 100.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.11.14 Linux/6.11.0-1018-azure

File hashes

Hashes for crim_intervals-2.0.62.tar.gz
Algorithm Hash digest
SHA256 b50044be1499a39ef70b6fa54711c439ebfa3ba48b5767d5c4c9cfc90d64fe87
MD5 7a6030701b24094c111a52d1d7bf9848
BLAKE2b-256 1504c23a635ea6ae49cfb115eed7dd3339decff74b7405355c0ad9845bfffcf9

See more details on using hashes here.

File details

Details for the file crim_intervals-2.0.62-py3-none-any.whl.

File metadata

  • Download URL: crim_intervals-2.0.62-py3-none-any.whl
  • Upload date:
  • Size: 100.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.11.14 Linux/6.11.0-1018-azure

File hashes

Hashes for crim_intervals-2.0.62-py3-none-any.whl
Algorithm Hash digest
SHA256 1e85192e9efb877f705d6a1d949af150c3510b7b038e6d9872df30ab93ffd142
MD5 636ea8fbdab7862742aff36bd6d16df4
BLAKE2b-256 1af1213b84fc40d9b6cf5da66be33f713a429fad2ba346f47cd4cc86a9022016

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page