ECE497 Project Spectrum Analyzer

From eLinux.org
Jump to: navigation, search



Team members: Jay Dial and Michael Fuson

Executive Summary

We set out to create a spectrum analyzer that could run on the Beagleboard. We wanted it to be able to perform a fast Fourier transform (FFT) on live audio and output both the audio and the FFT data.

We were able use a Gstreamer Good plugin to perform the FFT on an audio file. We then managed to get Gstreamer to read in audio and output it using Alsa and get the FFT data plotted on a graph using Python. As an additional feature, useres are able to input audio from a PSeye and see changes in the spectrum plot live.

We originally wanted have the data plotted using gnuplot. Gnuplot allows for more intuitive user interfaces and was simpler to use. But due to software complications on the Beagleboard, we were forced to use a simpler Python library. These issues limited what feature we were able to implement over the course of the project.

Overall, we feel that we managed to implement a good deal of feature given the time and software limitations of the project. Given more time, we would have been able to put the finishing touches on this project that would take it to the next level.

Instillation Instructions

All steps can be performed on the beagle.

# git clone git@github.com:fusonmb/Spectrum-Analyzer.git
  • Install python tkinter on the beagle
# opkg install python-tkinter
  • Copy zellegraphics.py to /usr/lib/python2.6/site-packages
# cd Spectrum-Analyzer
# cp zellegraphics.py /usr/lib/python2.6/site-packages/
  • Compile Audioout.c to read in audio from in input jack or MicIn.c to read Audio from the Play Station eye.
# gcc -Wall $(pkg-config --cflags --libs gstreamer-0.10) Audioout.c -o Audioout
# gcc -Wall $(pkg-config --cflags --libs gstreamer-0.10) MicIn.c -o MicIn


Hardware needed

  • Male to Male Stereo Cable
  • Speakers or Headphones
  • Play station eye


User Instructions

First you must kill pulseaudio with the set shell script. Then the GStreamer application's output must be piped into the python program to be displayed.

# cd ~/Spectrum-Analyzer
# ./set
# ./Audioout | python SpecPlot.py

Ctrl^C to quit the program

Using the Audioout program grabs the signal coming into the input jack.
Using the MicIn program grabs the signal coming in from PSeye using the USB port.

Highlights

Our project is able to read in live audio and output the FFT of the signal and the audio live. These calculations are done in real-time and plotted for the user to see. We also have the audio being output from the Beagleboard after were perform the FFT. The plot refreshes in near real-time and has cursors for the user to take data readings with. Audio can be read in from a PSeye instead of the line-in port of the Beagleboard.


A breakdown of implemented features are as follows:

1. Perform FFT on live audio
2. Plot the data in terms of dB in the frequency domain
3. Live audio output
4. Read input from the PSeye
5. Cursors

Theory of Operation

Audio is being read in using an Alsa source at the default sample rate of 44.1 KHz and being output using an Alsa source inside Gstreamer. Also inside Gstreamer, we are performing the FFT on the audio and passing the data outside of Gstreamer to a Python script. The Python script plots the data using the ZelleGraphics library and runs in near real-time. The FFT and output of audio occurs in parallel and one doesn't affect the other. The FFT length is twice the number of bands minus two. The variable to set the number of bands is in the Audioout.c program and is easily modified. For our examples and from whats in the repository the length of the FFT is 198 data points.

Pipeline layout for Spectrum Analyzer Project

Work Breakdown

Mike handled all the GStreamer elements.

  • reading Audio in, taking the Spectrum, Writing Audio out
  • tested and got things running on the beagle


Jay handled all the plotting elements

  • wrote the python program to plot
  • wrote a perl program to plot using gnuplot

Unfinished Finished Tasks
Make gnuplot work properly - Jay
Allow for input parameters to set the spectrum resolution and bandwidth - Mike


These tasks will not be finished this quarter.

Conclusions

Like most things in this class, our project seemed pretty straight forward at the start but quickly became more complicated by hurtle after hurtle. We had hopped to get the basic functionality done earlier so that we could focus on additional features but two weeks was not a sufficient amount of time.

There are many addition we wish we could have made. First would be to get to plotting done much faster. As it stands now if we were to make the process even faster by using the DSP processor the speed increase would not be noticeable since the ploting is so slow. That being said a key addition to this process would be to have the DSP processor do the FFT. A GUI interface to adjust the window of the spectrum analyzer in real time would also be a welcome addition. The ultimate addition to this project would to make the whole program a Gstreamer plug in.