I want to set the volume of an audio endpoint like in windows directly from 0 to 100
public override void SetVolume(int volume) {
NativeInterfaces.IMMDeviceEnumerator enumerator = NativeClasses.ComObjectFactory.CreateInstance(new Guid(NativeGuids.MM_DEVICE_ENUMERATOR)) as NativeInterfaces.IMMDeviceEnumerator;
enumerator.GetDefaultAudioEndpoint(
NativeEnums.EDataFlow.eCapture | NativeEnums.EDataFlow.eRender,
NativeEnums.ERole.eConsole,
out NativeInterfaces.IMMDevice device
);
device.Activate(new Guid(NativeGuids.I_AUDIO_ENDPOINT_VOLUME), 0x1, IntPtr.Zero, out object volumeObj);
NativeInterfaces.IAudioEndpointVolume audioEndpointVolume = volumeObj as NativeInterfaces.IAudioEndpointVolume;
audioEndpointVolume.SetMasterVolumeLevelScalar(volume / 100.0f, new Guid());
}
When I run this code my volume is still on 50 although I passed 60 as a parameter. When I call GetMasterVolumeLevelScalar it outputs 0.6 so the code worked but it seems like I use the wrong method. So how to set between 0 and 100?
