Rendering audio using wasapi (loopback) - capturing the speakers & Volume

Started by
-1 comments, last by Timi11 9 years, 2 months ago

I capture all sounds using wasapi loopback using this code: https://github.com/rdp/directshow-demo-audio-input-open-source/blob/master/acam/loopback-capture.cpp

And save it to a file. Everything works. Problem is that I want it to work while the computer speakers will not produce any sound. So I use: mEndpointVolume->SetMasterVolumeLevelScalar((float)0, NULL);

To set Master volume to 0. Seems that it should make wasapi playback to not work as i want (i.e to capture silent only since I set the master volume to 0 which is not what i want), BUT this does not happen. It works as I want. I.E wasapi captures the speakers sounds AND PC speakers do not make any sounds.

Also, seems that changing the master volume does not change the volume of what is captured by wasapi (only changing the sounds from the application the make the sounds - for example Media Player, change the volume of the sounds wasapi capture) - as i want.

Everything good - this is what i want (I want that nothing will be heard on the PC speakers and I want that changing the master volume (the volume of the speakers) will have not effect on the volume of the sounds wasapi captures).

Problem: But on another computer (asus) Setting master volume to 0 using SetMasterVolumeLevelScalar does change the volume of the sounds wasapi captures... Also changing the master volume change as well the volume of the sounds wasapi captures...

I need advice how to make what i want to work on all computers. I.E to capture all computer sounds using wasapi loopback (already have this) but that nothing will be heard on PC speakers and that when user change the Master volume that this will have no effect on the wasapi capturing volume.

What I do know (not sure if that is the cause) is that calling mEndpointVolume->QueryHardwareSupport(&dwMask) gives dwMask=2 on the computer that works as I want ( ENDPOINT_HARDWARE_SUPPORT_MUTE The audio endpoint device supports a hardware mute control.)

BUT gives dwMask=7 which is combination of all three below on the computer where it does not work as I want.

ENDPOINT_HARDWARE_SUPPORT_VOLUME The audio endpoint device supports a hardware volume control.

ENDPOINT_HARDWARE_SUPPORT_MUTE The audio endpoint device supports a hardware mute control.

ENDPOINT_HARDWARE_SUPPORT_METER The audio endpoint device supports a hardware peak meter.

Thanks for helping in this.

This topic is closed to new replies.

Advertisement