An important milestone for music21 passed unnoticed by me a few weeks ago: ten years since the first time that code (well mostly documentation and tests) that still remains somewhere in the music21 codebase was run and did something useful (a scrambled loop for a composition project I was working on called Fine dead sound, after Faulkner). It seemed worth saying a bit about the history of the project and things learned along the way.
Music21 started as a Perl project -- the oldest code I can find that even vaguely resembles the current music21 comes from November 2003, a 30k Perl script to label a Bach chorale with Roman numerals and correct keys (I still need to publish the algorithm somewhere since I haven't seen a better one). It had no graphical output except using David Rakowski's Lassus font. I was able to get it back up and running and through the modern miracle of web fonts, everyone (except IE users) can play with the oldest music21 system at: http://www.trecento.com/test/lassus.cgi?num=260. If I remember correctly, chords in red had only a passing functionality, the small letters are the roots of chords and the second line of text is the locally active key. Pivot chords are labeled in brackets. This was done for an assignment in Avi Pfeffer's AI and Music class; others in my group had already produced the code (in C I believe) for removing passing tones from the score.
Version 2 is the first version of music21 since v.1 to make substantial changes in the code base that introduce backwards incompatibilities in order to make going forward faster and smoother. It doesn't change anything super fundamental à la Python 3's print function, so most code should still run fine, but definitely test in a separate environment before upgrading on any code you have that needs to run without problems. The system is still changing and more backward-incompatible changes could be included until v.2.1.
We have had 420 commits since the last release, so there is a lot that is new!
Substantial changes include:
- Offsets and quarterLengths are now stored internally as Fractions if they cannot be exactly represented as floating point numbers. A lot of work went into making this conversion extremely fast; you probably won't ever notice the speed difference, but you can now be sure that seven septuplets will add up to exactly a half note. For instance:
- >>> n = note.Note()>>> n.duration.appendTuplet(duration.Tuplet(3,2))>>> n.fullName'C in octave 4 Quarter Triplet (2/3 QL) Note'>>> n.quarterLengthFraction(2, 3)>>> n.quarterLengthFloat # if you need it...0.6666666666666666
- Converter structure has been overhauled for more easily adding new converters in the future. If you've wanted to write a converter or already have one for a format not supported but have been daunted by how to include it in music21 now is a great time to do it. Speaking of which...
- MEI format is supported for import (thanks to Chris Antila and the ELVIS team at McGill university for this great enhancement)
- Python 2.6 is no longer supported. All tests and demos pass and run on Python 2.7, 3.3, and 3.4. (3.2 and older are not supported)
- FreezeThaw on Streams works much better and caching loaded scores works great (some of this was included in 1.9, so definitely upgrade at least to that.
- Lots of places that used to return anonymous tuples, now return namedtuples for more easily understanding what the return values mean.
- Integrated Travis-CI testing and Coverage tests will keep many more bugs out of music21 in the future.
- Many small problems with Sorting and stream handling fixed.
- Corpus changed: for various licensing reasons, v.2.0 does not include the scores from the MuseData corpus anymore. This change mostly affects Haydn string quartets and Handel's Messiah. However, new replacement scores are being included and 2.1 will have as many great works as before. The MuseData scores are still available online. MuseData is now a deprecated format and no further testing on it will be conducted; only bug fixes that are easily implemented will be accepted.
- music21 is now available under the BSD license in addition to LGPL!
- Stream __repr__ now includes a pointer rather than a number if .id is not set. This change will make filtering out doctests easier in the future.
- TinyNotation no longer allows for a two-element tuple where the second element is the time signature. Replace: ("C4 D E", "3/4") with ("tinynotation: 3/4 C4 D E")
- Obscure calls in SpannerBundle have been removed: spannerBundle.getByClassComplete etc.
- Convenience classes: WholeNote, HalfNote, etc. have been removed. Replace with Note(type='whole') etc.
- Old convenience classes for moving from Perl to Python (DefaultHash, defList) have been removed or renamed (defaultlist)
- Articulations are marked as equal if they are of the same class, regardless of other attributes.
- common.almostLessThan, etc. are gone; were only needed for float rounding, and that problem is fixed.
- duration.aggregateTupletRatio is now aggregateTupletMultiplier, which is more correct.
- scala.ScalaStorage renamed scala.ScalaData
- common.nearestMultiplier now returns the signed difference.
- layout -- names changed for consistency (some layout objects had "startMeasure" and some "measureStart" - now they're all the same); now all use namedtuples.
- rarely used functions in Sites, base, Duration, SpannerStorage, VariantStorage, have been removed or renamed. I'd be surprised if these affect anyone outside the development team.
- common.mixedNumeral for working with large rational numbers
- common.opFrac() optionally converts a float, int, or Fraction to a float, int, or Fraction depending on what is necessary to get exact representations. This is a highly optimized function responsible for music21 working with Fractions at about 10x the speed of normal Fraction work.
- Rest objects get a .lineShift attribute for layout.
- staffDetails, printObject MXL had a bug, writing out "True" instead of "yes"
- staffLines is now an int not float. (duh!)
- better checks for reused pointers.
- lots of private methods are now ready for public hacking!
- Lyric.rawText() will return "hel-" instead of "hel" for "hel-lo".
- music21j / 21M.051 -- I've been translating music21 to the web to support my teaching of MIT's "Fundamentals of Music" -- feel free to register for an account an play around.
- The Other Tournai Kyrie -- A lost piece of medieval music was sitting right under our noses.
- music21 -- what exactly is a "Toolkit for Computational Musicology"? Older article. The latest version at GitHub
- Conference / Journal Convergence -- When top journals begin publishing only articles presented at invited conferences, do less connected scholars lose out?
- When Computers Listen to Music, What do they hear? -- on music21 and other Boston area projects (Boston Globe)
- Musical examples in web pages -- an easier way to do this than before, using cuthbertLab's music21j.
- Advanced dotting -- the mathematics behind that simple feature of musical notation: the dot.
- An early fifteenth century canon -- unraveled from a manuscript of Strasbourg destroyed in the fire of 1870.
- Bach's voice ranges -- a how-to on music visualization.
- Changing Musical Time -- how rhythm and tempo have evolved over the last 1000 years.
- Sexism and Age in Politics -- are older folks more sexist when it comes to electing a president? The data is unconvincing.
- Are bullpens underused? -- solve for x, and call the bullpen earlier.
I am a researcher within the Performing Arts Medicine Association. I was interested in looking at Beethoven's use of range over time in his piano sonatas. Although several previous studies have looked at the question of how Beethoven's compositions were affected by his hearing loss, the results were far less than conclusive. A study in the British Medical Journal counted the notes in the first movements of the first violin parts of Beethoven's string quartet's by hand. For a number of reasons, I thought it might be better to look at the piano sonatas, including that Beethoven wrote more piano sonatas than he did string quartets and symphonies, so the statistical power would be greater. Counting all of the notes in Beethoven's piano sonatas by hand would be a Herculean task for sure, but fortunately with scores available from the Center for Computer Assisted Humanities and music21 sufficient coding skills would do the job.
In addition to the number of high notes, I was also interested in Beethoven's overall use of range, the average note, average frequency, number of measures with high notes, and in calculating values based on the number of notes, as well as weighting those measures by the duration of notes. The methods available in music21 allow the collection of this data very quickly. To collect the majority of the data I needed from all 103 movements of Beethoven's piano sonatas, count over a quarter million individual notes, and organize the data into sonatas, and separating the data by movement number, takes about 11 minutes.
Some Interesting Findings
Beethoven's use of high notes was lowest around 1800 (for all the graphs below, the colors within the dots represent the Sonata Numbers, going from red to purple from 1-32):
The average frequency of each sonata follows a similar trend:
In general, as there are more notes per measure, there are more high notes per measure. This trend does not hold many of the sonatas written before 1802.
Also, the relationship between the use of high notes, and the average frequency was different between the earlier and later sonatas:
Technology like music21 is an invaluable tool for the empirical study of musicology. Relatively quickly, data gathered can be used to analyze the possible relationships between Beethoven's use of high notes and his overall range, and compare that with what we understand about his hearing loss. These data suggest that Beethoven was significantly affected by his hearing loss, though it seems that sometime around 1802 he developed strategies to cope with his progressing disability.
Cuthbert received his A.B. summa cum laude, A.M. and Ph.D. degrees from Harvard University. He spent 2004-05 at the American Academy as a Rome Prize winner in Medieval Studies, 2009-10 as Fellow at Harvard's Villa I Tatti Center for Italian Renaissance Studies in Florence, and in 2012–13 was a Fellow at the Radcliffe Institute in 2012-13. Prior to coming to MIT, Cuthbert was Visiting Assistant Professor on the faculties of Smith and Mount Holyoke Colleges. His teaching includes early music, music since 1900, computational musicology, and music theory.
Cuthbert has worked extensively on computer-aided musical analysis, fourteenth-century music, and the music of the past forty years. He is creator and principal investigator of the music21 project. He has lectured and published on fragments and palimpsests of the late Middle Ages, set analysis of Sub-Saharan African Rhythm, Minimalism, and the music of John Zorn.
Cuthbert is writing a book on Italian sacred music from the arrival of the Black Death to the end of the Great Schism.
Download what is almost certainly an out-of-date C.V. here (last modified June 2012)
Bologna Q15: the making and remaking of a musical manuscript, review for Notes 66.3 (March), pp. 656-60.
"Palimpsests, Sketches, and Extracts: The Organization and Compositions of Seville 5-2-25," L’Ars Nova Italiana del Trecento 7, pp. 57–78.
Der Mensural Codex St. Emmeram: Faksimile der Handschift Clm 14274 der Bayerischen Staatsbibliothek München, review for Notes 65.4 (June), pp. 252–4.
"Generalized Set Analysis and Sub-Saharan African Rhythm? Evaluating and Expanding the Theories of Willie Anku," Journal of New Music Research (formerly Interface) 35.3, pp. 211–19. [.pdf]
Unless otherwise mentioned, the writings, compositions and recordings on this site are licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License.
Copyright 2010-14, Michael Scott Cuthbert. Web design by M.S.C.
Fonts for musicology: Ciconia (14th/15th c.) and ClarFinger (clarinet music).
In my copious spare time as a junior faculty member on tenure track, I do web design and programming consulting for the National Bureau of Economic Research.
Lectures on the web
enChanting: Musical Artifacts in Unlikely Places, lecture March 3, 2009
Ambiguity, Process, and Information Content in Minimal Music, podcast of a lecture to Comparative Media Studies at M.I.T.
Just for fun...
Mondrian meets Finding Aids in a map of books in my former apartment.
Musicology Buzzword Bingo, useful for AMS meetings (requires Bach and Futura fonts)
Automatic New Musicology Paper Generator based on the Dada engine