SetSoundVolumeMBS does not work?

I have this code, which does nothing:

Var Value As Integer //Between 0 and 100

if Value<1 then //Mute
  SetSoundVolumeMBS 0
  SetSoundMuteMBS True
Else //Unmute
  SetSoundMuteMBS False
  SetSoundVolumeMBS Value/100
end if

For example, even when value=0, I can still listen to the running music.
It’s on MacOS 12. Does it works for someone else or it’s just broken?

1 Like


1 Like

I can’t make it working on Windows, either.

let me look. This is quite old code.

SetSoundVolumeMBS 0.5

on macOS works just fine.
You don’t need to do mute, I think.

On Mac this sets kAudioDevicePropertyVolumeScalar for the system sound device and you can do that yourself with CoreAudioMBS class.

On which MacOS version have you tried?
I just tried your exact code and it still does nothing. MacOS 12 here.

I’ll try later with the CoreAudioMBS class.
Ultimately, I need a solution for Windows.

Thank you.

Monterey 12.1.
On windows, it changes the mixer, which you can also change with WindowsAudioMixerMBS class.

But if macOS or Windows changed APIs or permissions to do this, that may not work.

That’s useful. I always wonder about that and never found a definitive answer (never searched enough, either).

Same as me…

So if we have the same OS version, it shouldn’t be a permission issue :thinking:
Could it be related to our configuration? Like you’re trying on the built-in speaker and I’m attempting on the Line-out, giving different results?

I’ll check this.

Thank you.

So, I tested on a real Windows 10 computer (no longer using Boot Camp) and the WindowsAudioMixerMBS class gives me these results:

(the last number is the ticks, so I can monitor that the app didn’t hang. The other numbers are the properties of the WindowsAudioMixer object (code below)).
Whatever volume I set, the numbers don’t change (except the ticks).

Here’s the code, in a timer (“wam” is the WindowsAudioMixer property of the window):

if wam=nil then wam=new WindowsAudioMixerMBS

Label1.Text="DD: "+wam.DestinationDigitalVolume.ToString+EndOfLine+"DHP: "+wam.DestinationHeadPhonesVolume.ToString+EndOfLine+"DL: "+wam.DestinationLineVolume.ToString+EndOfLine+"DM: "+wam.DestinationMonitorVolume.ToString+EndOfLine+"DS: "+wam.DestinationSpeakersVolume.ToString+EndOfLine+"DT: "+wam.DestinationTelephoneVolume.ToString+EndOfLine+"DVI: "+wam.DestinationVoiceInVolume.ToString+EndOfLine+"DWI: "+wam.DestinationWaveInVolume.ToString+EndOfLine+"SA: "+wam.SourceAnalogVolume.ToString+EndOfLine+"SAU: "+wam.SourceAuxiliaryVolume.ToString+EndOfLine+"SCD: "+wam.SourceCompactDiscVolume.ToString+EndOfLine+"SD: "+wam.SourceDigitalVolume.ToString+EndOfLine+"SM: "+wam.SourceMicrophoneVolume.ToString+EndOfLine+"SPCS: "+wam.SourcePCSpeakerVolume.ToString+EndOfLine+"SS: "+wam.SourceSynthesizerVolume.ToString+EndOfLine+"ST: "+wam.SourceTelephoneVolume.ToString+EndOfLine+"SWO: "+wam.SourceWaveOutVolume.ToString+EndOfLine+System.Ticks.ToString

if wam.DestinationDigitalMute or wam.DestinationHeadPhonesMute or wam.DestinationLineMute or wam.DestinationMonitorMute or wam.DestinationSpeakersMute or wam.DestinationTelephoneMute or wam.DestinationVoiceInMute or wam.DestinationWaveInMute or wam.SourceWaveOutMute or wam.SourceTelephoneMute or wam.SourceSynthesizerMute or wam.SourcePCSpeakerMute or wam.SourceMicrophoneMute or wam.SourceLineMute or wam.SourceDigitalMute or wam.SourceCompactDiscMute or wam.SourceAuxiliaryMute or wam.SourceAnalogMute then break

Therefore, I also get wrong results here.

For the Windows 10 tests, I tried on Boot Camp, a real PC and Parallels Desktop (32 bits there).

Does this exact code give you better results?
Plugin version=21.5, if it matters.

Here’s a Xojo project showing the issue, on my server:

Could someone please try it on Windows 10 and tell me whether I’m alone with this trouble on all my computers?
I’m rather annoyed to not be trusted because it appears to work for you, Christian, but it doesn’t work on all my Windows 10 devices.

Yes, it may be a configuration thing. Maybe it only works for stereo output.

The function and classes are >10 years old and Microsoft may have changed something.

I can look again in the next days.

1 Like

Thank you.

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.