Code
To follow this guide you'll want to download the following code and unzip it somewhere convenient:- spectrum, a folder with a Teensyduino sketch for the spectrum analyzer.
- toneinput, a folder with a Teensyduino sketch for tone detection.
- Spectrogram.py, a python script to display a real-time spectrogram from the hardware.
- SpectrogramUI.py, the user interface code used by Spectrogram.py.
- SpectrogramDevice.py, an abstract class for extending the spectrogram to other devices in the future.
- SerialPortDevice.py, an implementation of SpectrogramDevice.py to interface with the hardware over a serial port.
Dependencies
To run the sketches you'll want to make sure you have Teensyduino installed. Follow these instructions to download and install Teensyduino.To run the Spectrogram python script you'll need python 2.7 and a few libraries installed:
- matplotlib, a library for plotting data.
- NumPy, a library for numeric computing.
- PySide, a python binding to the Qt user interface library.
- pySerial, a library for serial code IO.
Assuming you installed a distribution such as Anaconda, you'll want to install the pySerial library (which is not included in the distribution) by executing the following command (be sure the anaconda /bin directory is in your path before executing):
pip install pyserial
Continue on to learn about the applying the Fourier transform to build an audio spectrum analyzer.