Mute/unmute?

Ok, I just ran into this during my effort to improve the AudioSystem in JME.



    public void unmute() {
        setVolume(volume);
    }

    public void mute() {
        if (enabled)
            setVolume(0.0f);
    }

    public float getVolume() {
        return volume;
    }

    public void setVolume(float volume) {
        this.volume = volume < 0.0f ? 0.0f : volume > 1.0f ? 1.0f : volume;
        player.setVolume(this.volume);
    }



Am I the only one who would think that:


track.mute();
// no sound now....
track.unmute();
// The sound is back up...



Would be the case? Well it is not, since setVolume(0.0f) will set track.volume to 0.0f making a call to unmute() not work as expected.

Is anyone interested in mute() unmute() methods? Could they not just use setVolume(0.0f) and setVolume(1.0f) if that is what mute/unmute does?

That's weird… where is that code from?



Locally I have this in OpenALSystem:



    @Override
    public void mute() {
        super.mute();
       
        lastMasterGain = masterGain;
        setMasterGain(0);
    }

    @Override
    public void unmute() {
        if (lastMasterGain == -1) {
            return;
        }
        super.unmute();

        setMasterGain(lastMasterGain);
    }

Sorry, I forgot to say it was from "AudioTrack.java". And from CVS back in 10/22/2007, maybe it has been fixed later on - we are waiting to merge changes since then into our repository. (did I mention that we look forward to the JME2.0 SVN repository? :wink: )