Using the Audacity Spectrum Analyzer

Stephen Wise is your guide to home recording.

Audacity® supplies a handy tool for analyzing sounds called a Spectrum Analyzer. What the Spectrum Analyzer does is simple, but how it does it is not. In fact, enough scholarly papers have been written on the subject to fill a small town library.

In the previous post, I discussed the use of equalization. Sometimes, applying equalization doesn’t have the desired effect or seems to have no effect at all. Often, the problem is that you are trying to act on something that isn’t there or, at least, is not where you thought that it was.

When you look at a track in Audacity®, you are seeing a time domain representation of a sound – that is, the amplitude of the sound over a period of time. Through the use of a mathematical process known as Fast Fourier Transform, the time domain can be converted into the frequency domain. The useful thing about the frequency domain is that it lets you see a representation of the individual frequency components that make up a sound. Now you know where to place your filters!

If you are looking to replicate a certain sound, it can be useful to compare their individual spectra, applying filters or adding components until you have a match. The Spectrum Analyzer can also help you locate extraneous sounds for removal.

In Figure 1, I have taken the spectrum of a “sawtooth” wave created by the Audacity® “Generate” function. A sawtooth is one of the “geometric” waveshapes common to the original analog synthesizers. It’s a bright, buzzy sound and has the characteristic spectrum shown. All of the partials are present out to infinity and the levels of the partials decrease with increasing frequency.

By contrast, Figure 2 is a heavily low-pass-filtered square wave, another common analog synthesizer tone. You can see by the spectrum that the partials are lower in amplitude and that the even numbered ones are attenuated. A spectrum such as this one belongs to a bright but hollow sounding flute.

The controls on the Spectrum Analyzer no doubt seem cryptic. The controls are there because spectrum analysis is somewhat imprecise math. How you accomplish the Fast Fourier Transform (FFT) depends on what you want to see and what your source material is. The first box selects “Spectrum” along with some other functions for which I have yet to find a use.

To the right of that is drop-down list of numbers, each double the number above. This number is the number of sample points that will be used in the analysis. More points gives you a better picture but, you also get more averaging. More points is great for a steady tone such as an organ, but useless for something such as a drum hit.

Since a drum hit varies tremendously over time, you want to analyze small pieces of the whole and you can’t do that with a large number of sample points. You could, however, re-sample the drum to a much higher sample rate first.

The lower left window is perhaps the most cryptic. Since you are chopping out a chunk of sound to analyze, the actual sample points included in the chunk are somewhat arbitrary. If you use a “Rectangular” window, then you are just analyzing the raw, chopped out chunk. The abrupt “edges” on this chunk cause a lot of errors, so mathematicians have devised means to minimize the error.

Not surprisingly, most of these “window” functions have been named after mathematicians. If you really want to know the hows and whys of these window functions, there are plenty of papers on the web. My advice is to use what works best for you. Sometimes, the rectangle is best. Of the windows available in Audacity®, I prefer the “Hanning” (actually Hann) window as it generally gives me the most useful result.

The final window gives you a choice of linear or log scale. Always use log scales for audio. Log handles the wide ranges a lot better. You can get precise numbers for amplitude and frequency by moving the mouse over the graph. If you do the “mouse over” with the different window functions, you will see how the results vary from one function to the next. Note that in the case of amplitude (dB), it is the relative amplitude that is important, not the actual amplitude.

The Spectrum Analyzer is probably more useful for music synthesis. It is quite invaluable for creating electronic instrument sounds, but it also has uses in creating a clear audio mix. When mixing many instruments, some of the instruments can become “lost in the mix.”

You can often “find” these instruments by determining which other tracks are occupying the same frequency space and filtering those tracks to create a “hole” for the lost instrument to fit into. The ear/brain happily fills in these holes and also hears the formerly lost instrument. This trick works well with the snare drum, allowing you to keep the level of this drum high without its beats obliterating everything else. Filter the snare so that comes through the holes where the other instruments are not.

Stephen Wise has been designing electronic musical instruments since 1975. Steve specializes in realistic recreations of traditional instruments. He became interested in the field after hearing Walter/Wendy Carlos’ “Switched On Bach” and upon being introduced to the Allen Digital Computer Organ, the world’s first all digital musical instrument. Steve is currently designing instruments for Schulmerich Bells, maker of handbells, electronic carillons, and the breakout MelodyWave® instrument.

7 comments

1 Howard Collingsworth
Posted 05/10/10 at 3:39 pm

Hi Stephen, thanks for your informative articles. I’m fairly new to Audacity and your articles are very helpful. Again, thanks . . .
Howard

2 Stephen Wise
Posted 05/12/10 at 8:16 am

Thanks, Howard! Whenever one publishes something on-line, one wonders if more than two or three people are reading it.

3 Leah R. Garnett
Posted 05/13/10 at 12:42 pm

Not a chance….Google Analytics says you get thousands of page views each month! Your readers are sometimes too busy implementing your great advice to comment…

4 kat alaniz
Posted 12/14/10 at 9:01 am

thank you for your time, i am only starting to use the basic audacity program, a newbie ! i find your articals helpful. thank you !

5 Stephen Wise
Posted 12/15/10 at 8:32 am

kat,
I’m glad that you found something of use to you! The one central theme of this blog is “low cost.” Other than that, it’s whatever pops into my head. Low cost means that you can try out a lot of things with little risk. That’s fun! Check back, because I will be blogging at many different skill levels.

6 Daria
Posted 05/17/11 at 8:59 am

Hi Stephen,

I wonder if you could help me a bit with the use of the spectrum analyzer. You mentioned that the relative amplitude (dB) is what counts, but are there any means to convert the peak amplitude value seen in the spectrogram into actual desibels used in measuring auditive sound pressure? If I have understood right, this would require the baseline level (0 dB) to be known in relation to the spectrum values. How and where can I obtain this baseline to be able to compare the sound pressure (loudness) of different recordings with one another?

Your answer would be most helpful!

7 Stephen Wise
Posted 05/17/11 at 10:52 am

Daria, You will have to calibrate your set up each time that you use it. To calibrate, you will have to attach something to your PC input that generates a tone at a level that you will use to represent “0dB”. Then you will have to adjust levels on your sound card and in Audacity so that the tone displays as “0db” on the spectrum analyzer. A more satisfactory solution would be to obtain a specialized instrument for this purpose. There are probably a lot of reasonably priced used sound level meters floating around. You will probably want to read up on standards also.

Leave a Comment

(to appear with comment)

(will not be displayed)

(if any)

*Required field