Setting the Volume of a Sampled Audio Player

// To create a Clip object, see 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);

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.