Click here to send us your inquires or call (852) 36130518

Tuesday, May 08, 2007

Poor Man's Spectrum Analyzer

Spectrum Analysers are too damn expensive for me, but they are handy for troubleshooting signals. I have found a low tech good-enough-until-further-notice spectral analyser solution for tight band-limited signals: the audio input to some disused linux box!

First, go to and get your free copy of baudline. Connect a microphone to the audio jack and you're in business! Start talking and notice the spectral difference between consonants and vowels (consonants have wideband high frequency content). I use it for visual feedback on harmonics on practicing khoomei. (see screenshot below) Note that the frequency snapshot is selected by the white line. The fundamental band of my khoomei attempt starts around 2kHz, and the fifth harmonic is selected somewhere around 9.6kHz (I know it's the fifth because I saw the 2nd through 4th a little earlier). I need a lot more work on harmonic stability!

While watching the spectral content of your voice with baudline is a lot of fun, your voice has limited use in signal troubleshooting/analysis. I'll show you some other ways to use it using the microphone as an accoustically coupled "probe".

On the workbench I keep a radio playing. I like listening to music while I putter around work hard in the garage. The microphone and baudline easily picked up the roughly 6-7kHz audio broadcast from the radio speakers, but I also wanted to look at the spectrum of the audio signal coming out of my old black and white television, simultaneously. Since my spectral analyser was running on an accoustic link (the microphone), I would normally have to turn off the radio in order to get a cleanly represented television audio spectrum. Normally, that is, if you didn't happen to have a function generator with modulation inputs laying around, too. I plugged a jack from the TV headphone out into the function generator and AM modulated it to 12.5kHz, which I used to drive a small orphaned headphone speaker. The sound from it also filled the air, but with a different bandwidth at different frequecies. In the spectrum below you can see the lowband radio (1 to 7kHz) in the upper left (then they had a dead moment before commercial) and the higher band television audio signal (echoed on each side of the carrier at ~12.5kHz), with lots of empty space between them.

In case you hadn't noticed yet, holy crap look closely at that crazy looking modulated spectrum! It almost looks like there is some Mayan or Aztec-like image encoded into the spectrum, just like in Aphex Twin's own face that he inserted into Windowlicker.

The audio port is digitally sampling at only 48kHz, so its maximum bandwidth is less than 22kHz, the Nyquist Limit. However, the important word is bandwidth, not frequency; The low end of the band does not have to be 0Hz. With a little mathematical magic from baudline, you can take your band-limited signal within a 48kHz window and downsample to a smaller arbitrary frequency window getting increased spectral resolution in the band. In the photo below, I've zoomed in from the range of 0 to ~22kHz. The window now shows 11.8 to 13.2kHz only, at much higher frequency resolution (1.4kHz window). That is the (allegedly) 12.5kHz carrier right in the middle, and now not all the sideband information can fit into this scale.

When I was young and playing with fractals (specifically, the Mandelbrot Set), I could zoom in on the images forever and ever, always wanting to see what the next level of magnification held. So too, it seems, with spectral analyes. I took the downsampling up a notch and got viewing in tight between 12.465 and 12.510kHz (45Hz bandwidth!)

Unfortunately to get this level of resolution, the signal gets averaged over a macroscopic amount of time, and all the signals look blurred together. You can't see any transients. However, you can see that the carrier tone appears to be centred a lot closer to 12490.63kHz than 12.5kHz. I'm not complaining, and I believe that error is less than the error in calibration of the 48kHz sampling rate, anyway.

I love using baudline for looking at real time spectrums. If you had a signal that was sufficiently band-limited (less than 22kHz), you could use a function generator (with modulation input) to demodulate a signal from a much higher frequency into something reproduceable over the accoustic link to the microphone input and still get a reasonable, measurable spectrum. (Don't forget to turn off the radio, too! ;-) Sure, you could just hook up electrically from the function generator into the microphone (or line-in) input if you watch the levels, but where's the fun in that?

Burton MacKenZie


CoDebris said...

Thanks for a real nice site. I have written a spectral analysis program, Spectre, that is much more precise than Fast Fourier Transforms provide. Based on Michael Korenberg's Fast Orthogonal Search, the program is available for download at CoDebris has been awarded grants from NIH for human EEG interpretation using Spectre, and it was purchased by NASA WAllops Island for rocket engine vibration studies. I'm interested in getting Spectre into the hands of people who need the precision and flexibilty Spectre offers, with over a hundred time series analysis tools.

-- Gene Zawadzki,