Controlling volume of a Clip when using Java Sound (javax,sound.sampled)
Pergunta
I'm using Java sound to play back a number of sound samples with the Clip.start() method.
Given this, what is the best way to control the playback volume?
In particular, I'm very keen that the solution will work reliably across platforms.
Solução
FloatControl volume = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
volume.setValue(gainAmount);
Just replace gainAmount
with a float representing the gain in decibels. Can be positive or negative.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow