java 获取麦克,如何从与Java API声麦克风捕捉声音?

博主在尝试枚举音频混频器以寻找带有麦克风输入的设备。通过AudioSystem获取混频器信息,成功找到混频器但无法获取到用于读取的线路。尝试使用mixer.getTargetLineInfo()和mixer.getTargetLines()均未得到预期结果。遇到的问题包括获取到未记录的内部类对象和空数组。博主建议提供一个可视化的音频线路渲染组件来辅助识别声音线路。
摘要由CSDN通过智能技术生成

I am enumerating mixers with the following code

System.out.println("Searching for microphones");

for(Mixer.Info mixerinfo : AudioSystem.getMixerInfo()) {

mixer = AudioSystem.getMixer(mixerinfo);

//System.out.println(mixerinfo.toString());

if( mixer.isLineSupported(Port.Info.MICROPHONE) ) {

mixers.add(mixer);

System.out.println(Integer.toString(mixers.size()) + ": " + mixerinfo.toString());

}

}

i.e. by presense of microphone input. But next, having a mixer, I can't get line to read.

If I use mixer.getTargetLineInfo(), I receive an array of one Info, which when passing to mixer.getLine returns an object of type com.sun.media.sound.PortMixer$PortMixerPort, which is not ducumented.

If I use mixer.getTargetLines() I get an empty array.

If I create my own DataLine.Info and pass it to the mixer's getLine, I get unsupported exception.

So, what to do?

解决方案

Left-field suggestion.

Provide a visual rendering of each sound line, in a component along the lines of the AudioPlotPanel or a simpler RMS volume. It should not take the user too long to figure which sound line they are yodeling through. ;)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值