Here is part 2 of my sound experimentation.

What I’m trying to do here is to analyse Fast Fourier Transform data from a sine wave, to determine what the initial pitch of the sound is.

First of all I’m generating a sine wave (see part 1). The pitch of this wave is relative to the mouse X position. This frequency is represented on the graph as a white line.

Then the sound data is put through the Fast Fourier Transform (FFT) using

SoundMixer.computeSpectrum(bytes, true, 2);

This data is plotted on the graph and the 5 highest peaks are marked with the red cross.

I want to determine the initial frequency of the sound that was put through FFT. This version calculates this by finding the middle point of the 3rd and 4th highest peaks, and then averaging this value with the weighted average height of the three highest peaks. The calculated frequency is represented on the graph by the red line.

In the bottom right-hand corner you can see the two pitches, and the difference between them.

Obviously this still has quite a way to go as the estimated frequency moves around quite a bit.

Would you care to share the source? 🙂

Hi zproxy,

The source for this has actually evolved into something else now. I can’t send you a working set of files, but can probably dig out a function or two if you need. Which part of this are you interested in?

Cheers

Did you see SiON? I tried to get into it but didn’t have the patience for all the numbers… really awesome sound synth library for AS3

Here’s an “intuitive” demonstration: http://wonderfl.net/c/f5eX