pyWinCoreAudio icon indicating copy to clipboard operation
pyWinCoreAudio copied to clipboard

Switch process to another device

Open DamienStaebler opened this issue 3 years ago • 10 comments

Hi, Thanks for the awesome library. I am curious if there any way to route process to another device? In Win10 under mixer you can see that your able to change app's output/input device.

DamienStaebler avatar Mar 12 '22 07:03 DamienStaebler

I am not sure what you mean.

kdschlosser avatar Mar 12 '22 21:03 kdschlosser

I also have a newer version of the library that runs on python 3. I also reworked the API so it's much easier to use. I also fixed some memory leaks as well.

It's in the develop branch

kdschlosser avatar Mar 12 '22 21:03 kdschlosser

image You see discord have audio output

DamienStaebler avatar Mar 12 '22 23:03 DamienStaebler

I want to be able to switch Output device per application

DamienStaebler avatar Mar 12 '22 23:03 DamienStaebler

you want to be able to control the volume of another application?

I haven't tried doing that. if you register to get a callback for a stream being created/destroyed you might be able to change the volume of the stream. I would have to mess about with it to see if it can be done.

kdschlosser avatar Mar 17 '22 16:03 kdschlosser

you want to be able to control the volume of another application?

I haven't tried doing that. if you register to get a callback for a stream being created/destroyed you might be able to change the volume of the stream. I would have to mess about with it to see if it can be done.

Well change the output device of each application

DamienStaebler avatar Mar 17 '22 17:03 DamienStaebler

The only way you can alter the output device is if you set the application to use the default audio endpoint and then using this library you would change the default audio endpoint to whatever it is you want the audio to be output from.

Unfortunately there is no API to redirect another programs audio output to a different endpoint. Now I am not saying there is a way as I am sure there is, I believe you can do what you are looking to do by using the loopback sound device and looping the audio back and then send it back out to the endpoint you want. Problem is Python is simply too slow to be able to do this.

kdschlosser avatar Mar 17 '22 17:03 kdschlosser

The only way you can alter the output device is if you set the application to use the default audio endpoint and then using this library you would change the default audio endpoint to whatever it is you want the audio to be output from.

Unfortunately there is no API to redirect another programs audio output to a different endpoint. Now I am not saying there is a way as I am sure there is, I believe you can do what you are looking to do by using the loopback sound device and looping the audio back and then send it back out to the endpoint you want. Problem is Python is simply too slow to be able to do this.

I found this It seems like there is a way using policyconfig https://github.com/Belphemur/SoundSwitch/blob/4ae9d0c6a8dc7cb2f7cf62d8ab8d8ca11d50830c/SoundSwitch.Audio.Manager/AudioSwitcher.cs#L109

DamienStaebler avatar Mar 17 '22 21:03 DamienStaebler

OK that is only going to work on Windows 10 version 1803 or newer.

I am looking into it because I am not able to locate the class ids in my registry nor can I locate the the .NET class "Windows.Media.Internal.AudioPolicyConfig".

I have added code to see if I can get it to work. we will see what happens.

kdschlosser avatar Mar 19 '22 06:03 kdschlosser

Any luck on this?

DamienStaebler avatar Mar 28 '22 17:03 DamienStaebler