gpt4 book ai didi

Java:Master Gain 不支持异常

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:42:53 26 4
gpt4 key购买 nike

在 linux 中这段代码不起作用:我添加了两行

// Added two lines.
DataLine.Info info = new DataLine.Info( SourceDataLine.class, audioFormat );
SourceDataLine dataLine = (SourceDataLine) AudioSystem.getLine( info );
// Adjust the volume on the output line.
if( dataLine.isControlSupported( FloatControl.Type.MASTER_GAIN)) {
// If inside this if, the Master_Gain must be supported. Yes?
FloatControl volume = (FloatControl) dataLine.getControl(FloatControl.Type.MASTER_GAIN);
// This line throws an exception. "Master_Gain not supported"
volume.setValue( 100.0F );
}

这正常吗?我该怎么做才能解决这个问题?
在 Windows 中是否有效。

谢谢,马丁。

最佳答案

在尝试对其使用控件之前,您能否尝试open() 该行。像这样:

// Added two lines.
DataLine.Info info = new DataLine.Info( SourceDataLine.class, audioFormat );
SourceDataLine dataLine = (SourceDataLine) AudioSystem.getLine( info );
dataLine.open();
// Adjust the volume on the output line.
if( dataLine.isControlSupported( FloatControl.Type.MASTER_GAIN)) {
// If inside this if, the Master_Gain must be supported. Yes?
FloatControl volume = (FloatControl) dataLine.getControl(FloatControl.Type.MASTER_GAIN);
// This line throws an exception. "Master_Gain not supported"
volume.setValue( 100.0F );
}

关于Java:Master Gain 不支持异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1827607/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com