public SoundClip(String path) {
try {
InputStream audioSrc = getClass().getResourceAsStream(path);
InputStream bufferedIn = new BufferedInputStream(audioSrc);
AudioInputStream ais = AudioSystem.getAudioInputStream(bufferedIn);
AudioFormat baseFormat = ais.getFormat();
AudioFormat decodeFormat = new AudioFormat(
AudioFormat.Encoding.PCM_SIGNED,
baseFormat.getSampleRate(), 16, baseFormat.getChannels(),
baseFormat.getChannels() * 2, baseFormat.getSampleRate(),
false);
AudioInputStream dais = AudioSystem.getAudioInputStream(decodeFormat, ais);
clip = AudioSystem.getClip();
clip.open(dais);
gainControl = (FloatControl)clip.getControl(FloatControl.Type.MASTER_GAIN);
} catch (Exception e) {
e.printStackTrace();
}
}
SoundClip.java 文件源码
java
阅读 23
收藏 0
点赞 0
评论 0
项目:Side-Quest-City
作者:
评论列表
文章目录