Sunday, August 6, 2017

Music21 v.4 released (4.1.0)

The first release of music21 version 4 was released today (August 6, 2017).  This is the first major release of music21 in a year, and it brings with it a wealth of new tools for analyzing music with a computer and performing digital musicology, music theory, and composition.

Download from https://github.com/cuthbertLab/music21/releases or from the terminal, type:

    pip3 install --upgrade music21

(or without the "3" if you are using Python 2)

Version 4 is the last version of music21 that will support Python 2.7.  If you run Version 4 on Python 2.7, you will see a warning that it's time to move up to the brilliance that is Python 3.6.

As with all new "X" release names, v.4 has backward incompatible behaviors that I think are worth it for the great new features. 
Among the 272 commits since v.3.1:
Major new features:
  • Graphing rewrite!
.plot() and Graphing has always been one of the most powerful parts of music21 since long before v.1.0 (mad props, Christopher Ariza!) but it's also been one of the most daunting aspects of using music21. It shouldn't be any more. The code has gone through a major rewrite to improve the simplicity of doing easy things and the power when doing difficult things. The easy things are documented in Chapter 22 and the hard things in Chapter 44.
  • Local Corpora are great!
There's been a major rewrite of the corpus.corpora.LocalCorpus() function that makes it a fantastic way to work quickly with files you are working on from your own hard drive.  Set up your own local corpus, add paths to it, set the cacheFilePath to somewhere to store the metadata and you'll be able to search for pieces with particular features and metadata without needing to parse the score.

  • Style!
the all new style module and style.Style object handles aspects of a note or other object's visual display that are not (usually) semantic. This class has allowed a major increase in the ability to properly preserve MusicXML visual formatting on input and export.
Style objects are created only when needed, so el.hasStyleInformation() allows for checking for the presence of a .style object without creating one.
(To be documented more soon)
  • Major rewrite of TinyNotation allows for easy extensibility.
Documented in the User's Guide! Check it out!
  • Always improving docs
The User's Guide goes up to chapter 24 now, with major new examples in Chapter 20 along with rewritten chapters on keys, time signatures, sorting, and so on and so on. Plus all examples are now Retina quality for viewing fine details of scores.
Documentation has been moved out of the music21 directory into the root directory -- it is no longer installed with music21 from pip -- this change was necessitated by the move to retina quality graphics, but reduces the installation size from 90MB to 15MB for the full corpus version and 6MB for the no-corpus version.  All documents are now tested with nbval, to ensure they stay up to date.
Other new features
  • Stream.measures() now optionally allows for indexes (where 0 always is the first measure; -1 is the last, and so on) making .getElementsByClass('Measure') not necessary in most cases.
  • much better metadata processing in musicxml, humdrum, and braille
  • improved braille translation (tuplets) -- thanks Bo-Chen
  • better beaming, meter, and tuplets in ABC
  • output directly to PDF if MuseScore is installed.
  • Nested Tuplets! including in MusicXML.
  • Non-traditional key signatures
  • New works by Clara Schumann in the corpus.
  • stream.iterators.OffsetIterator() -- iterate groups of objects by offset.
  • improvements to analysis.discrete
  • demos/build_melody shows how to build MidiFile directly (thanks PeterMitrano!)
  • corpus paths are now searchable in corpus.search()
  • matplotlib and musescore graphics in Jupyter notebook are now retina quality.
  • Chord.add() and Chord.remove() allow for direct manipulation of chords.
  • Improvements to parallel processing in music21.
  • Ottava spanners now come in two types, transposing and non-transposing -- reflecting whether the pitches under the spanner already reflect the transposition (non-transposing) or not.
  • Palestrina humdrum has been reorganized and parses completely.
  • Many improvements to spanners and RomanNumerals.
  • Beams work much better and transfer in and out of MusicXML more completely.
  • Every MusicXML 3.0 articulation is now supported.
  • Core routines in stream.core have now been exposed publicly.  They are dangerous to use, but for anyone working on their own parsers, they can speed up insertions and appends by an order of magnitude.
Others, including bugs squashed:
  • Warning on Python 2 that music21 v. 4 is the last version to support Py 2.
  • Stream.template() is a great way to get an empty stream that otherwise matches the current Stream.  Replaces the obsolete .measureTemplate()
  • ABC key signature and mode error fixed.
  • RecursiveIterator gets a .currentOffsetInHierarchy, which can let even more places remove the dependence on .flat.  In fact, .flat uses the .recurse() method internally, because recurse() is now so fast.
  • AudioSearch bugs fixed (thanks jjrob13)
  • Chord.normalOrderString (thanks emzhang)
  • Removed lots of old crutches including the "analysisData" on Stream, Note.editorial, and others. Style fixes most of this.
  • fix to Bach BWV 386 (thanks alexcoplan) and to Beethoven Opus 59 no 3, movement 1.
  • Note.pitches returns a tuple not list, just like Chord.pitches
  • Converter can deal with some wrong file extensions now.
  • Instrument reprs are fixed
  • configure finds many more notation programs.
  • ties are imported better between elements in and out of voices in musicxml
  • configure works on macOS when user directory contains spaces.
  • Bugs in ending and restarting a recursiveIterator fixed.
  • doc errors fixed (thanks Andrew Sanchez)
  • bestClef() has been moved to the clef module where it belongs.
  • MusicXML sound tag now is placed properly (thanks Almog Cohen)
  • MIDI output from transposed scores now plays in concert pitch.
  • Breves are now acceptable as full measure rests.
Deprecations and deprecated elements removed
  • (this list does not contain changes to the alpha/ directory which can change at any time)
  • Note.ps, and Note.accidental, Note.pitchClass, Note.pitchClassString, Note.diatonicNoteNum, and Note.microtone are all deprecated. Use Note.pitch.ps, etc. instead.
  • Chord.normalForm is deprecated because it gave the wrong answer. use normalOrder instead; same with normalFormString
  • SpannerBundle.list is deprecated; use list(SpannerBundle) instead
  • with the advent of .style, el.color is deprecated, use el.style.color instead
  • Stream.stream() is deprecated -- now that the transition to iterators is done, there should be no need for this.
  • REMOVED stream.getOffsetByElement; use s.elementOffset(el) instead.
  • REMOVED stream.haveBeamsBeenMade; use stream.streamStatus.haveBeamsBeenMade
  • REMOVED stream.makeTupletBrackets(); use stream.makeNotation.makeTupletBrackets(s)
  • REMOVED stream.realizeOrnaments; use stream.makeNotation.realizeOrnaments(s)
  • REMOVED VirtualCorpus -- it may return at some point but with a lot more features.
  • nbconvert is no longer packaged with music21
  • .exe files are no longer generated -- they were rarely used and pip is a better choice for Windows users now.

As the last version of music21 to run on Python 2, version 4 will have a longer support period for security patches and major bug fixes that render large parts of the system unusable for multiple users. This LTS (Long-term support) will run until the clock on python 2 runs out. (Currently two more years and eight months).  After that time, Python 2 will no longer be supported by the Python Foundation, and thus, by music21 either.  We're looking forward to joining the glorious Python 3-only feature and finally get to use some great features to make development faster and more stable.  Music21 v. 5 will be released at about the same time Django v. 2 (Py3 only) and a year after IPython/Jupyter made their first Python 3 only release.  Matplotlib will soon follow.  Python 3 is the future of humanistic and scientific programming.
As always, we thank the community for great support.  We'd always love to hear how you use music21 via the Google Groups mailing list.  Music21 was made possible by grants from the Seaver Institute, the National Endowment for the Humanities, and the School of Humanities, Arts, and Social Sciences / Music and Theater Arts Section at MIT.

No comments:

Post a Comment