In Java, how can I play the same audio clip multiple times simultaneously? -


If I have java.applet.AudioClip object, then I can call it once to play it and call it . But if I call many times the clip will just continue to resume. It seems that the only way to move around is loading multiple instances of the same sound file. It seems worthless to memory in one game, if I have 20 explosions then I have to load 20 instances of sound file.

I have taken a quick look at javax.sound to see that using audio instead of clip will help you use it here. I do not see anything that indicates that it supports playing the same clip multiple times at once.

Is it possible that the same sound file is sometimes loaded with simple java.applet.AudioClip or Javax.sound stuff?

check here

If you use 'then a clip , You must maintain a copy per item that is necessary to play the sound together. You can keep a master copy, and then you can make copies of the clip as needed to play the clip, and then make the memory Dump copies to reduce consumption.

A second thought would be to write your clip class. In particular, you only need to dump on a TargetDataline to target some voice data. It handles buffering and plays at the right pace. If you have done all this, then you will be able to dump several times with the same example and will play it several times.


Read raw sample data in a byte array and whenever any sound is required to run, I read data from the array with a BitArray Intestream which An Audio Instream. After the playback ends I close the clip and no system resources are wasted.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -