C++ Winapi waveOutSetVolume()

3.9k views Asked by At

I want to change the master volume with the function

MMRESULT waveOutSetVolume(
  HWAVEOUT hwo, 
  DWORD dwVolume 
); 

hwo
Handle to an open waveform-audio output device. This parameter can also be a device identifier. 

How do I create a handler for the Master Volume?

dwVolume
Specifies a new volume setting. The low-order word contains the left-channel volume setting, and the high-order word contains the right-channel setting. A value of 0xFFFF represents full volume, and a value of 0x0000 is silence.
If a device does not support both left and right volume control, the low-order word of dwVolume specifies the volume level, and the high-order word is ignored.

How do I pass the Volume (for example 75) to the function?

Trying it like this : How to change master volume programmatically? doesnt't work for me!

1

There are 1 answers

2
Roman Ryltsov On BEST ANSWER

There is no master volume change in Vista+ through legacy waveOutXxx API. Use WASAPI instead:

If a device has a hardware volume control, changes made to the control through the IAudioEndpointVolume interface affect the volume level both in shared mode and in exclusive mode. If a device lacks hardware volume and mute controls, changes made to the software volume and mute controls through this interface affect the volume level in shared mode, but not in exclusive mode. In exclusive mode, the application and the audio hardware exchange audio data directly, bypassing the software controls.