Installing and Testing a Python Environment

Authors: Meinard Müller, Frank Zalkow

[Mueller2015] Meinard Müller. Fundamentals of Music Processing. Springer Verlag, 2015.


Install Python 3.6 Miniconda ( with default settings. Then open an Anaconda-aware command line interface (e.g. Anaconda Command Prompt in Windows, standard Terminal in Linux/OS X).

Step into the directory containing the provided files environment.yml and install.ipynb and create a Python environment (named MIRCourse) for this course. You may confirm on demand. Also note it could take a awhile.

cd MIRCourse/
conda env create -f environment.yml

If you are on Windows, activate your environment with the following command:

activate MIRCourse

If you are on Linux or OS X, activate your environment with the collowing command:

source activate MIRCourse

Now run the following command to start Jupyter.

jupyter notebook

Your default browser should open and show the current directory. If it does not, open your browser and go to http://localhost:8888. There you can open a notebook by clicking on its file name.


Your browser should display the same file you viewed as an HTML file before. However, this time it is an interactive Jupyter notebook. If everything is installed correctly, you should be able to execute the following cells. For executing a cell, first click on it and then click this button in the menue above: . As a shortcut for executing a cell one may also use SHIFT+ENTER (⇧+⏎). (In some circumstances it can take a while if matplotlib is used for the first time.)

In [ ]:
import numpy as np
from scipy import signal
from matplotlib import pyplot as plt
from IPython.display import Audio
%matplotlib inline

fs = 4000
t = np.linspace(0, 1, fs + 1)

Play Audio:

In [ ]:
chirp = signal.chirp(t, 220, 0.8, 440)
Audio(chirp, rate=fs)

Display the spectogram:

In [ ]:
winsize = 256
spec, freqs, t, img = plt.specgram(chirp, Fs=fs, NFFT=winsize, noverlap=winsize//2, mode='magnitude', scale='dB')
plt.ylim([0, 660])
plt.xlabel('Time (seconds)')
plt.ylabel('Frequency (Hertz)')

If everything worked correctly, you got a player for audio playback and you see an image of the spectogram.

Acknowledgment: The International Audio Laboratories Erlangen are a joint institution of the Friedrich-Alexander-Universität Erlangen-Nürnberg (FAU) and Fraunhofer Institute for Integrated Circuits IIS.