It is currently June 29th, 2022, 3:24 pm

Adjust Mic Volume Level?

Get help with creating, editing & fixing problems with skins
User avatar
sl23
Posts: 1015
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Adjust Mic Volume Level?

Post by sl23 »

There is a small issue, when scrolling down, and you're on the last device, it produces this error in the log:

Code: Select all

System.Management.Automation.CmdletInvocationException: No AudioDevice with that Index ---> System.ArgumentException: No AudioDevice with that Index
   at AudioDeviceCmdlets.GetAudioDevice.ProcessRecord()
   at System.Management.Automation.CommandProcessor.ProcessRecord()
   --- End of inner exception stack trace ---
   at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
   at PowershellRM.Measure.Invoke() (Rounded\RoundVolume\RoundVolume_1.ini - [NextInputIndex])
Is there a way to stop this? I'm not worried if not, as it's only a minor thing. I mean, how many times are you likely to keep scrolling down once you know that's the last device?!
User avatar
Yincognito
Rainmeter Sage
Posts: 4724
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Adjust Mic Volume Level?

Post by Yincognito »

sl23 wrote: May 15th, 2022, 11:00 am There is a small issue, when scrolling down, and you're on the last device, it produces this error in the log:

Code: Select all

System.Management.Automation.CmdletInvocationException: No AudioDevice with that Index ---> System.ArgumentException: No AudioDevice with that Index
   at AudioDeviceCmdlets.GetAudioDevice.ProcessRecord()
   at System.Management.Automation.CommandProcessor.ProcessRecord()
   --- End of inner exception stack trace ---
   at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
   at PowershellRM.Measure.Invoke() (Rounded\RoundVolume\RoundVolume_1.ini - [NextInputIndex])
Is there a way to stop this? I'm not worried if not, as it's only a minor thing. I mean, how many times are you likely to keep scrolling down once you know that's the last device?!
Sorry for not responding, I must have either missed the mail alert for this or forgot to respond. The solution is very simple, just enclose the related commands / line into a try {...} block and add a catch {} to it, since the latter is required even if not used. See details about it here.

In other words, set a line like this:

if ($(Get-AudioDevice -Index $($($(Get-AudioDevice -Playback).Index) + $Offset)).Type -eq "Playback") {Set-AudioDevice -Index $($($(Get-AudioDevice -Playback).Index) + $Offset)}

from the Set-OutputIndex function the .PS1 script to something like:

try {if ($(Get-AudioDevice -Index $($($(Get-AudioDevice -Playback).Index) + $Offset)).Type -eq "Playback") {Set-AudioDevice -Index $($($(Get-AudioDevice -Playback).Index) + $Offset)}} catch {}

I know you need it for the input aka "Recording" equivalent function that follows, but that's easy enough to type it yourself, without pasting. :D
User avatar
sl23
Posts: 1015
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Adjust Mic Volume Level?

Post by sl23 »

No problem, better late than never!!! :D

Thanks for the solution, that solved it :thumbup:
User avatar
Yincognito
Rainmeter Sage
Posts: 4724
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Adjust Mic Volume Level?

Post by Yincognito »

sl23 wrote: June 11th, 2022, 3:14 pm No problem, better late than never!!! :D

Thanks for the solution, that solved it :thumbup:
Excellent! :great: