AudioDeviceCmdlets icon indicating copy to clipboard operation
AudioDeviceCmdlets copied to clipboard

Feature request - Control individual applications like in Volume mixer

Open Suncatcher opened this issue 6 years ago • 23 comments

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.

Suncatcher avatar Apr 09 '18 08:04 Suncatcher

@Suncatcher No, not at this point.

frgnca avatar Apr 14 '18 15:04 frgnca

@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

frgnca avatar Apr 15 '18 19:04 frgnca

Spectacular, man! Will check it soon.

Suncatcher avatar Apr 15 '18 19:04 Suncatcher

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

Suncatcher avatar Apr 17 '18 15:04 Suncatcher

@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 avatar Apr 17 '18 22:04 frgnca

@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

frgnca avatar Apr 18 '18 23:04 frgnca

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 avatar Apr 20 '18 19:04 Suncatcher

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.

Suncatcher avatar Apr 20 '18 19:04 Suncatcher

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

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

cdhunt avatar Apr 20 '18 20:04 cdhunt

@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.

frgnca avatar Apr 21 '18 04:04 frgnca

Thanks a ton!

Suncatcher avatar Apr 21 '18 07:04 Suncatcher

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

frgnca avatar Apr 21 '18 21:04 frgnca

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?

Suncatcher avatar May 05 '18 17:05 Suncatcher

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.

frgnca avatar May 05 '18 17:05 frgnca

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 avatar May 06 '18 07:05 Suncatcher

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

Suncatcher avatar May 26 '18 17:05 Suncatcher

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?

Craefter avatar Sep 21 '18 10:09 Craefter

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.

frgnca avatar Sep 21 '18 13:09 frgnca

Do you still have that mentioned .dll for me to play around with until that time? :)

On Fri, Sep 21, 2018 at 3:31 PM frgnca [email protected] wrote:

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.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/frgnca/AudioDeviceCmdlets/issues/18#issuecomment-423531698, or mute the thread https://github.com/notifications/unsubscribe-auth/ApdNXHkIcCHZtZSDukgek4d4NtG57rVHks5udOoqgaJpZM4TMKJV .

Craefter avatar Sep 21 '18 13:09 Craefter

Any update here?

smmalis37 avatar Sep 12 '21 19:09 smmalis37

Bump, any update? This feature would be awesome

JuzioMiecio520 avatar Oct 25 '22 17:10 JuzioMiecio520

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.

God-damnit-all avatar Oct 28 '22 14:10 God-damnit-all