public synchronized void setVolume ( float gain ) { if ( currentVolume != gain ) { currentVolume = gain ; if ( sourceLine != null && sourceLine . isControlSupported ( FloatControl . Type . MASTER_GAIN ) ) { FloatControl gainControl = ( FloatControl ) sourceLine . getControl ( FloatControl . Type . MASTER_GAIN ) ; float dB = ( float ) ( Helpers . getDBValueFrom ( gain ) ) ; if ( dB > gainControl . getMaximum ( ) ) dB = gainControl . getMaximum ( ) ; else if ( dB < gainControl . getMinimum ( ) ) dB = gainControl . getMinimum ( ) ; gainControl . setValue ( dB ) ; } } }
Set the Gain of the sourceLine