views:

1990

answers:

7

Hi,

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?

A: 

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/

bastianneu
+1  A: 

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.

basszero
I'm not trying to write a player or anything, just something that will take in an MP3 and visualize it, but I don't know anything about how to connect all those pieces. I'm on Linux, so I'd stick to something simple. Haven't really thought about integrating it into anything else.
victor
consider using a library like mpg123, libmad, or ffmpeg to decode then mp3 into audio samples. From there you'll want to use DFT(FFT) to convert audio to frequency information (see FFTW). At this point you'll have raw frequency data similar to what you see on most visuliazers (winamp/xmms moving lines w/ peaks). After that you need to figure out what to visual based on frequency and changes in frequency.
basszero
A: 

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++.

20th Century Boy
A: 

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.

Jem
+1  A: 

If you use C++/CLI, here's an example that uses WPF four (fourier that is;) display.

He references this site 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 1.2. Harmonic Oscillator
  2. Sampling Sounds
  3. Fourier Analysis
  4. Complex Numbers
  5. Digital Fourier Transform
  6. FFT

Ahhh, I found this a few minutes later, it's a native C++ analyzer. Code included, that should get you off and running.

RandomNickName42
A: 

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.

A: 

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

Led