How change X-axis range in Spectrum Analysis Plot

Effects, Recipes, Interfacing with other software, etc.
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
Spriter1275
Posts: 20
Joined: Fri Apr 18, 2014 7:54 pm
Operating System: Please select

How change X-axis range in Spectrum Analysis Plot

Post by Spriter1275 » Thu Apr 24, 2014 5:50 pm

Hello,
I am analysing some noise from industrial equipment and have been asked by a noise expert to do the spectrum analysis with a linear scale on the x-axis such that harmonics are more easily recognisable. At the moment the range goes to 40,000Hz while I'm only interested in <500Hz. Is this possible to do ?!

Thanks.........Steve

kozikowski
Forum Staff
Posts: 68941
Joined: Thu Aug 02, 2007 5:57 pm
Operating System: macOS 10.13 High Sierra

Re: How change X-axis range in Spectrum Analysis Plot

Post by kozikowski » Thu Apr 24, 2014 6:14 pm

Zoom In to a spectrum analysis is a Feature Request.
The work-around, since the accuracy of the display goes up as the dragged size of the window goes up is to repeatedly drag the window larger and push it off the left of the screen as you go. Then reposition the window so the portion of interest is in screen center.

Koz

Trebor
Posts: 9852
Joined: Sat Dec 27, 2008 5:22 pm
Operating System: Windows 8 or 8.1

Re: How change X-axis range in Spectrum Analysis Plot

Post by Trebor » Thu Apr 24, 2014 11:10 pm

Using the log(arithmic) scale makes the lower frequencies more conspicuous ...
log-linear#.gif
log-linear#.gif (81.25 KiB) Viewed 3473 times

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

Re: How change X-axis range in Spectrum Analysis Plot

Post by steve » Fri Apr 25, 2014 4:51 pm

Note also that selecting a higher "Size" setting will show more detail in the low frequency range.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Spriter1275
Posts: 20
Joined: Fri Apr 18, 2014 7:54 pm
Operating System: Please select

Re: How change X-axis range in Spectrum Analysis Plot

Post by Spriter1275 » Fri Apr 25, 2014 7:34 pm

OK, thanks. Using Trebor's pictures it does look like the harmonics are easier to pick out with the linear plot which I think is what the acoustics guy suggested. I've just spent an hour downloading other software to try and achieve this with no success. Unfortunately I can't zoom in and get the definition between the frequencies I'm interested in with Audacity on the linear scale so guess I'm stuck with using the log scales which I daresay will be OK..........

Trebor
Posts: 9852
Joined: Sat Dec 27, 2008 5:22 pm
Operating System: Windows 8 or 8.1

Re: How change X-axis range in Spectrum Analysis Plot

Post by Trebor » Sat Apr 26, 2014 12:09 am

If you re-sample a copy of your audio by dividing its sample-rate by four,
that will effectively allow you to zoom-in on the lower frequencies on the spectrogram ...
down-sample by factor of 4.gif
44100Hz re-sampled to 11025Hz (1/4)
down-sample by factor of 4.gif (41.63 KiB) Viewed 3292 times
[click on this image to see it in its entirety].

NB: you'll have to click-on "replot" after resampling , (as the frequency analysis won't automatically update itself).
Last edited by Trebor on Sat May 03, 2014 4:12 pm, edited 1 time in total.

Spriter1275
Posts: 20
Joined: Fri Apr 18, 2014 7:54 pm
Operating System: Please select

Re: How change X-axis range in Spectrum Analysis Plot

Post by Spriter1275 » Sun Apr 27, 2014 9:37 pm

OK, thanks, re-sampling and trying to extend the window gives a better linear plot with a reduced x axis. Not great though but may be usable.......

Trebor
Posts: 9852
Joined: Sat Dec 27, 2008 5:22 pm
Operating System: Windows 8 or 8.1

Re: How change X-axis range in Spectrum Analysis Plot

Post by Trebor » Mon Apr 28, 2014 6:42 am

IIRC the spectrograms generated by the free program SoX allow you to specify a frequency window.

[ but SoX is not very user-friendly : is has a command line interface ]

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

Re: How change X-axis range in Spectrum Analysis Plot

Post by steve » Mon Apr 28, 2014 2:59 pm

Trebor wrote:IIRC the spectrograms generated by the free program SoX allow you to specify a frequency window.
SoX has nice spectrogram plotting feature.
SoX does not have an equivalent to Audacity's "Plot Spectrum", but it does have "stat" and "stats" effects that can output a wide range of statistical data.
SoX is documented here: http://sox.sourceforge.net/sox.html

The basic syntax for a spectrogram is:

Code: Select all

sox my.wav −n spectrogram
where "my.wav" is the file to be analyzed.

To plot a spectrum up to, say, 500 Hz with SoX:

Code: Select all

sox my.wav −n rate 1k spectrogram
The "rate 1k" parameters tell SoX to analyze with a sample rate of 1 kHz, which thus outputs a range up to 500 Hz (half the sample rate).

Here is an example output from the above command:
spectrogram.png
spectrogram.png (169.36 KiB) Viewed 3054 times
The same idea can be used with Audacity's Plot Spectrum. Here I have resampled a file to 1 kHz (using "Tracks > Resample")
500HzPlot.png
500HzPlot.png (42.29 KiB) Viewed 3054 times
Note that "Plot Spectrum" in Audacity can output the analysed data as a text file, which can then be imported into any suitable graph plotting application to create custom graphs.
http://manual.audacityteam.org/o/man/plot_spectrum.html
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Spriter1275
Posts: 20
Joined: Fri Apr 18, 2014 7:54 pm
Operating System: Please select

Re: How change X-axis range in Spectrum Analysis Plot

Post by Spriter1275 » Sun May 04, 2014 8:45 pm

OK, thanks.

I haven't managed to get SOX working in Windows 7 but the export function and then graphing in excel works really well although quite time consuming. Plus the resampling rate also works but I find I have to use a value of 3500 rather than 1000 otherwise I get an error message saying there is not enough data. My recordings are ~20 seconds and done in wav 24bit 96k format.

Post Reply