Example usage for javax.sound.sampled BooleanControl setValue

List of usage examples for javax.sound.sampled BooleanControl setValue

Introduction

In this page you can find the example usage for javax.sound.sampled BooleanControl setValue.

Prototype

public void setValue(boolean value) 

Source Link

Document

Sets the current value for the control.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    DataLine.Info info = null;/* ww  w  .  j  a  v  a2s.  co m*/
    Clip clip = (Clip) AudioSystem.getLine(info);

    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);

    BooleanControl muteControl = (BooleanControl) clip.getControl(BooleanControl.Type.MUTE);
    muteControl.setValue(true);

    muteControl.setValue(false);

}