This project has moved and is read-only. For the latest updates, please go here.

Obtaining intensity from samples via FFT?

Oct 17, 2013 at 11:40 AM
Hi, I am trying to obtain the intensity of the audio in a specific window which I assume FFT is done to audio samples.

The question is do these samples need to be bytes or floats? And how would I synchronize the outputted intensities with the audio in time: e.g. 2 minute audio track, every 10ms should have a new intensity.

I looked at the auto-tune article but that didn't seem to have any code that showed intensity...
Oct 17, 2013 at 2:55 PM
the intensity of each bin in the FFT output is calculated as the square root of the sum of the squares of the real and imaginary parts. Remember the that first bin is DC, and that only the first half of the bins are of interest. An FFT length of 512 at a sample rate of 44100 should give you close to the 10ms chunks you are after. You may also want to apply a windowing function to the audio before applying the FFT.
Oct 17, 2013 at 3:26 PM
Could I get intensity if I just RMS floating point samples obtained from an audiofilereader? Or is that not a good idea? Some other guys on the internet seem to have been doing that.

I'm trying to make a game with the "loudness" of the sounds as a core mechanic but I was taught in school (yes I am a high school student) that amplitude is loudness? And found out that samples are electronic equivalents of amplitude at a specific moment in time.

Right now I have a samplechannel for the samples (floats) and a waveoutdevice for the music to be played. I'm struggling to sync both as they are separate objects.

Sorry, not exactly an audio specialist here...
Oct 18, 2013 at 5:05 PM
Here's what I have so far, however, I do not know if the FFT is done correctly...

test.cs (The main application class + method):
FFT.cs (FFT class found on the net):
Oct 25, 2013 at 7:54 AM
I'm unclear what you are actually trying to do. The FFT is for getting frequency information. If you just want to see how loud the signal is, then examine the sample values coming from AudioFileReader. Find the maximum absolute sample value over a period of say 10ms, and convert it to decibels if you want by taking log base 10 and multiplying by 20.