I use the following code to download a clip (javax.sound.sampled.Clip)
def createClip(file:String):Clip = {
val clip = AudioSystem.getClip()
clip.open(AudioSystem.getAudioInputStream(new File(s"sounds/$file.wav")))
clip
}
It is written in Scala, but I think that anyone who is not familiar with Scala, but java will see that it is basically the same as java.
My attempt was to do this effortlessly to produce such a sound
createClip("example_WAV_File").start()
Since I will create a new Clip, every time I call a sound file, I thought that there should not be any problems with rewinding the clip, etc. However, in a real application (game), I used this library to process sounds arising from a stroke and all these things. Now here's what, when (say, for example) breaks several times, some when I get
"Thread-58" javax.sound.sampled.LineUnavailableException: PCM_SIGNED 44100.0 , 16 , , 4 /, -endian .
, , 16 . 16- , , ...
, .
, . , , - , .
, , , , . , . , .
, , , close() .
val clip = createClip("example_WAV_file")
clip.start()
clip.close()
, , , , , .
, .getMicrosecondLength(), ? .
left → API , , , . , ? ?