e730. setting the volume of a sampled audio player.txt

来自「这里面包含了一百多个JAVA源文件」· 文本 代码 · 共 15 行

TXT
15
字号
  // To create a Clip object, see e723 Loading and Playing Sampled Audio
    
    // Set Volume
    FloatControl gainControl = (FloatControl)clip.getControl(FloatControl.Type.MASTER_GAIN);
    double gain = .5D;    // number between 0 and 1 (loudest)
    float dB = (float)(Math.log(gain)/Math.log(10.0)*20.0);
    gainControl.setValue(dB);
    
    // Mute On
    BooleanControl muteControl = (BooleanControl)clip.getControl(BooleanControl.Type.MUTE);
    muteControl.setValue(true);
    
    // Mute Off
    muteControl.setValue(false);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?