java.lang.IllegalArgumentException:不支持的行:接口TargetDataLine支持格式PCM_SIGNED 44100.0 Hz,

时间:2019-07-13 04:31:26

标签: java audio processing

当我尝试在MacOS X和Windows上同时运行该程序时,当我的程序尝试打开麦克风时,出现以下异常:

java.lang.IllegalArgumentException: Line unsupported: interface TargetDataLine supporting format PCM_SIGNED 44100.0 Hz, 16 bit, mono, 2 bytes/frame, big-endian
    at com.sun.media.sound.DirectAudioDevice.getLine(DirectAudioDevice.java:174)
    at guitar.tab.generator.main.MainFrame.setNewSoundListener

此功能以前曾经工作过,突然间似乎对我不起作用,想知道这是否是由于我正在使用的JRE中的问题所致。

    AudioFormat format = new AudioFormat(sampleRate, 16, 1, true, true);

    DataLine.Info dataLineInfo = new DataLine.Info(TargetDataLine.class, format);

    TargetDataLine line;
    line = (TargetDataLine) mixer.getLine(dataLineInfo);
    final int numberOfSamples = bufferSize;
    line.open(format, numberOfSamples);
    line.start();

    AudioInputStream stream = new AudioInputStream(line);
    AudioStream audioStream = new AudioStream(stream);
    reader = new AudioReader(audioStream, bufferSize, overlap);
    reader.addAudioProcessor(new PitchEvaluator(sampleRate, bufferSize, this));

0 个答案:

没有答案