Synchronizing Java Visualizer Audio and Visual

Posted by Matt on Stack Overflow See other posts from Stack Overflow or by Matt
Published on 2011-01-01T19:46:34Z Indexed on 2011/01/01 19:54 UTC
Read the original article Hit count: 278

I've run into a problem creating a visualizer for .mp3 files in Java. My goal is to create a visualization that runs in time with the .mp3 file being played.

I can currently visualize an .mp3 OR play it, but not both at the same time. I am using libraries which may make this trickier than necessary.

I currently:

  1. Read in the .mp3 as a FileInputStream.
  2. a) Convert the FileInputStream into a Bitstream and run the Visualizer OR b) Pass the FileInputStream to a library Play method where it converts it into a Bitstream, decodes it, and plays it.

I am using the JLayer library to play and decode the .mp3.

My question is: how do I synchronize the two actions so that I can run both at the same time AND they line up (so my visualizations correspond to the changing frequencies). This implies that they finish at the same time as well.

© Stack Overflow or respective owner

Related posts about java

Related posts about synchronization