Upgrades for most users should work automatically by typing:
pip3 install --upgrade music21
or (Python 2)
pip install --upgrade music21
Or download from GitHub
A summary of the most important changes since v.2.2 are below:
Fun and easy to understand changes:
Lots more MusicXML support -- better support for time signatures, for grace notes, for spanners, for metadata, for...you name it! And the system is refactored in such a way as to make contributing missing features quite easy.
MIDI files play back in Jupyter/IPython contexts. Lots of improvements there for people who use MuseScore.
The User's Guide has become much more awesome, and you can play with all the good features there.
Many new ways to search scores -- LyricSearcher is fully polished and documented in the User's Guide. Carl Lian's search.serial is upgraded from alpha to a full release that will be easy to expand in the future -- want to know where certain motives are used or transformed? This will make it easy to do. And search.segment -- the old standby -- is even better than ever (see below)
Try splitting notes and recombining them -- lots of intelligence going into this.
There's a big difference between taking a passage up a major third and taking it up 4 semitones. In Chromatic contexts, music21 will now spell things how a musician would like to see them. If you're working with MIDI data, without explicit enharmonics specified, you'll appreciate this.
Go ahead and use '~/../dir' and things like that in your file parsing -- music21 groks all that.
Look at you, fancy programmer, with your 4-CPU laptop! Why not give common.runParallel(tasks, function) a try and get music21 working 2-3x faster than before? (just make sure that "tasks" isn't a list of Streams). Oh, and if you're using search.segment to search for a particular passage inside a large collection of files, don't worry about using runParallel -- we'll do that for you automatically.
Docs are pretty and much better. The User's Guide is the place to start.
Too many other changes to mention, but some shoutouts to Shimpe for new Lilypond code (triplet chords, etc.), Frank Zalkow for enharmonic spelling , dynamics, tempos and other things, Chris Antilla for continued dedication to MEI processing, Emily Zhang for hashing functions and speeding up MIDI quantization, Sonovice for articulation handling, Dr. Schmidt for Chord symbol translations, Bagratte for IO cross Py2/3 fixes, Bo-Cheng Jhan for great braille contributions.
Big under the hood changes.
Big, backwards incompatible change: Many calls such as .parts, .notes, .getElementsByClass(), .getElementsByOffset(), etc. no longer return Streams. They now are iterators (returning something called a StreamIterator). For most uses, this is not going to change anything. You can still use: for n in myStream.notes: and it'll work great. It makes many parts of music21 much, much faster. For small scores, the differences will be small. For large scores, the differences will be tremendous, especially when filters are chained, such as: myScore.recurse().notes.getElementsByClass('Chord').getElementsByOffset(0.0). You're going to find that writing iterator chains is an amazing way to only get at items you want, especially with custom filters. To get the old behavior, just add .stream() to the end of your iteration.
Because none of these filters change the activeSite of an element, you'll find that this is much more stable than before.
If you want to know what the note after a given note is in a musical context, call n.next() or n.previous(). If it's the last note of a measure, it'll move on the first note of the next. And once you've called .next() on one note of a stream, the remaining calls will be super super fast. I still haven't wrapped my mind completely around this paradigm, but it sure beats all the fooling around I used to do to figure out if one note was the same pitch as the next one, etc.
If you've been using music21 for some time, but have never looked at the docs for base.contextSites(), do it -- this is a very fast and extremely powerful way of figuring out how two objects relate to each other. Together with the .next(), .previous(), and better support for .derivation, many extremely powerful systems can be written in music21 easily that could only be written with huge difficulty before.
Nearly all functions marked deprecated in v.2. have been removed. Lots of super obscure functions in .base.Music21Object or .sites.Sites are gone. This is a positive step since it'll make the documentation for these objects simple enough to understand.
Sorting works. I mean, it just works. With grace notes, with oddly positioned elements, with what have you. And it's pretty darn fast. This might seem like something small, but it's enormous for us.
Corpus managing is much simplified -- if you ever thought in the past, "Hey, I'd like to use a custom corpus" and then thought, "uhh...no thanks..." give a look at what is needed to set one up now. You'll be glad for it!
Musescore and not Lilypond is used in Jupyter/IPython notebooks.
Complex durations are a lot less complex -- and faster.
PyLint on all code -- I estimate that at least 200 undetected bugs vanished through this major effort.
As noted in messages to the music21 mailing list (music21list at Google Groups), v.3.1 is the first non-beta release in the v.3 lineup. Version 3 happens to share a version number with Python 3, but that is merely coincidence. Music21 version 3 continues to work with Python 2.7 as well as Python 3.4. Version 3 adds explicit support for Python 3.5 and drops support for Python 3.3. Music21 will continue to develop into a Version 4 to be released next summer (4.0.x will be alpha and beta releases and 4.1.0 will be the public release). Version 4 will likely be the last version to support Python 2.
This release represents the end of a year's sabbatical where I got to work on low-low-level music21 functions that I didn't think anyone else would want to. Due to teaching and other obligations, I'll be taking off work on the heart of music21 until the holidays (I'll still be taking bug fixes, etc.) and working more on documentation, examples, and applications. The changes put in place for music21 v.3 has made working with it a lot more fun for me, so you'll probably see more a lot more applications get added, first to the alpha directory and then into the main set. I've also put up a version 4 roadmap (trees are almost done, they should make it in. Style objects will be introduced so that beautiful musical scores can be created or at least imported and exported properly without major speed loses) so if anyone wants to take the lead on a project you can do so. I'm working on a project called STAMR, Small Tools for Agile Music Research, which should create standalone tools using music21 and music21j for musicologists to get their work done faster. Given that I'm teaching music fundamentals online again, you should see music21 and music21j integration working far better than ever before.
Thanks to MIT for supporting my work, and the Seaver Institute and the NEH for initial funding to make music21 a success. And thanks to this great community for all your contributions in the past and contributions to come.
Get it at:
This is likely to be the Release Candidate also for music21 v.3. I've indicated several times in the past that music21 v.3 is the last release that I guarantee will continue to support Python 2. I now suspect that there will be a Python 2.7-compatible v.4, since Python 2.7 is still the shipping version of Python w/ macOS Sierra.
Notes about the substantial changes in Version 3 have been posted on this list several times. The biggest changes are that .getElementsByClass() and .notes, etc. all return a new class called a “StreamIterator” which makes working with stream filtering much much faster than before, especially for very large streams.
The new tree-based storage system is still too flaky to turn on by default except in a few cases, and will be deferred to Music21 v.4.
Laundry list of items changed since 3.03-alpha:
min Python 3 version is now 3.4 -- 3.3 should still work but is untested.Notes parsed from MIDI or transposed by a number of semitones now get a .spellingIsInferred attribute which indicates that they can change their spelling ("G#" vs "A-") as needed for the situation. This is incompatible behavior, but much improved!
More User's Guide chapters...
Lots of improvements to Braille output, and refactoring to make more improvements in the future possible. (Thanks Bo-Cheng Jhan! and esp. to Jose Cabal-Ugaz in the first place).
Better documentation for Searching Lyrics (User's Guide, Chapter 28)
MIDI will now handle part names, etc. that use unicode.
Long files (>10 pages) in Musescore automatic PDF generation format now work (thanks Emily Zhang)
TimeSignatures such as 2/4+3/8 display much better now.
TimeSignatures import and export symbols ('common', 'cut', etc.) in MusicXML properly.
Fixes for musicxml parsing where both voices and chords interact.
configure.py now finds common MusicXML readers (Finale, Sibelius, MuseScore) on Windows!
InsertIntoNoteOrChord works in more cases
Streams are faster to calculate their own durations
Major speedups to large makeMeasure() calls.
A failure in makeTies now gives a warning instead of an exception
The old "musicxmlOld" format is removed.
metronomeMarkBoundaries works better (thanks Frank Zalkow!)
improved ability to specify how to quantize MIDI (thanks EZ!)
improvements to automatic instrument detection.
lots more MEI articulations work (thanks sonovice)
Fingerings import and export to MusicXML better.
noteheadParentheses work well now.
Roman.fromChordAndKey gets quite a few more chords now.
incompatible change: normalOrder instead of normalForm for chords -- gives the untransposed ordering of a chord -- this is the correct behavior; prior behavior is wrong.
incompatible change: Stream.offsetMap is now a method
incompatible change: common.isStr() removed -- use isinstance(s, str) or (s, (str, unicode))
incompatible change: key.KeySignature() no longer supports a .mode attribute. Use key.Key() instead. key.KeySignature() objects get an .asKey('major') etc. attribute.
incompatible change: pitches lose ".getMidiPreCentShift()" method. Just call .midi instead!
in case you missed what is new in v.3.0.3:
Last year I learned about music21 and ever since I have been wondering how I can use it to learn more about the Moroccan musical repertoires that I study. Long story short, I ended up building a tool for creating interactive web-based contour visualizations from the command line and I'd like to share it here.
Climbing out of a rabbit hole
|Malhun Performance in Fez, Morocco|
|Malhun Contour Example|
Building a tool
|ContourViz, simple example|
|ContourViz, more complex example|
I am a gigging musician and bass player who has discovered music21, but, alas, I am certainly not a musicologist or academic.
I have seen many of the amazing examples that showcase music21’s capabilities with classical and twentieth-century music, and wanted to show how I use music21. Hopefully these examples show that music21 can also be used to explore jazz and popular music, either via analysis for educational purposes or for developing improvisational ideas.
Jazz Standard Voice Leading LinesMusic21 has an amazing corpus of public domain classical music, but most jazz standards are not available for inclusion. But, since music21 has an understanding of seventh chords and reads MusicXML, a virtual corpus of jazz standards is available for analysis and exploration via another application called IRealPro. IRealPro is a virtual accompanist software program that has chord charts for over 3000 jazz standards, and which can export the chord progressions in MusicXML, a format that will allow music21 to understand the harmony. Once we have that outline of a jazz standard's harmonic structure, music21 can be turned loose.
For this example, lets export the chord chart to the standard “Alone Together” and generate a 3rd to 7th voice-leading line through the entire tune, based on this concept by Burt Ligon, as described here.
Alone Together.XML and Guide Tone Lines with Music21.py)
Since music21 understands harmony, any kind of voice leading line is possible, for instance the 5th resolving to the 9th. Now these voice leading lines can be generated for any jazz standard (or for any chord progression) that can be exported as MusicXML format and these lines can be used as jumping off points for making solos or studying voice leading.
Jazz Solo AnalysisAnalyzing jazz solos from the masters is another way to get improvisational material, but it is better known as stealing someones licks! Since music21 can understand the relationship of any note to any chord, it can be used to analyze the functional relationship of the notes in a solo.
Here is an example of Miles Davis’s solo on “Freddie Freeloader” with the notes being labeled so they represent their function against the chord being played, for example, an F note on a Bb7 chord being the fifth.
Miles Solo XML and Melodic Labeler.py)
This same Music21 code was used to analyze Charlie Parker's solo on Bloomdido, and a walking bass line over F blues by Ron Carter.
Now any solo line that can be exported as MusicXML can be analyzed by music21 and then explored even further. What notes are favored? What beats of the bar do certain notes get played on? How many times do certain notes get played? Are there repeating phrases that a certain player uses over and over? All of this can be cataloged or graphed once it has been brought into the music21 world. The included code needs a chord symbol over every measure.
Hopefully these examples show that music21 is not only for musicologists exploring the pitch class space of Bartok's string quartets or for twelve-tone row composers! Students and musicians can use it for very useful and practical purposes as well. Many thanks to Michael for allowing this guest posting from big music21 fan!
(Ed: Thanks Dan! The examples included here are copyrighted by their respective composers and publishers. We believe their inclusion here for educational and instructional purposes are supported by all four factors of the Fair Use test).
My two biggest problems preventing success have been (1) Maintaining an Inbox Zero philosophy, where at least daily, I get my Inbox to zero, by deleting messages, doing a very quick reply, or immediately creating a task for a message that requires more than 2–5 minutes to take care of, and (2) being realistic about the number of tasks that I can possibly say yes to and have the time to actually do.
Sometimes, I can maintain Inbox Zero for six or eight months. Other times, I get way behind on Inbox Zero and need to resort to an Inbox DMZ to reset the obligations that I have. Usually the thrill of an empty inbox at that point will let me get out of DMZ in a few weeks. Maybe someday I'll write about how this happens to me and how I break the cycle (at least so I can read this post again later), but at this moment, I'm almost out of Inbox/Email Hell. So my big problem lately is the second one.
When I was a graduate student, or just starting out as a professor, I was so thrilled that someone was asking little ol' me to be on a committee, help them with a problem in my field ("Can you transcribe this medieval song?"), or, big honor, fly out and give a talk at their school. I am still honored to be asked, but fortunately or unfortunately, at this point in my career, I'm asked to do far too many things that I could possibly do.
One of the hardest parts about saying "no," is that I have always been far too much of an optimist about how long a particular task will take. Sure, it'd just take twenty minutes to write that recommendation letter, IF I were in the right mental state, not distracted, had all my ducks in a row, etc. Realistically, I've never gotten one done in under an hour, and three hours is more usual. An article review? I need to learn that I write far too many notes to the author, duplicate too much of the research, order sources from ILL, etc., and so eight hours is a realistic timeline for me for a twenty-page review.
I've figured that I have about sixty hours of work in me per week (not just academic work but also counting certain stressful obligations, such as being a trustee, dealing with a plumber, etc. that I don't consider fun time). Of those sixty hours, I know that recurring obligations such as teaching and advising will take up about 30 hours a week most of the year. This leaves about 30 hours per week (1500 hours per year) to do everything else I've either agreed to do, or need to do to continue to develop as a professor (researching and writing articles and books, developing music analysis software, etc.). Twenty letters of recommendation and ten article reviews per year eats up 10% of that time. Joining a board is probably 50 hours a year. Etc. etc. Adding it all up and it's easy to see why the years when I say "No" often, I can write, say, two chapters and three articles, and those that I don't, I'm lucky to get a single article out.
(And then there's the damage I do to others when I say "Yes, sure!" and then end up stretching or breaking deadlines or needing to cancel later; this is the worst of all possible options.)
Each day I try to create a realistic plan for the day during a morning review. It always begins with Inbox zero as a task. (Since 2012, I've tried to make every task begin with an action verb. "Inbox zero" has somehow remained as an exception, since I always know what to do about it). Each task usually has two tags attached to it, a location tag ("@Any" is the most common. "@Home", "@MIT" also appear), and a time tag ("5 min," "15 min", "1 hr", etc.). When I've organized the ToDos in a good order for the day, and adjusted the times to what I think are realistic, I run the thingsToCal.scpt which puts all the todos on the calendar, making sure that they don't interfere with any events already in the calendar. The results are below:
I can now see that, hmm... given that it's my turn to cook, I'm going to need to be willing to work until around 9:30 if I'm going to get all these things done; for a weekday, that's fine. For Sunday night, I think I'd rather not. Something (probably that "Get an Outline" for Tuesday's talk event) will need to go till to tomorrow. (And that was before I added an hour-long "Blog about this system" todo). After rearranging, etc., I rerun the script and the events for the day get removed and readded in the new order.
I'm hoping that this system works well. If you are geeky and want to try it out, the code is at this link. It runs only with Things (if Time tags are set up properly) and OS X/macOS Calendar (with a calendar called Things) and you'll need to use it at your own risk (Sorry if something gets screwed up in your calendar), hence I'm not providing installation instructions beyond this link. But if I can get it to run faster (currently, figuring out my existing schedule on Calendar takes 20-30 seconds) and perhaps to work with next items beyond today (and maybe preserving non-working hours, etc.) then I'll make it a nicer script.
Wish me luck! Especially if you've been waiting on a reply or for me to do something for you.
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-11, 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.
Numeric Deathmatch, a game I coded that was taught to me by Jon Wild. More fun in person, but the web interface encourages trashtalking.
Musicology Buzzword Bingo, useful for AMS meetings (requires Bach and Futura fonts)
Automatic New Musicology Paper Generator based on the Dada engine