views:

5401

answers:

8

So how does someone create a music visualizer? I've looked on Google but I haven't really found anything that talks about the actual programming; mostly just links to plug-ins or visualizing applications.

I use iTunes but I realize that I need Xcode to program for that (I'm currently deployed in Iraq and can't download that large of a file). So right now I'm just interested in learning "the theory" behind it, like processing the frequencies and whatever else is required.

+4  A: 

Typically, you take a certain amount of the audio data, run a frequency analysis over it, and use that data to modify some graphic that's being displayed over and over. The obvious way to do the frequency analysis is with an FFT, but simple tone detection can work just as well, with a lower lower computational overhead.

So, for example, you write a routine that continually draws a series of shapes arranged in a circle. You then use the dominant frequencies to determine the color of the circles, and use the volume to set the size.

Mark Bessey
+5  A: 

As a visualizer plays a song file, it reads the audio data in very short time slices (usually less than 20 milliseconds). The visualizer does a Fourier transform on each slice, extracting the frequency components, and updates the visual display using the frequency information.

How the visual display is updated in response to the frequency info is up to the programmer. Generally, the graphics methods have to be extremely fast and lightweight in order to update the visuals in time with the music (and not bog down the PC). In the early days (and still), visualizers often modified the color palette in Windows directly to achieve some pretty cool effects.

One characteristic of frequency-component-based visualizers is that they don't often seem to respond to the "beats" of music (like percussion hits, for example) very well. More interesting and responsive visualizers can be written that combine the frequency-domain information with an awareness of "spikes" in the audio that often correspond to percussion hits.

MusiGenesis
I have noticed that most visualizers don't respond to frequencies or spikes very well. That's why I'm interested in seeing how they work, as an educational thought experiment.
crystalattice
It's a shame that MIDI has so many limitations, because that gives a programmer perfect information about what notes are playing and when. MIDI-based visualizers are perfectly responsive.
MusiGenesis
+1  A: 
  1. Devise an algorithm to draw something interesting on the screen given a set of variables
  2. Devise a way to convert an audio stream into a set of variables analysing things such as beats/minute frequency different frequency ranges, tone etc.
  3. Plug the variables into your algorithm and watch it draw.

A simple visualization would be one that changed the colour of the screen every time the music went over a certain freq threshhold. or to just write the bpm onto the screen. or just displaying an ociliscope.

check out this wikipedia article

Omar Kooheji
+3  A: 

If you're looking for a small download, fairly portable toolset to play with (and a rabid community to draw on) I would suggest Processing (http://www.processing.org), particularly http://processing.org/learning/libraries/ under ESS. That should take you down the rabbit hole. Wouldn't make an iTunes visualizer, but was used for prototyping this : http://www.barbariangroup.com/software/magnetosphere which became the default iTunes visualizer.

Pragmaticyankee
+3  A: 

There are a variety of ways of processing the audio data, the simplest of which is just to display it as a rapidly changing waveform, and then apply some graphical effect to that. Similarly, things like the volume can be calculated (and passed as a parameter to some graphics routine) without doing a Fast Fourier Transform to get frequencies: just calculate the average amplitude of the signal.

Converting the data to the frequency domain using an FFT or otherwise allows more sophisticated effects, including things like spectrograms. It's deceptively tricky though to detect even quite 'obvious' things like the timing of drum beats or the pitch of notes directly from the FFT output

Reliable beat-detection and tone-detection are hard problems, especially in real time. I'm no expert, but this page runs through some simple example algorithms and their results.

Chris Johnson
A: 

Lee Brimelow has a great video tutorial for doing this in flash. Should point you in the right direction even if you want to implement it using something other than flash.

Kristian J.
+1  A: 

For creating BeatHarness ( http://www.beatharness.com ) I've 'simply' used an FFT to get the audiospectrum, then use some filtering and edge / onset-detectors.

About the Fast Fourier Transform : http://en.wikipedia.org/wiki/Fast_Fourier_transform

If you're accustomed to math you might want to read Paul Bourke's page : http://local.wasp.uwa.edu.au/~pbourke/miscellaneous/dft/

(Paul Bourke is a name you want to google anyway, he has a lot of information about topics you either want to know right now or probably in the next 2 years ;))

If you want to read about beat/tempo-detection google for Masataka Goto, he's written some interesting papers about it.

Edit:

His homepage : http://staff.aist.go.jp/m.goto/ Interesting read : http://staff.aist.go.jp/m.goto/PROJ/bts.html

Once you have some values for for example bass, midtones, treble and volume(left and right), it's all up to your imagination what to do with them. Display a picture, multiply the size by the bass for example - you'll get a picture that'll zoom in on the beat, etc.

Led
A: 

Go to http://developer.apple.com/library/mac/#technotes/tn/tn2016.html. It gives information on iTunes Visualizers straight from Apple, and it does mention that iTunes can give you waveform data after FFT without you doing any work.

ughoavgfhw