Plot Spectrum reports wrong peak Hz

Help for Audacity on Windows.
Forum rules
ImageThis forum is for Audacity on Windows.
Please state which version of Windows you are using,
and the exact three-section version number of Audacity from "Help menu > About Audacity".


Audacity 1.2.x and 1.3.x are obsolete and no longer supported. If you still have those versions, please upgrade at https://www.audacityteam.org/download/.
The old forums for those versions are now closed, but you can still read the archives of the 1.2.x and 1.3.x forums.
Post Reply
RichR
Posts: 14
Joined: Thu Aug 05, 2010 7:31 pm
Operating System: Please select

Plot Spectrum reports wrong peak Hz

Post by RichR » Fri Nov 15, 2019 5:20 pm

Using Audacity 2.3.2, I found a bug while attempting to clean up a recorded file. Plot Spectrum indicated a peak of 58 Hz. When I applied a narrow (50.0) Notch Filter at 58 Hz, it made no difference. Turns out the actual peak was at 60 Hz; after I applied the Notch Filter at 60 Hz, Plot Spectrum showed the noise was gone.

Reproducing the bug is very easy...

1. Open a New file (File > New)
2. Generate > Tone...
3. Waveform: Sine, Frequency (Hz): 60, Amplitude (0-1): 0.25, Duration: 1.000s, click OK
4. Analyze > Plot Spectrum...
5. In the Frequency Analysis window (Algorithm: Spectrum, Size: 8192, Function: Rectangular, Axis: Log & make it as large as possible to see detail), place the cursor at the exact peak of the plot. Note the Cursor: value indicates the peak is at 59 Hz, while the Peak: value says 58 Hz (A#1). (But you know you generated a 60 Hz tone.)

If you wish, experiment with the Notch Filter to further examine the problem.

steve
Site Admin
Posts: 81627
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Plot Spectrum reports wrong peak Hz

Post by steve » Fri Nov 15, 2019 5:38 pm

RichR wrote:
Fri Nov 15, 2019 5:20 pm
5. In the Frequency Analysis window (Algorithm: Spectrum, Size: 8192, Function: Rectangular, Axis: Log & make it as large as possible to see detail), place the cursor at the exact peak of the plot. Note the Cursor: value indicates the peak is at 59 Hz, while the Peak: value says 58 Hz (A#1). (But you know you generated a 60 Hz tone.)
As shown below, I'm seeing the peak reported as 61 Hz, but you are using a different window function (I'm using the default "Hann" window as you can see)

Screenshot_2019-11-15_17-30-55.png
Screenshot_2019-11-15_17-30-55.png (47.33 KiB) Viewed 266 times
Plot Spectrum uses FFT analysis, which gives an approximation of the frequency spectrum. A larger window size gives a closer approximation on frequency values:

Screenshot_2019-11-15_17-36-01_2.png
Screenshot_2019-11-15_17-36-01_2.png (46.49 KiB) Viewed 266 times

It's not a bug, it's a limitation of FFT analysis that the smaller the window, the less precise the approximation is.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

RichR
Posts: 14
Joined: Thu Aug 05, 2010 7:31 pm
Operating System: Please select

Re: Plot Spectrum reports wrong peak Hz

Post by RichR » Fri Nov 15, 2019 6:16 pm

steve wrote:
Fri Nov 15, 2019 5:38 pm
It's not a bug, it's a limitation of FFT analysis that the smaller the window, the less precise the approximation is.
Hmm... knowing nothing about FFT analysis, I had supposed the smaller window would result in a more precise approximation.

However, I found using the 32768 window gave the proper results, no matter what tone I chose for my tests.

Good to know.

Thanks!

steve
Site Admin
Posts: 81627
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Plot Spectrum reports wrong peak Hz

Post by steve » Fri Nov 15, 2019 6:54 pm

RichR wrote:
Fri Nov 15, 2019 6:16 pm
Hmm... knowing nothing about FFT analysis,
There is a bit of information about it, in not too technical language, here: https://manual.audacityteam.org/man/plot_spectrum.html
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Post Reply