4

iTunes EQ

Hello,

I'd like to implement a similar visual effects as iTunes plays music. I'm using AVAudioPlayer, my sound files are local. I played the same files in iTunes and captured this screenshot.

Updated:

  1. I did research Apple's avTouch sample. Visualization-wise, I've got a rough idea. but this sample is about volume metering
  2. someone told me I need to use FFT, but that's too much over my head
  3. I found after iOS 4.1, the Accelerometer framework contains FFT DSP functions
  4. It seems I need to touch down to Core Audio (Audio Queue?) to get sample buffer then FFT it

Gee, I only want to implement a simple spectrum for my playback, anyone can help?

Chris Chen
  • 5,307
  • 4
  • 45
  • 49
  • This may help you: http://stackoverflow.com/questions/3398753/using-the-apple-fft-and-accelerate-framework/4094705#4094705 – P i Jul 26 '11 at 23:51

1 Answers1

4

The FFT "I" or real input is n samples from the sample buffer (preferably with a window weighting applied prior to the transformation). Set the "Q" or imaginary input to al zeros.

The output is the complex spectrum with DC in the index=0 position. Index=1 corresponds to the sampling frequency divided by the FFT length N, index=2 twice that frequency and so on up to index N/2. To get the power at a certain frequency you need to add the squared real and imaginary parts.

Typically you want to display the power in a dB scale, which is calculated as 10*log10(power), each block in the display corresponds to e.g. 3dB. You may also want to add some averaging or peak detection.

The more advanced displays has a logarithmic frequency axis as well, e.g. each column corresponds to 1/12 octave. Ideally each output has its own filter but you may achieve something similar by adding the higher index FFT outputs instead of showing them all.

Jens
  • 409
  • 4
  • 11