kdschlosser / pyWinCoreAudio

Python Windows Core Audio API
GNU General Public License v2.0
35 stars 9 forks source link

Using #2

Open renato-caruso opened 4 years ago

renato-caruso commented 4 years ago

Sorry for my ignorance, but how can I use this to control an application volume like the Windows Mixer Volume GUI?

I'm making a 'sound table' ... I already develop with Arduino and I already have my control device ready, but I want to interact with the windows mixer, and I wanted to do it with python ...

kdschlosser commented 4 years ago

well that depends on how you want to interact with the sound mixer. You have the capabilities of altering endpoints which would be speakers, headphones, microphones, etc...

You will not have the ability to alter sessions. so if you see a volume slider for say Firefox or Google. These are controlled by the application and cannot be changed by another process. This is done as a protection so applications cannot hijack another applications sound session.

The Windows Core Audio API is mostly geared to what you see in the sound control panel. So you have the ability to set channel volumes and set the master volume. get events for when the volume changes. I do manage to locate a hole in the core audio api that does allow me to get events when changes are made to a sessions volume or when a session starts and stops audio playback and also when a session gets created or destroyed.

you also have access to the peak meter which is a good mechanism to be able to tell if there is actually audio being played to an output or being received from an audio input like a microphone.

How familiar are you with Python and programming?? This is going to let me know what your experience is so I use verbage that will be better understood.

renato-caruso commented 4 years ago

I study Python in college and develop web with Ruby, PHP and JavaScript. If with this package there is no possibility to change the volume of an application, I will not be able to do what I expected. Do you know if it could be in .NET Windows SDK? Probably not, I understood the vulnerability ... Can you imagine a way to be able to control audio sessions through an application? Would a driver be needed?

kdschlosser commented 4 years ago

Windows API .NET or C does not provide any way of controlling the volume of a session that another application created. Not saying there is not a way to do it. I do not know of it if there is one.