Question

I'm interested in learning to use OpenGL and I had the idea of writing a music visualizer. Can anyone give me some pointers of what elements I'll need and how I should go about learning to do this?

Was it helpful?

Solution

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.

  1. The Physics of Sound
    • Harmonic Oscillator
  2. Sampling Sounds
  3. Fourier Analysis
  4. Complex Numbers
  5. Digital Fourier Transform
  6. 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.

OTHER TIPS

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 ! :)

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're just after some basic 3D or accelerated 2D then I'd recommend purchasing a copy of Dave Astle's "Beginning OpenGL Game Programming" which covers the basics of OpenGL in C++.

For the music analysis part, you should study the basis of Fourier series, then pick a free implementation of a DFFT (digital fast fourier transform) algorithm.

You can find implementation of FFT algorithms and other useful informations in Numerical Recipes in C book. The book is free AFAIK. There is also Numerical Recipes in C++ book.

You may want to consider using libvisual's FFT/DCT functions over FFTW; they're much simpler to work with and provide data that's similarly easy to work with for the sake of generating visuals. Several media players and visualization plugins use libvisual to some extent for their visuals. Examples: Totem (player), GOOM (plugin for Totem and other players), PsyMP3 2.x (player)

From my point of view...check this site: http://nehe.gamedev.net/

really good Information and Tutorials for using OpenGL

edit: http://www.opengl.org/code/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top