How to start writing a music visualizer in C++?
Are you trying to write your own audio/music player? Perhaps you should try writing a plugin for an existing player so you can focus on graphics rather than the minutia of codecs, dsp, and audio output devices.
I know WinAMP and Foobar have APIs for visualization plugins. I'm sure Windows Media Player and iTunes also have them. Just pick a media player and start reading. Some of them may even have existing OpenGL plugins from which you can start so you can focus on pure OpenGL.
If you use C++/CLI, here's an example that uses WPF four (fourier that is;) display.
He references this site (archived) that has considerable information about what your asking, here's anoutline from the specific page;
How do we split sound into frequencies? Our ears do it by mechanical means, mathematicians do it using Fourier transforms, and computers do it using FFT.
- The Physics of Sound
- Harmonic Oscillator
- Sampling Sounds
- Fourier Analysis
- Complex Numbers
- Digital Fourier Transform
- FFT
Ahhh, I found this (archived) a few minutes later, it's a native C++ analyzer. Code included, that should get you off and running.
My approach for creating BeatHarness (http://www.beatharness.com) :
- record audio in real time
- have a thread that runs an FFT on the audio to get the frequency intensities
- calculate audio-volume for left and right channel
- filter the frequencies in bands (bass, midtones, treble)
now you have some nice variables to use in your graphics display. For example, show a picture where the size is multiplied by the bass - this will give you a picture that'll zoom in on the beat. From there on it's your own imagination ! :)