Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request - Control individual applications like in Volume mixer #18

Open
Suncatcher opened this issue Apr 9, 2018 · 23 comments
Open

Comments

@Suncatcher
Copy link

Does your cmdlet support getting info about apps that are currently active (=playing) in Windows Volume Mixer like this?
I wanna list them and get info about their volume levels.

@frgnca
Copy link
Owner

frgnca commented Apr 14, 2018

@Suncatcher No, not at this point.

@frgnca
Copy link
Owner

frgnca commented Apr 15, 2018

@Suncatcher I have started the fork dev_v3.1_communicationDevice for this enhancement request.
Until then, it IS possible with the current version to get the processID/processName, volume level, and mute state of the different applications under each audio device.
This is just a workaround, but please see the following file https://github.com/frgnca/AudioDeviceCmdlets/blob/dev_volume-mixer/dev_volume-mixer.ps1

@Suncatcher
Copy link
Author

Suncatcher commented Apr 15, 2018

Spectacular, man! Will check it soon.

@Suncatcher
Copy link
Author

Well, I tried it and found out it's not working as it intended.
Here is the output of dev_volume-mixer.ps1

App
Idle
Volume
100
Mute
False
########################

It shows Idle whilst in fact I have two apps active in mixer: System sounds and Chrome, and none of them has volume level 100.

image

@frgnca
Copy link
Owner

frgnca commented Apr 17, 2018

@Suncatcher How about with the file as it is now? Is the result the same with $deviceIndex=1
I think it was giving you the informations about the second AudioDevice which might have been the default recording device.

@frgnca
Copy link
Owner

frgnca commented Apr 18, 2018

@Suncatcher In fact, could you try the dll from the dev branch and tell me what you think?
Get-AudioSession -List
Here's what it looks like at this point
image

@Suncatcher
Copy link
Author

Well, it works not without glitches, but works and that's wonderful. About glitches:
It shows wrong level, e.g. 38% on the screenshot, when in reality it's 21%. Also It shows Idle instead of system sounds.

sketch

But all that doesn't matter for me. Could you please build a single cmdlet for this function? E.g. GetMixerVolumes or smth like that?
It's very cumbersome to type this script every time

$deviceIndex=1
########################
# Set $i to zero
$i=0

# While $i is less than the amount of audio session on the audio device
while($i -lt (Get-AudioDevice -Index $deviceIndex).Device.AudioSessionManager.Sessions.Count)
{
    Write-Host "########################"
    
    # Display audio session number
    Write-Host "Audio session #$($i + 1)"
    
    # Display processID of audio session
    Write-Host "Process name: $((Get-Process -Id (Get-AudioDevice -Index $deviceIndex).Device.AudioSessionManager.Sessions[$i].ProcessID).ProcessName)"

    # Display volume level of audio session
    Write-Host "Volume level: $(((Get-AudioDevice -Index $deviceIndex).Device.AudioSessionManager.Sessions[$i].SimpleAudioVolume.MasterVolume * 100).ToString('#'))%"

    # Display mute state of audio session
    Write-Host "Mute state:   $((Get-AudioDevice -Index $deviceIndex).Device.AudioSessionManager.Sessions[$i].SimpleAudioVolume.Mute)"

    # Increment $i
    $i++
}
Write-Host "########################"

@Suncatcher
Copy link
Author

Also, is it possible to install your module not manually but via NuGet or some automated manner? In order to be up to date when your DLL is updated.

@cdhunt
Copy link
Collaborator

cdhunt commented Apr 20, 2018

@Suncatcher We're working on getting the new version published to the PowerShell Gallery.

Old version: https://www.powershellgallery.com/packages/AudioDeviceCmdlets/

@frgnca
Copy link
Owner

frgnca commented Apr 21, 2018

@Suncatcher

It shows wrong level, e.g. 38% on the screenshot, when in reality it's 21%. Also It shows Idle instead of system sounds.

You're right. Those things have now been corrected in the dev dll.
I found out later it's because the volume level of an audio channel that the CoreAudioApi gives is in relation to the current volume level of the audio device, unlike on the GUI where it is in relation to the maximum volume level.

As for being able to install the module not manually, I will get back to you once it is updated on the PowerShell Gallery.

@Suncatcher
Copy link
Author

Thanks a ton!

@frgnca
Copy link
Owner

frgnca commented Apr 21, 2018

I can confirme the current v3.0 dll is now available from the PowerShell Gallery. When I merge in the finished volume mixer feature, I will update to v3.1 there.

PS> Save-Module -Name AudioDeviceCmdlets -Path <path>
PS> Install-Module -Name AudioDeviceCmdlets

@Suncatcher
Copy link
Author

I installed you module from PS Gallery exactly like above, but module commands are not recognized and in the exported commands I see nothing

image

Does it mean it was installed incorrectly?

@frgnca
Copy link
Owner

frgnca commented May 5, 2018

It probably means that I don't know how to properly publish to PS Gallery. I will definitely look into that when I have the time. Thank you for bringing this to my attention.

@Suncatcher
Copy link
Author

Suncatcher commented May 6, 2018

Well, I assume this is not the problem of publishing, but the problem of incorrect installation. As I said, module commands are not recognized:

 PS C:\Users\User> Get-AudioDevice -List
 Get-AudioDevice : The term 'Get-AudioDevice' is not recognized as the name of a cmdlet, function, script file, or
 operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
 again.
 At line:1 char:1
 + Get-AudioDevice -List
 + ~~~~~~~~~~~~~~~
     + CategoryInfo          : ObjectNotFound: (Get-AudioDevice:String) [], CommandNotFoundException
     + FullyQualifiedErrorId : CommandNotFoundException

What has gone wrong? I just done

PS> Save-Module -Name AudioDeviceCmdlets -Path <path>
PS> Install-Module -Name AudioDeviceCmdlets

@Suncatcher
Copy link
Author

Mmm, any suggestions? Tried to reinstall multiple times but module cmdlets are still not recognized.

@Craefter
Copy link

This link ain't working anymore: https://github.com/frgnca/AudioDeviceCmdlets/blob/dev_volume-mixer/AudioDeviceCmdlets.dll
I was looking for a way to log at regular intervals the audio volume settings of devices and applications. Reason being: Users complain about seemingly randomly changing audio settings. So I was planning on some sort of script which would generate an output trigger either by time or some sort of application event.
But, yeah, it seems like this dev tree has been deleted, am I correct?

@frgnca
Copy link
Owner

frgnca commented Sep 21, 2018

Correct. I still plan on adding this feature and merge it with future version v3.1 but I am currently in the process of moving places so I might not be able to code for this project for a bit.

@Craefter
Copy link

Craefter commented Sep 21, 2018 via email

@smmalis37
Copy link

Any update here?

@JuzioMiecio520
Copy link

Bump, any update? This feature would be awesome

@God-damnit-all
Copy link

Windows 10 (and presumably 11) has the ability to set what audio devices that individual apps listen to. For some reason, however, it resets often for me. If AudioDeviceCmdlets had the ability to set this, I could set up a script to run with Task Scheduler to make sure my apps are set correctly.

@frgnca frgnca changed the title Individual apps in volume mixer Feature request - Control individual applications like in Volume mixer Jan 29, 2023
@red-daut
Copy link

I know this is over a year old, but I am very interested in having this added.

Any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants