frgnca / AudioDeviceCmdlets

AudioDeviceCmdlets is a suite of PowerShell Cmdlets to control audio devices on Windows
MIT License
764 stars 92 forks source link

Question: How to get a single value from PlaybackStream #47

Closed edvinasdi closed 2 years ago

edvinasdi commented 2 years ago

Hi,

Im, like, very new on PowerShell scripts and would like to know if it's possible to get a single value from Write-AudioDevice -PlaybackStream command so I can use it afterwards to create a condition showing if something is playing or not and construct an if statement of it.

frgnca commented 2 years ago

would like to know if it's possible to get a single value from Write-AudioDevice -PlaybackStream

No, not that I know of by using the Write-AudioDevice cmdlet.

frgnca commented 2 years ago

But it seems possible to get that single value by using the Get-AudioDevice cmdlet in the following way

[int]$Output = (Get-AudioDevice -Playback).Device.AudioMeterInformation.MasterPeakValue * 100

which, by the way, is basically what the Write-AudioDevice cmdlet does in a loop on a 100ms sleep timer.