Tutorial Basics Notes Part 1: Visualizations

(version 2022_01_03)

Table of contents:

  1. Piano roll display
  2. Visualisation of dynamics
  3. Piano score
  4. Piano score with chord position symbols and roman numerals
  5. Tasks

In this tutorial we will discuss possibilities for

  1. the visualization of note files and
  2. the automated creation of a piano score and a harmonic designation of a sheet music.

Both areas are presented with music examples andcertain analytical questions followed by an interpretation of the respective results. Working through and following the tutorial should enable you to examine your own music examples (sheet music files) as well as to make comparisons between different pieces of music.

Every seesion with a Jupyter notebook using the Python library music21 starts with the import of music21 - using this simple command:

To load a file from the internet, you only have to insert the internet address of the file with the following syntax (red marked URL). The URL can be taken from the sheet music database, e.g. https://analyse.hfm-weimar.de/doku.php?id=en:mowo (mouse right-click on the link: "Copy link address"). We now load the first movement of the String Quartet No. 1, D major, KV 80, by Wolfgang Amadeus Mozart.

You can also listen to the piece in the browser – but only in a version with MIDI sounds and when Firefox or Chrome is used as the browser.

1. Piano roll display

What can be seen by this way of display?

To zoom in, you can either select individual sections and bars (see 2.2), or you can activate the MatPlotlib add-on module, which opens a popup window.

Select the magnifying glass symbol in the pop-up window. If you now select a section with the mouse, the section will be enlarged. The section can then be moved using the cross symbol.

Note: Piano rolls can also be generated in the Sonic Visualiser. There, the corresponding note files can be listened to simultaneously while the piano roll runs from right to left. See: https://analyse.hfm-weimar.de/doku.php?id=sv-pianoroll.

2. Visualization of dynamics

If dynamic are marked in the score file (pp, p, mf, f, ff, etc.), they can be integrated into a visual representation of the parts using the following code. Since this is not the case in the Mozart String Quartet, we load the Ballade in B minor Franz Liszt for this purpose:

This representation allows you to follow the dynamics of the ballad quite nicely, including rests. Since the dynamic symbols are linked to the staff of the right hand, but refer to the entire sheet music, the left hand is only displayed as a vertical bar. By adding the command '%matplotlib' the graphic can be opened externally

For use in other computer applications (Word, Powerpoint) the graphics (as png file) can of course be exported:

3. Piano score

With the Chordify command you can easily create a piano score. Now, we come back to Mozart’s string quartet.

Sometimes it is clearer to distribute the chords over two systems. For this, however, the voice distribution for the upper and lower system must be defined manually.

4. Piano score with chord position symbols and roman numerals

Music21 offers a possibility to provide a piano reduction with the numbering of the chord position. However, not all voices are taken into account. Nevertheless, this simplified display can be helpful for a harmonic analysis.

Additionally, music21 offers the possibility of providing a note file with a step numbering. However, the sheet music is only evaluated in a very superficial way, a profound harmonic analysis is not performed. Nevertheless, such a numbering can sometimes be helpful - as a first step towards a real harmonic analysis.

ATTENTION: Step numbering is always based on the root key you specify with the key.Key(' ') command, e.g. 'key.Key('Dm') or 'key.Key('D') for D minor or D major respectively. Modulations and other harmonic movements are not taken into account.

NOTE: Unfortunately, only the piano score in one system ('pianoscore') can be displayed - not the one in two systems ('pianoscore_neu').

The chord position view (see above) can of course also be combined with the step name. This view is easier to read:

Finally, the somewhat more complex piano reduction of a Haydn symphony:

5. Tasks

Please, load sheet music files of your own choice from the note archive (https://analyse.hfm-weimar.de/doku.php?id=komponisten). Use these files to test the visualization opportunities presented in this tutorial.