# Piano Roll Representations

Following Section 1.2.1 of [Müller, FMP, Springer 2015], we look in this notebook at a symbolic music representation often referred to piano roll representation.

## Player Pianos¶

In the late 19th and early 20th century, self-playing pianos, player pianos became quite popular. Player pianos contained pneumatic mechanisms to automatically operate the key and pedal movements according to the instructions specified by a prestored piano-roll medium. A piano roll is a continuous roll of paper with perforations (holes) punched into it. The perforations represent note control data. The roll moves over a reading system known as a tracker bar and the playing cycle for each musical note is triggered when a perforation crosses the bar and is read. Rolls for player pianos were generally made from recorded performances of musicians. This way, the playing of many famous pianists and composers including Gustav Mahler, Edvard Grieg, Scott Joplin, or George Gershwin is preserved on piano rolls.

Here is a player piano in action playing "The Entertainer":

In [1]:
import IPython.display as ipd
import os


## Piano-Roll Representation¶

Motivated by traditional piano rolls, a piano-roll representation is understood to be a geometric visualization of the note information as specified by a piano roll. The horizontal axis of this two-dimensional representation encodes time, whereas the vertical axis encodes pitch. Every note is described by an axis-parallel rectangle coding three parameters. The first parameter is the onset time, given by the leftmost horizontal coordinate of the rectangle, and the second is the pitch, given by the lower vertical coordinate of the rectangle. Finally, the third parameter is the duration of the note, encoded by the width of the rectangle.

The following figure shows a sheet music representation and as well as piano-roll representation of the beginning of Fugue BWV 846 in C major by Johann Sebastian Bach. The four occurrences of the theme are highlighted.

The following video shows an animated piano-roll representation for Bach's Fugue BWV 578 in G minor performed by Stephen Malinowski. The different voices of the fuge are shown in different colors.

In [2]:
ipd.display(ipd.YouTubeVideo('ddbxFi3-UO4', start=1))


While they are a considerable simplification of what is notated in sheet music, piano-roll representations visually describe the most important attributes of musical notes in an easy-to-understand way. Therefore, piano-roll representations are often used when describing and talking about symbolic music. Also, piano rolls can be seen as a kind of mid-level representation on the basis of which semantic relations can be established across various manifestations of music.

Acknowledgment: This notebook was created by Meinard Müller.