# Can FFT be used to find peaks and pits on audio files

I'm able to read wav files and its values. I need to find peaks and pits positions and their values.

First time, I tried to smooth it by $\frac{(i-1 + i + i + 1)}{3}$ formula, then searching on array as array[i-1] > array[i] & direction == 'up' --> pits style solution. But because of noise and other reasons of future calculations of project, I'm trying to find a better working area.

Since couple days, I'm researching FFT. As my understanding, FFT translates the audio files to series of sines and cosines. After FFT operation the given values is a0's and a1's for $a_0 + a_k * cos(k*x) + b_k * sin(k*x)$ which k++ and x++ as this picture:

My question is, does FFT helps to me find peaks and pits on audio? Does anybody has a experience for this kind of problems?

• Define what you mean by "peaks and pits". The "raw" audio signal can be displayed as a waveform that will have peaks and valleys, but the "envelope" will also have "peaks" (corresponding to loud sounds) and "valleys" (corresponding to relatively quiet intervals). What are you going to do with the "peaks and pits" information once you have it?? – Daniel R Hicks Jul 3 '12 at 15:04

FFT is a tool to look at your signal content in frequency domain. So if you want to find peaks of your time domain signal, FFT cannot help you. However if you want to see what frequency component in the signal is the largest then you can use FFT. To find peaks of your time domain signal you can load it into MATLAB and use command "max" for example if your signal is called "mySignal" in MATLAB type: max(mySignal) and it will give you the location of value of the peak.

Note that if your signal is periodic, you can find the "peaks and pits", in spite of a moderate amount of noise and distortion, with an appropriately designed phase-locked loop.

Unless you clearly define what you mean by "peaks" and "pits", this is an unanswerable question. Do you mean

1. Local minima and maxima in the time domain waveform?
2. Local maxima and minima of the envelope? If so, what is your time scale for enevelope detection
3. Areas that are perceived as "louder" or "softer" as the average track.
4. Something else

These are all very different things that require very different algorithms.

If your intention is to detect sections with high and low level (for example for dynamic compression) at the scale of tenths of seconds or seconds, you don't need the FFT. A common way to extract an envelope from an audio signal is to compute the maximum sample over a small window of a few ms ; then low-pass filter the result. The averaging you do over 3 successive sample is not capable of tracking long term level changes in the signal - I assume these are the ones relevant to you. More sophisticated level detectors include filters which have different coefficients depending on whether successive samples are increasing or decreasing (allowing a fast response to positive change, and a slower decay after a peak to prevent "pumping").