对于 MacBook Pro 上的内置麦克风和内置输入,以下几行均返回 false
:
line.isControlSupported(FloatControl.Type.VOLUME);
line.isControlSupported(FloatControl.Type.MASTER_GAIN);
line
是 TargetDataLine
的一个实例,并且已成功 open()
'd。
因为我无法设置增益,所以我捕获的任何音频都处于极低的水平,并且被噪音淹没。 JVM(1.6.0_24、com.apple.javajdk16.cmd、OS X 10.6.7)在调用 TargetDataLine.close()
时也经常崩溃。
有人对此感到幸运吗?
最佳答案
检查一下 - 这里有 OS X java 声音演示应用程序。
http://java.sun.com/products/java-media/sound/samples/JavaSoundDemo/
也有一个可用的 os x 增益控制。
基于评论:
也检查一下:http://www.jsresources.org/faq_audio.html#recording_volume ,但老实说从未尝试过。在页面:
The obvious solution would be to get a Control object of type VOLUME or MASTER_GAIN for the TargetDataLine and manipulate the volume via this object. However, this is not possible, since no known Java Sound implementation supports any controls for TargetDataLine instances.
What you can do is to use the system mixer to control the recording volume --- it affects hardware settings in the soundcard. One possibility is to use the mixer application of the operating system. The other possibility is using Port lines from inside a Java Sound application. See the section Ports for details.
关于OS X 上的 Java 声音输入。不支持音量控制?崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6169076/