frgnca / AudioDeviceCmdlets

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

Default Communication Device #30

Closed frgnca closed 2 years ago

frgnca commented 5 years ago

Should be able to support

TODO:

DONE:

bool AudioDevice.DefaultCommunication

Get-AudioDevice -PlaybackCommunication      # Get the default communication playback device as <AudioDevice>
Get-AudioDevice -PlaybackCommunicationMute  # Get the default communication playback device's mute state as <bool>
Get-AudioDevice -PlaybackCommunicationVolume    # Get the default communication playback device's volume level on 100 as <float>
Get-AudioDevice -RecordingCommunication     # Get the default communication recording device as <AudioDevice>
Get-AudioDevice -RecordingCommunicationMute # Get the default communication recording device's mute state as <bool>
Get-AudioDevice -RecordingCommunicationVolume   # Get the default communication recording device's volume level on 100 as <float>

Set-AudioDevice <AudioDevice> -CommunicationOnly    # Set the given playback/recording device as the default communication device and not the default device, for its type
Set-AudioDevice <AudioDevice> -DefaultOnly      # Set the given playback/recording device as the default device and not the default communication device, for its type
Set-AudioDevice -ID <string> -CommunicationOnly     # Set the device with the ID corresponding to the given <string> as the default communication device and not the default device, for its type
Set-AudioDevice -ID <string> -DefaultOnly       # Set the device with the ID corresponding to the given <string> as the default device and not the default communication device, for its type
Set-AudioDevice -Index <int> -CommunicationOnly     # Set the device with the Index corresponding to the given <int> as the default communication device and not the default device, for its type
Set-AudioDevice -Index <int> -DefaultOnly       # Set the device with the Index corresponding to the given <int> as the default device and not the default communication device, for its type
Set-AudioDevice -PlaybackCommunicationMuteToggle    # Set the default communication playback device's mute state to the opposite of its current mute state
Set-AudioDevice -PlaybackCommunicationMute <bool>   # Set the default communication playback device's mute state to the given <bool>
Set-AudioDevice -PlaybackCommunicationVolume <float>    # Set the default communication playback device's volume level on 100 to the given <float>
Set-AudioDevice -RecordingCommunicationMuteToggle   # Set the default communication recording device's mute state to the opposite of its current mute state
Set-AudioDevice -RecordingCommunicationMute <bool>  # Set the default communication recording device's mute state to the given <bool>
Set-AudioDevice -RecordingCommunicationVolume <float>   # Set the default communication recording device's volume level on 100 to the given <float>

Write-AudioDevice -PlaybackCommunicationMeter   # Write the default playback device's power output on 100 as a meter
Write-AudioDevice -PlaybackCommunicationStream  # Write the default playback device's power output on 100 as a stream of <int>
Write-AudioDevice -RecordingCommunicationMeter  # Write the default recording device's power output on 100 as a meter
Write-AudioDevice -RecordingCommunicationStream # Write the default recording device's power output on 100 as a stream of <int>
stjiub commented 4 years ago

Any chance of this getting merged into master and rebuilt for download? I really need this feature and am having trouble building this branch from source.

ImTheRedDevil commented 4 years ago

This is exactly what I need, would be very nice if it could be merged and rebuilt since I'm having trouble building this as well.

Andargor commented 4 years ago

@stjiub @ImTheRedDevil I've managed to build it by adding the following in Project > Reference > Browse button at bottom:

C:\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell\3.0\System.Management.Automation.dll

If you are having difficulty with Uninstall-Module or Remove-Module to remove a previous version, open up a cmd shell (not powershell) and run:

powershell -NoProfile -Command "& {Get-Module -ListAvailable -Name 'AudioDeviceCmdlets' | Remove-Module -Force -Verbose}"

I had trouble removing the module when installed using the README, since it is auto-loading. Hence, using cmd without a profile prevents the auto-load and it gets removed.

HTH

telnetdoogie commented 3 years ago

@cdhunt Can we get this merged into master? Would love to see this in the latest build.

oddbear commented 3 years ago

There seems to be a bug in this code: WriteObject(new AudioDevice(i + 1, DeviceCollection[i], true));

If I understand this correctly, the true boolean will flag it to be the default playback/recording device.

The logical choice for me would be to extend the AudioDevice class to have both a Default and DefaultCommunication boolean, or a enum for defaults.

Ghost-Terms commented 2 years ago

I recommend changing 'Windows PowerShell' to 'PowerShell on Windows'. Ever since they dropped the 'Core' suffix from PowerShell 6+, they've been saying 'Windows PowerShell' to refer to PowerShell 5.1 specifically.

frgnca commented 2 years ago

I recommend changing 'Windows PowerShell' to 'PowerShell on Windows'. Ever since they dropped the 'Core' suffix from PowerShell 6+, they've been saying 'Windows PowerShell' to refer to PowerShell 5.1 specifically.

Thank you @ImportTaste I did not know that. I'll try to read up a bit more on this.