/**
* Open a line to the Java Sound APIs.
*
* @throws Exception
* if the Java sound system could not be initialised.
*/
private void openJavaSound() throws Exception {
// Convert the OpenIMAJ audio format to a Java Sound audio format object
final javax.sound.sampled.AudioFormat audioFormat = new javax.sound.sampled.AudioFormat(
(int) (this.getFormat().getSampleRateKHz() * 1000), this
.getFormat().getNBits(), this.getFormat()
.getNumChannels(), this.getFormat().isSigned(), this
.getFormat().isBigEndian());
System.out.println("Creating Java Sound Line with " + this.getFormat());
// Create info to create an output data line
final DataLine.Info info = new DataLine.Info(TargetDataLine.class, audioFormat);
try {
// Get the output line to write to using the given
// sample format we just created.
this.mLine = (TargetDataLine) AudioSystem.getLine(info);
// If no exception has been thrown we open the line.
this.mLine.open(audioFormat);
} catch (final LineUnavailableException e) {
throw new Exception("Could not open Java Sound audio line for"
+ " the audio format " + this.getFormat());
}
}
JavaSoundAudioGrabber.java 文件源码
java
阅读 17
收藏 0
点赞 0
评论 0
项目:openimaj
作者:
评论列表
文章目录