views:

113

answers:

4

Is there a possibility to render an visualization of an audio file?

Maybe with SoundManager2 / Canvas / HTML5 Audio? Do you know some technics?

I want to create something like this:

alt text

A: 

For this you would need to do a Fourier transform (look for FFT) which will be slow in javascript, and not possible in realtime at present.

If you really want to do this in the browser, I would suggest doing it in java/silverlight, since they deliver the fastest number crunching speed in the browser.

Phil H
A: 

Run samples through an FFT, and then display the energy within a given range of frequencies as the height of the graph at a given point. You'll normally want the frequency ranges going from around 20 Hz at the left to roughly the sampling rate/2 at the right (or 20 KHz if the sampling rate exceeds 40 KHz).

I'm not so sure about doing this in JavaScript though. Don't get me wrong: JavaScript is perfectly capable of implementing an FFT -- but I'm not at all sure about doing it in real time. OTOH, for user viewing, you can get by with around 5-10 updates per second, which is likely to be a considerably easier target to reach. For example, 20 ms of samples updated every 200 ms might be halfway reasonable to hope for, though I certainly can't guarantee that you'll be able to keep up with that.

Jerry Coffin
A: 

http://ajaxian.com/archives/amazing-audio-sampling-in-javascript-with-firefox

Check out the source code to see how they're visualizing the audio

Ben Rowe
A: 

This isn't possible yet except by fetching the audio as binary data and unpacking the MP3 (not JavaScript's forte), or maybe by using Java or Flash to extract the bits of information you need (it seems possible but it also seems like more headache than I personally would want to take on).

But you might be interested in Dave Humphrey's audio experiments, which include some cool visualization stuff. He's doing this by making modifications to the browser source code and recompiling it, so this is obviously not a realistic solution for you. But those experiments could lead to new features being added to the <audio> element in the future.

Jason Orendorff