How to realize visual spectrum while playing music

iTunes EQ

Hello,

I would like to implement similar visual effects, since iTunes plays music. I use AVAudioPlayer, my audio files are local. I played the same files in iTunes and captured this screen shot.

Updated:

  • I researched a sample of Apple avTouch . Visualization is wise, I have a general idea. but this sample refers to the measurement of volume.
  • someone told me that I need to use FFT, but this is too much above my head.
  • I found after iOS 4.1, the Accelerometer view contains FFT DSP features
  • It seems I need to touch Core Audio (Audio Queue?) To get the sample buffer and then FFT.

Well, I just want to implement a simple spectrum for my playback, who can help?

+4
source share
1 answer

FFT "I" or real input is n samples from the sample buffer (preferably with window weighting applied before conversion). Set "Q" or imaginary input for all zeros.

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

Usually you want to display power in a dB scale, which is calculated as 10 * log10 (power), each block on the display corresponds to, for example, 3dB. You can also add some averaging or peak detection.

More advanced displays also have a logarithmic frequency axis, for example. each column corresponds to 1/12 octave. Ideally, each output has its own filter, but you can achieve something similar by adding outputs with a higher FFT index instead of showing all of them.

+4
source

All Articles