public void setVolume(float gain) {
        if (audioDevice instanceof JavaSoundAudioDevice) {
            JavaSoundAudioDevice jsAudio = (JavaSoundAudioDevice) audioDevice;
            if (gain > maxGain) {
                gain = maxGain;
            }
            if (gain > getMaxGain()) {
                gain = getMaxGain();
            }
            if(fadeOut != null) {
                fadeOut.setFade(gain, (gain+getMinGain())/2, fadeTime, duration-fadeTime);
            }
            currentGain = gain;
            jsAudio.setLineGain(gain);
            //EIError.debugMsg("Setting Gain: "+gain);
        }
    }