Viewing Notation

This brief tutorial module explains how to view notation in the music21 environment.

After you install music21, you must configure it for your system. As part of this process, you must install or specify a software program to display notation in the MusicXML format. The instructions for this configuration process are included as part of the installation instructions for different systems at the top of this page.

Free options for viewing MusicXML files include Finale Notepad and MuseScore. MusicXML is an emerging standard for encoding digital sheet music.

You can check whether you have everything set up properly by entering the following code line by line.

First, load the music21 environment:

from music21 import *

Next, load an example file from the music21 corpus:

example = corpus.parse('johnson_j_r/lift_every_voice.mxl')

And use the .show() function to display the notation:

example.show()

If music21 is configured properly on your system, the notation software you chose should automatically begin running, and the notation for “Lift Every Voice and Sing” composed by J. Rosamond Johnson with lyrics by James Weldon Johnson, should appear after a moment.

In some cases, the software may present you with an “import” dialog box. Usually you can leave the default settings in place and simply click OK.

It may take a few seconds for the software and file to load. However, if the notation does not appear, return to the configuration process and specify your software of choice. Or consider downloading and installing Finale Notepad and MuseScore, and then run the configuration assistant again.

For more on MusicXML files and software, check this page.