PCP Teaser

Exercise: Music Representations

Prerequisites

To work on this exercise, you should first work through the Lecture on Music Representations.

This exercise will make heavy use of the Preparation Course Python (PCP) and the Fundamentals of Music Processing (FMP) notebooks. Thus, we require you to run the PCP notebook environment and the FMP notebook environment. Follow the links and set them up on your local machine.

Both PCP and FMP use Jupyter, so you can work on all assignments through your browser. You may optionally use an integrated development environment like PyCharm, which can be more convenient to use.

Finally, please take the opportunity to review your programming skills. Basic knowledge of Python is required for the remainder of this class. You should be confident in applying the concepts presented in units 1 to 5 of PCP.

Tasks

Throughout the exercise, we will make use of the PCP and FMP notebooks. Please, always feel encouraged to actively work through these notebooks, play around with different parameters, other input files etc.! That is the best way to learn.

Task: Musical Notes and Pitches

Go through the FMP Notebook on Musical Notes and Pitches and understand the meaning of the parameters (such as Fs, pitches,...). In particular:

  • Write a small function that generates a sonified D major scale.
  • More general, write a small function that accepts a pitch class as input and outputs a sonified major scale for the given pitch class.

Task: Pitches and Center Frequencies

Go through the FMP notebook on Frequency and Pitch and write the following functions:

  • A function that accepts a pitch as input and returns the corresponding frequency in a 12-tone equal tempered scale with reference pitch $p=69$ and reference tuning $440~\mathrm{Hz}$.
  • A function that accepts a pitch as well as parameters $p, d\in\mathbb{N}$ and $\omega\in\mathbb{R}_{>0}$ as input and returns the corresponding frequency in a $d$-tone equal tempered scale with reference pitch $p$ and tuning frequency $\omega$.

Task: Shepard Tones

Understand the concept of Shepard tones by going through the FMP Notebook on Chroma and Shepard Tones. Answer the following questions:

Task: Sonification

Understand how to sonify pitch-based representations by going through the corresponding part in the FMP notebook on Sonification. The notebook on the Harmonic Series may be useful to understand why we superimpose certain sinusoids in the sonification. Then,

  • Write a function that sonifies a D major scale using a sinusoidal model including harmonics.
  • Recalling the Shepard glissando, extend your function to make the sonification sound like it "rises indefinitely".

Optional Task: Bach's Neverending Canon

We will now employ the concepts you have learned to recreate the following YouTube video:

In [1]:
import IPython.display as ipd
ipd.display(ipd.YouTubeVideo('A41CITk85jk'))

Listen to the start and the end of the YouTube video. Even though the music seems to be "rising" constantly, the start and end match up perfectly!

The piece by Johann Sebastian Bach that is being played here ends one whole tone above the tone where it started. Therefore, after six repetitions, the music arrives at an octave above the tone where it started. In the YouTube video, shepard tones are additionally used to match the frequencies at the start and after six repetitions. This creates the impression of a "neverending canon".

  • You can find a CSV-representation of Bach's piece here. Using the FMP notebook on CSV representations, load the file and display a piano roll representation of the piece.
  • Sonify the piano roll representation using a sinusoidal model including harmonics.
  • Transpose the piece six times, each time one whole tone higher than before. Remember that a whole tone corresponds to two MIDI pitches. Paste the six iterations of the piece together, one after the other. Visualize the result as a piano roll and sonify it.
  • You should now have a version of the piece that ends one octave above where it started. Recalling the Shepard glissando, change your sonification so that the result "rises indefinitely".
  • Save your result as a .wav-file, open it in a music player application and turn on the loop feature ;)

Optional Task: Sonify your own MIDI

There are many resources on the web where you can download MIDI files, which encode symbolic music. See the FMP notebook on MIDI for more information on how to parse MIDI files. Find a MIDI of your favorite song and sonify it using the methods you have learned thus far.

Question & Answer Session

MPA footer