Installing and Testing a Python Environment

Installing

Install Python 3.6 Miniconda (https://conda.io/miniconda.html) with default settings. Then open an Anaconda-aware command line interface (e.g. Anaconda Command Prompt in Windows, standard Terminal in Linux/OS X) and create an environment called MusicProcessing with some packages. You may confirm on demand. Also note it could take a awhile.

conda create --name MusicProcessing numpy scipy matplotlib jupyter

When you are on Windows, activate your environment with the collowing command:

activate MusicProcessing

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

source activate MusicProcessing

Now step into the directory where you stored the notebooks and 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 the first notebook by clicking on its file name.

Testing

Your browser should display the same file you viewed as an HTML file before. Howeever, 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 = 512
spec, freqs, t, img = plt.specgram(chirp, Fs=fs, NFFT=winsize, noverlap=winsize//2, mode='magnitude', scale='dB')
plt.colorbar()

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