I'm writing an indicator-sound
clone for OSS4. Setting the volume works fine now, but I'm having trouble with the muting aspect of my program.
A couple of facts about muting in OSS4:
The problem with this is, when reading the vmix volume and encountering zero, we don't know if the user has actually set it to zero, or has it set to some other value, but has mute on.
How should I write my muting logic when there is no concept of a central mute in OSS4's vmix and other volume controllers handle mute internally?
I'm not familiar with vmix
or OSS
so this might be way off...
You can add two variables to your own system: a flag to maintain the mute state, and a value to maintain the most recent unmuted volume.
OnMuteEvent
if MuteFlag //we were muted, now unmuting
MuteFlag = False
vmix current volume = LastVolume
else //we were unmuted, now muting
MuteFlag = True
LastVolume = vmix current volume
vmix current volume = 0
When the user turns mute on, you set the mute flag, which you can reflect on your UI, and log the volume value, then set the volume to 0. When the user unmutes, set the volume back to the logged value and clear the flag.
If your application can be launched when the user might have already set the mute state, you can initialize as follows:
if vmix.volume is 0 //might be mute!
MuteFlag = True //assume it was due to being muted
LastVolume = MaxVolume/2 //some sensible volume for when we unmute