Reputation: 53
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:
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.
Upvotes: 1
Views: 902
Reputation: 403
I am currently working on the same thing and I found the solution.
The problem: synchronized methods and attributes that doesn't allow paraell access.
The solution: Two threads in one thread group and synchronization over that thread group.
or* : Cached thread pool for runnables and synchronization over that cached pool. then your stream reader is one runnable and your visualisation is the second runnable.
Works just fine.
Upvotes: 0
Reputation: 1
I would try and set up each part in a thread and then synchronize the timing elements so they start at the same time.
Upvotes: 0