그래서 기타 시뮬레이터를 만들려고합니다. 내가 메서드를 호출하면 해당 노트가 재생됩니다. 그러나 다시 호출하면 이전 사운드가 재생되지 않습니다.Java의 메서드에서 오디오 파일을 재생하는 방법은 무엇입니까? 그러나 해당 메서드를 다시 호출하면 이전 오디오 파일의 재생이 중단됩니까?
public class ytst {
public static void main(String[] args)throws Exception {
Estring.play(1);
TimeUnit.SECONDS.sleep(3);
Estring.play(2);
}
----------
class Estring{
public static play(int fret){
String filename="E" + fret + ".wav"
File soundFile = new File(filename);
AudioInputStream audioIn = AudioSystem.getAudioInputStream(soundFile);
Clip clip = AudioSystem.getClip();
clip.open(audioIn);
clip.start();
}
}
이렇게하면 두 번째 오디오 파일이 첫 번째 오디오 파일과 겹칩니다. 이 메드를 다시 호출하면 이전 사운드 파일의 재생이 중지되므로 어떻게 할 수 있습니까?