I tried to play some sounds using the javax.sound.sampled package, when I encountered a strange residual beeping sound right after the clip ends. I am playing back four different audio files and the other three are working fine. I can not find a reason, why it is making this sound. Just to clarify, I checked the audio file in a editor and the beeping noise is not showing up and therefore has to be caused by Java. The following code is used to play the sounds (I am having trouble with case 1):
import java.io.IOException;
import java.net.URL;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;
public class SoundHandler implements SoundConstants{
URL url;
public SoundHandler() {
url = this.getClass().getResource("/sounds3.wav");
}
public void playSound(int sound) {
try {
Clip clip = AudioSystem.getClip();
clip.open(AudioSystem.getAudioInputStream(url));
clip.setFramePosition(0);
clip.start();
} catch (IOException | LineUnavailableException | UnsupportedAudioFileException e) {
e.printStackTrace();
}
}
}