Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a Windows program that can determine the "highest sound wave frequency" found within an audio file (e.g. mp3 file)?

For example, it should be able to analyze the file Dog-Whistle-0 and determine that the highest frequency found within the file is roughly ~12000 Hz.

Also, it should be able to analyze Piano.mp3 and determine the highest note.

share|improve this question
add comment

2 Answers

up vote 12 down vote accepted

R is cross-platform and free / open source.

Load it, and load the tuneR and seewave libraries (install them from the package manager if not installed yet).

library(tuneR)
library(seewave)

Then, load your MP3 or WAV file:

w = readMP3("dog-whistle-0.mp3")
w = readWave("dog-whistle-0.wav")

Now, let's plot the spectrum and its peaks:

fpeaks(meanspec(w), nmax=1)

Result:

Numerical result:

fpeaks(meanspec(w), nmax=1, plot=FALSE)
12.05859

The above only works with non-musical data. When you analyze frequencies of music, you'll find that the highest frequencies will always be around 12-20 kHz, depending on the instrument(s) involved. However, this highest frequency will not give you an estimate of the note that's being played, since a musical note, when played by an instrument, will be composed of multiple frequencies.

This is the so-called "timbre" of an instrument, and you'll find that that an A at 440 Hz by a flute will include different frequency components as compared to an A played by an electric guitar.

Your best bet is to run a dominant frequency analysis by looking at the frequency peaks over sliding time windows, and check where the highest one occurs.

There's no such thing as "frequency over time" though. You can only plot the average (or dominant) frequency over certain sliding time windows. Seewave offers quite a few functions regarding selecting windows of time, but it gets rather complicated.

You could use

s = specprop(meanspec(w, from=10, to=11)) 

to get the spectrum properties from 10 to 11 seconds and then call s$centroid or s$mean to get the centroid or mean frequencies of that particular time window (although 1 second is quite large for audio analysis).

If your Wave file uses 44.1 kHz sampling, you could downsample it to reduce the computation effort, e.g. to 16 kHz.

w = downsample(w, 16000)

But remember that according to the Nyquist Theorem, the maximum frequency that can be represented now is 8 kHz.

You could also look for a pitch detection software. Like this one, which requires MATLAB though.

share|improve this answer
    
Btw instead of fpeaks, are you aware if there's a function that plots the graph of frequency against time? –  Pacerier Jun 13 '12 at 13:13
    
See my update. It's not that trivial. I haven't been working with audio that much to know if there's anything better around though, sorry. –  slhck Jun 13 '12 at 13:21
    
Thanks for the info =) –  Pacerier Jun 13 '12 at 13:32
    
+1 very well explained. –  avirk Jun 13 '12 at 13:57
add comment

Have you tried Audacity? It is a freeware tool that has some fairly sophisticated analysis tools, including a Plot Spectrum command accessed from Analyse -> Plot Spectrum....

Screenshot

Note that you get different results with the MP3 version of the file compared to the WAV version because the MP3 compression has altered the waveform and introduced artifacts/aliasing.

Edit: Those sound files you link to are not good examples for this. The higher frequency files are only sampled at 44.1KHz which is tailored to human hearing (around 20KHz max). You can't represent ultrasound frequencies without increasing the sample rate.

share|improve this answer
    
Hmm, it doesn't seem to work with the file Piano.mp3. For me it shows 10121 Hz (D#9) screenshoot.me/uZZ2N0, yet this is highly unlikely because the largest key on a piano is C8 (4186Hz). Am I doing something wrongly? –  Pacerier Jun 13 '12 at 12:44
3  
@Pacerier No, but you changed your question a bit. The dog whistle sample is easy to identify because the frequency with the highest peak in the spectrum is also the highest frequency and at the same time the dominant note. For music, the highest frequency is not necessarily the highest note, as a musical note played by an instrument is composed of multiple frequencies. –  slhck Jun 13 '12 at 12:46
    
@slhck Ic, I'd thought we could guess the note if we had the frequency, looks like it isn't so straightforward.. –  Pacerier Jun 13 '12 at 12:50
    
@Pacerier: If you set Size to a higher value I believe it may give more precise results and eliminate some harmonics. –  James Jun 13 '12 at 12:51
2  
@Pacerier No, it's really not as straightforward. Pitch detection requires you to transform the waveform into a frequency spectrum first (Fast Fourier Transform), then apply filters (Low-pass mostly), and yet another round of filters. Unless you find a tool that tracks pitch over time, what you're seeking is really going to be hard. You could look into vocal correction tools like Melodyne. –  slhck Jun 13 '12 at 12:53
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.