1

The goal is to get a simple 2d audio visualizer that is somewhat responsive to the music.

I've got the basics set up, where I have graphics that will respond to some data being fed in. Given a file, I load up an audioInputStream for playback (this works fine), and have that running in a thread. In another thread, I would like to extract byte data at a rate close to the playback (or perhaps faster, to allow for delay in processing that data). I then want to feed that to an FFT process, and feed the resulting data to my graphics object that will use it as a parameter for whatever the visualization is.

I have two questions for this process:

1) How can I get the byte data and process it at a rate that will match the normal playback of a file? Is using an audioInputStream the way to go here?

2) Once I do FFT, what's a good way to get usable data (ie: power spectrum? Somehow filtering out certain frequencies? etc..)

John
  • 21
  • 3

1 Answers1

0

Some considerations about (2) using the FFT to extract "features".

You should calculate short-term FFTs for example 512 points, whenever there is enough CPU cycles free to do so. For a visualisation it is not necessary to preserve all information (i.e. work with overlapping windows), instead you could calculate a 100ms FFT 5 times per second.

Then you should calculate the logarithmic power spectrum in dB (decibel). This gives you a pretty good impression about the detailed frequency content of your sound.

Depending on what you like to visualize you could for example combine some low frequency FFT lines (calculate the RMS) to get the "Bass" content of your sound and so on.

See this post for details.

Community
  • 1
  • 1
DrKoch
  • 9,556
  • 2
  • 34
  • 43