0

First off, I am not experienced at all with the Sound API and am looking for some quick advice. I have a mixer object and a TargetDataLine that I want to use to record using the mixer. Here is what I have gotten:

final TargetDataLine line;
try {
    line = (TargetDataLine) mixer.getLine(mixer.getLineInfo());
} catch (LineUnavailableException e) {
    e.printStackTrace();
}

However, this code passes an IllegalArgumentException when executed.

Exception in thread "Thread-14" java.lang.IllegalArgumentException: Line unsupported: interface Mixer
at com.sun.media.sound.DirectAudioDevice.getLine(Unknown Source)
at net.minecraft.src.SequenceAudioHandler.run(SequenceAudioHandler.java:32)

Does anyone have any idea why this is happening? Sorry if I am lacking basic knowledge, I'm still trying to learn.

4

1 回答 1

0

问题是你的|| 在测试中。即使该线路不受支持但具有特定名称,您也可以接受它作为可行的混音器。因此,当您稍后尝试从中获取一行时,您会 根据文档获得IllegalArgumentException-“如果此混音器不支持任何与描述匹配的行” 。

如果您要做的是获得一条可以从麦克风录制音频的线路,我建议这个问题/答案: Java Sound API - 捕获麦克风

于 2013-05-03T01:56:41.190 回答