# Plot Spectrum

From Audacity Development Manual

Plot Spectrum takes the selected audio (which is a set of sound pressure values at points in time) and converts it to a graph of frequencies (the horizontal scale in Hz) against amplitudes (the vertical scale in dB).

  Accessed by: Analyze > Plot Spectrum...

Plots are made using a mathematical algorithm known as a Fast Fourier Transform or FFT. This gives a value for each narrow band of frequencies that represents how much of those frequencies is present. All the values are then interpolated to create the graph.

Plot Spectrum take the audio in blocks of 'Size' samples, does the FFT, and averages all the blocks together.

## Algorithm

Determines what type of processing is done on the audio data.

- Spectrum: (default) - Plots the FFT of the data as described above. The amplitudes are normalized such that a 0 dB sine (pure tone) will be (approximately) 0 dB on the graph.
- Autocorrelation: These options measure to what extent the sound repeats itself. This is done by taking two copies of the audio, and moving one forward by one sample. The two copies are then multiplied together, and all the values added up. This is repeated for two samples difference and so on, up to the number of samples in the size option. This gives a small result if the waveform is random (for example, noise) and a large result if it is repetitive (like a musical note). By looking at the peaks in the plot, the key frequencies present can be determined even if there is a lot of noise.
- Cepstrum: The cepstrum of an audio signal is related to the spectrum, but presents the rate of change in the different spectrum bands. It's particularly useful for properties of vocal tracks and is used, for example, in software to identify speakers by their voice characteristics.

## Size

This controls how many frequency divisions are used for the spectrum, or how many samples are used for autocorrelation. In Spectrum, a larger size gives more accurate frequency resolution (narrow bands), but averages the result over a longer period of time (because more samples are needed for the calculation). In Autocorrelation, a larger size looks for repeating patterns over a larger range of time offsets, and so will detect lower frequency patterns. With either algorithm, Audacity will show a warning if the selected region is too short for the chosen size.

There is an audio version of the Uncertainty Principle that says "Frequency_Resolution*Time_Resolution = 2." Size lets you choose the FFT size which is the number of consecutive audio samples to be analyzed. If you choose 1024 samples, you will get 512 frequency bins covering the frequency range up to half the sampling frequency. Most projects use 44,100 Hz sampling frequency. Thus, in this example, Time_Resolution = 1024/44.1 = 23.2 milliseconds and the frequency resolution is 44,100/2/512 = 43 Hz.

## Function

Function offers choices like Rectangular, Hann, Hamming and others. We suggest you use the default Hann for most situations. The fundamental principle at work here is that the way we observe our data changes what we see. The "true spectrum" of your project would be computed over the entire project and would provide very detailed frequency resolution but essentially no time resolution at all. In other words, this "true spectrum" would offer an average frequency distribution over the entire project. If we select a short interval of audio, the short-time spectrum has frequency resolution limited by the observation window time AND the result is affected by the spectrum of the window itself. For general audio analysis, the Rectangular window is least desirable, and the other options offer slightly different effects.

- Currently, only the first 10485760 samples (237.8 seconds at 44,100 Hz sample rate) of selected audio can be analyzed.
- The spectrum analysis shows the sum of all selected channels, so shows the sum of left and right channels in a stereo track. If there are two selected channels with identical audio, the same peak will be 6 dB higher than if one channel was selected.

## Axis

When using the Spectrum, the frequencies can be displayed on a logarithmic scale (default)or a linear scale. The default log scale gives greater display width to low and mid-range frequencies with "mid range" frequencies occurring close to the middle of the graph. Linear view (which gives equal width to each "Hz" increment on the scale), can be useful to show high harmonics (a component frequency of the sound that is a whole number multiple of the fundamental frequency) or other very high frequency content.

## Zooming

To the right of the spectrum are two sliders to control zooming of the spectrum plot:

- The zoom slider on the far right with the magnifying glass icons. Move this up to increase the vertical magnification of the plotted spectrum and down again to reduce it.
- The scroll bar, to the left of the zoom slider. At default normal zoom this fills the slider and is inoperable but as you increase the vertical magnification the scrollbar shrinks and can be moved up and down to show different parts of the magnified spectrum plot.

## Buttons

- Export... Exports the spectrum to a text file. You could open this text file in another application for further analysis. Note that if you export again to the same file, the file will be overwritten with the new data.
- Replot Allows you to replot the spectrum when the selection changes.
- Close Closes the Frequency Analysis window and saves its current settings. If you then open a new project and open an analysis window in that project, the settings saved by the last closed analysis window will be used.
- Links to this "Plot Spectrum" page.

If you close the analysis window in any other way (such as the operating system's window close button or by using File > Close), the analysis settings are discarded when you close the project that was using the analysis window. Using other than the Audacity Close button may be useful if you are examining audio with settings you do not normally use. The next analysis window you open in a new project will then use your normal saved settings.

### Grids (checkbox)

Turns the measurement grids on and off.

## Links

|< Index of Effects, Generators and Analyzers

|< Analyze Menu