Music21 and Dorico testing on Mac

Up to this point, the open source Music21 musicology software from M.I.T. has supported Finale, Sibelius, and MuseScore (but not Dorico) for displaying its output as MusicXML or MIDI.

It works fine with Dorico, but it’s now a multi-step as you can’t say myResult.show() in a script and have it come up in Dorico.

So… I made a minor change to the Music21 code. Works great on Windows, but I can’t test my Mac related changes. Before I submit the change, is there a Musci21 / Dorico user on Mac who is willing to give me a hand? It involved copying one file configure.py into a directory after making a copy of the original file.

2 Likes

I’d be interested to give it a try!

Thank you Ben… okay…

If you don’t have Python 3.x installed, the instructions at Python.org are better than any I could write.

If you don’t have Music21 installed, then (if python is installed) go to a command prompt and type “pip install music21”. And again, there are instructions at this link if you need them: music21: a Toolkit for Computer-Aided Musicology

The modified file configure.py is attached below. Once you have both python and music21; In your python installation, there should now be a ./Lib/site-packages/music21 directory. Please unzip the file and place it there.

configure.py.zip (14.2 KB)

I assume you are familiar with Python and Music21, but just go to a command prompt and type “Python” Then type these two lines

import music21
music21.configure.run()

What should happen is that it takes a few minutes to configure Music21, and in the process it should ask you if you want to use Dorico as a music XML Reader. Once you say yes, something like the following command will verify that the Dorico integration is set up properly:

bwv295 = music21.corpus.parse(‘bach/bwv295’)
bwv295.show()

… should bring it up in Dorico.

And again - thank you!


If you are regular user of music21, or if you get interested, there is another file that I created that you can have if you want . Its called ChordDeck, and it basically lets you type in a complex chord progression quickly to display as notes in Dorico. It goes

from ChordDeck import *

chords = fromShorthand(“Em7 Bb7(b5) C/G F#Maj9”)
chords.show()

or whatever. At the moment it will create the notes for each chord as whole notes. The C/G will create an inversion for you, as will “IVc” where the “c” indicates the second inversion. For roman numerals, you can specify the key as in:

chords = fromShorthand(“I IV V ii V bVII”, key=“Eb”)
chords .show()

I extended the nomenclature a bit to do a little more that I wanted. The underscore on “C_9” for example will give you a rootless C9. and “C^9” Will give you a C9 “Cup” inversion of any extended chord that Jazz pianists apparently like to play that is a little different than either first or second inversion.

If you read python, you will see there are various methods in there for creating the bones of practice or training worksheets that treat the various possible chords as if they were cards in a flashcard deck - intended mostly for a person who wants to have some ability at Jazz comping on the piano… majorDeck() returns a random selection of major Chords, and you can guess what sixNineDeck() or whatever does. The really challenging one is deck() which gets you a little bit of whatever to practice.

ChordDeck.zip (5.1 KB)

1 Like

Hmm.

name ‘comparisonDorico’ is not defined in line 1322.

Ah: got it. The function def is mis-spelt at 1314.

All works well now.

Thank you sir!

… Forgot that I changed the name in ChordDeck to something shorter:

chords = explode(“I IV V”)

… and I added the option to change the note duration like

chords = explode(“I IV V”, dur = duration.Duration(“quarter”))

There is also a method if you just what to hear the progression first without bringing it up in Dorico or anything

audition(“I ii V”)

2 Likes

This looks fantastic. Very keen to give it a go. Thanks!

EDIT: Are you 'EvilArchitect" on github?? I see you’ve already submitted your fix.

1 Like

Sure, I opened an issue there and Mr. Cuthbert is waiting for it. I just wanted to test it on Mac, and it was a good thing I did - appreciate you testing and finding the typo.

Yeah, an old nickname. Because I always have an evil plan, “to take over the entire tristate area!!!” )

4 Likes

Seems fair.

Oh, one other thing: I can’t install music21 on my M1 Mac: it may be due to not all the dependency libraries being Apple Silicon native.

Thanks for setting this up! I just tried it out on my Windows 11 installation, and my problem is that my python environment is running in WSL. Because of that, the script thinks I’m on nix and assumes that musescore is the only option, and just skips over choosing the xmlreader. After futzing with the script for a while, I just put in a symlimk from /usr/bin/mscore3 to Dorico, and now that works! Not sure what else will be broken, but thanks for the help getting started.

I run all my python stuff quite happily on Windows using pycharm. So no need to use WSL.

That said, I find MuseScore loads so much faster than Dorico, that I prefer it as an xml viewer for music21 (Also MuseScore is more forgiving of xml errors than Dorico)

Possibly a stupid Mac question:

The modified file configure.py is attached below. Once you have both python and music21; In your python installation, there should now be a ./Lib/site-packages/music21 directory. Please unzip the file and place it there.

Running the latest version of Mac OSX, I cannot find this ./Lib/site-packages/music21 directory. There are lots of these directories in Previously Relocated Items, but I can’t find the current one anywhere.

Is there a way to replace the configure.py file from the Terminal? Thanks for any advice!

You can run this in terminal:

python3 -m site

Should give you the location of the site-packages directory.

1 Like

Fantastic - I’m up and running, and thanks also to Ben for catching the misspelled word in line 1314!