How does one get the master volume in Java? I want to make a program that displays (NOT CHANGE) this value (probably on a JProgressBar
or somet
You could be a little less abrasive rather than say "Does not help me".
Otherwise, here is the big picture, using the Sound API mentioned by AlexR's example: (there are a lot of practical details on that forum thread, and there is some Oracle documentation for Processing Audio with Controls)
Once you get a Line object that represents the sound output line that you wish to control, it is rather trivial to get the volume control:
line.open(); // May be necessary if the line is not already opened.
FloatControl volumeControl = (FloatControl) masterLine.getControl(FloatControl.Type.VOLUME);
Getting the "Master Line
" object is, at best, platform-dependant. You will have to list the Mixers and the Line
s at runtime using the AudioSystem static methods in order to determine which line you want. It can also happen that the master line will not support the volume control directly, but only through a CompoundControl
. (through a hierarchy that is, you guessed it, platform-dependant).