public static void playGradient(double fstart,double fend,double duration,double volume,byte fadeend,byte wave) {
byte[] freqdata = new byte[(int)(duration * SAMPLE_RATE)];
// Generate the sound
for(int i = 0; i < freqdata.length; i++) {
freqdata[i] = (byte)generateValue(i, duration, fstart + (fend-fstart) * (i/(double)freqdata.length), volume, fadeend, wave);
}
// Play it
try {
final AudioFormat af = new AudioFormat(SAMPLE_RATE, 8, 1, true, true);
SourceDataLine line = AudioSystem.getSourceDataLine(af);
line.open(af, SAMPLE_RATE);
line.start();
line.write(freqdata, 0, freqdata.length);
line.drain();
line.close();
}catch(LineUnavailableException e) {
e.printStackTrace();
}
}
SoundGenerator.java 文件源码
java
阅读 23
收藏 0
点赞 0
评论 0
项目:Explorium
作者:
评论列表
文章目录