public void setLineGain(float gain) {
        if (source != null) {
            if (source.isControlSupported(FloatControl.Type.MASTER_GAIN)) {
                FloatControl volControl = (FloatControl) source.getControl(FloatControl.Type.MASTER_GAIN);
                float newGain = Math.min(Math.max(gain, volControl.getMinimum()), volControl.getMaximum());

                volControl.setValue(newGain);
            }
        }
    }