/**
* Constructs a Microphone with the given InputStream.
*/
@Override
public void initialize() {
super.initialize();
audioList = new LinkedBlockingQueue<Data>();
DataLine.Info info = new DataLine.Info(TargetDataLine.class, desiredFormat);
/*
* If we cannot get an audio line that matches the desired
* characteristics, shoot for one that matches almost everything we
* want, but has a higher sample rate.
*/
if (!AudioSystem.isLineSupported(info)) {
logger.info(desiredFormat + " not supported");
AudioFormat nativeFormat = DataUtil.getNativeAudioFormat(desiredFormat, getSelectedMixer());
if (nativeFormat == null) {
logger.severe("couldn't find suitable target audio format");
} else {
finalFormat = nativeFormat;
/* convert from native to the desired format if supported */
doConversion = AudioSystem.isConversionSupported(desiredFormat, nativeFormat);
if (doConversion) {
logger.info("Converting from " + finalFormat.getSampleRate() + "Hz to "
+ desiredFormat.getSampleRate() + "Hz");
} else {
logger.info("Using native format: Cannot convert from " + finalFormat.getSampleRate() + "Hz to "
+ desiredFormat.getSampleRate() + "Hz");
}
}
} else {
logger.info("Desired format: " + desiredFormat + " supported.");
finalFormat = desiredFormat;
}
}
Microphone.java 文件源码
java
阅读 24
收藏 0
点赞 0
评论 0
项目:BrainControl
作者:
评论列表
文章目录