sl23 wrote: ↑May 10th, 2022, 8:11 pm
Although, in theory, this seems to work, it doesn't. I found that in the About/Skins window, the String for this doesn't change either. If the Mic is plugged in, then removed, the String changes to reflect this. But plug the Mic back in, and it doesn't trigger anything in the String, so it seems it isn't detected as a change?! Why?
EDIT: From what I can see, it appears to be a fault or limitation of the AudioLevel plugin. It doesn't seem to have the option to detect the Default Device. If it did, it would solve the problem, as Windows Control Panel Sound Settings Applet shows the default Device change back and forth between Mic and Stereo Mix each time you unplug/plug in the Mic.
I believe you encountered the fault / limitation / bug that I also encountered
here, in one of the skins of my suite. I wasn't using the device status like you did, but there were still things from the AudioLevel plugin. So yeah, it doesn't quite update things properly on switching back and forth between devices. But then, AudioDeviceCmdlets would be happy to leak some memory in helping you out with this though, I reckon...
sl23 wrote: ↑May 10th, 2022, 8:46 pmThis was what I originally hoped for when I first designed this skin. I have to admit, I'm a bit wary about trying your code due to your previous caution...
Would what you suggested just above be fine to use as a selection method? Or is this the 'forced' method you stated wasn't healthy?
Yeah, I meant forcing wouldn't be healthy, e.g. interfering with the 'normal' automatic switching of the active / default devices to force some particular device to always be the one to be active / default (even against other legit changes the user might operate from Settings and such).
Well, it would have been nice to describe your intentions right from the start - at least from my point of view. I mean, you probably realized by now that I'm quite open to challenges and making things work even - or better said, especially - when the odds are against that objective, but I have a slight problem in constantly adjusting the code to match ever changing goals. I prefer to aim to achieve something no matter how ambitious, instead of doing X and finding out Y is desired, then doing Y and finding out it's actually Z that's better suited, and so on. I'm sure you get the idea.
That being said, on a purely theoretical level, this shouldn't be too hard to achieve, though it might possibly involve some regex kung-fu and some well constructed interrogation system if it's about indexes. Basically, you'd need to:
1) get the entire list of devices in a RunCommand measure similar to what you already have in
[GetAudio], but via
Get-AudioDevice -List, optionally 'filtering' them to get only the indexes of the recording ones by using something like
Get-AudioDevice -List | where Type -like "*Recording*" | select Index | sort Index | format-list, in order to find out the values such an index could take
2) use the output above to count how many indexes there are, by:
- duplicating the said output in a String measure similar to how
[GetAudio] is duplicated in the code you already have and transforming it via a Substitute like
"\s+\d+(?:\s+$)?":"+1"
- use the "+1+1...+1" string output of the previous String measure to calculate the index count in a Calc measure
3) get the index iterator by applying a Substitute like
"(?siU)^.*(?:\s*\d+\s*?){0,#IndexToGetMinusOne#}+\s*(\d+)\s*?.*$":"\1" to a String measure that takes the output at 1) as the value of its
String= option, while your
#IndexToGetMinusOne# variable can be decremented or incremented via mouse actions within the
0 to
IndexesCountMinusOne interval (the indexes count being the value given by the Calc measure at step 2) above)
4) set the device index in a RunCommand measure, via
Set-AudioDevice -Index #Iterator#, where
#Iterator# is the variable equivalent of the iterator measure at 3), since PowershellRM doesn't like measure or nested variable syntax aka square brackets in commands
Yep, I know, not that easy, but not that hard either - besides the regexes I already built for you, it's all just basic Rainmeter stuff.
sl23 wrote: ↑May 10th, 2022, 7:47 pm
I did try this yesterday, but was too tired to reply...
Code: Select all
function Get-InputVolume
{
if ($(Get-AudioDevice -Recording).Name -like "*Microphone*") {return Get-AudioDevice -RecordingVolume}
}
I gave up as I'm back to square one trying to identify the device using PS code! Nothing seems to work for some reason?!
I have no idea why your PS is against you, since for me it works every freaking time:
AudioListNavigation.jpg
I used this slightly modified version of the script, that yields 5% or 5 if "*Microphone*" is not the default device, in order to not break or having to change the substitutes due to missing elements (which would be the case if we returned nothing):
Code: Select all
Import-Module -Name "$($RmAPI.VariableStr('@'))Addons\AudioDeviceCmdlets"
function Get-OutputVolume
{
return Get-AudioDevice -PlaybackVolume
}
function Get-InputVolume
{
# return Get-AudioDevice -RecordingVolume
if ($(Get-AudioDevice -Recording).Name -like "*Microphone*") {return Get-AudioDevice -RecordingVolume} else {return "5%"}
}
function Get-OutputMute
{
if (Get-AudioDevice -PlaybackMute) {return 1} else {return 0}
}
function Get-InputMute
{
# if (Get-AudioDevice -RecordingMute) {return 1} else {return 0}
if ($(Get-AudioDevice -Recording).Name -like "*Microphone*") {if (Get-AudioDevice -RecordingMute) {return 1} else {return 0}} else {return 5}
}
function Set-OutputVolume
{
[CmdletBinding()]param([Parameter(Mandatory)][float]$Volume)
Set-AudioDevice -PlaybackVolume $Volume
}
function Set-InputVolume
{
# [CmdletBinding()]param([Parameter(Mandatory)][float]$Volume)
# Set-AudioDevice -RecordingVolume $Volume
[CmdletBinding()]param([Parameter(Mandatory)][float]$Volume)
if ($(Get-AudioDevice -Recording).Name -like "*Microphone*") {Set-AudioDevice -RecordingVolume $Volume}
}
function Set-OutputMute
{
[CmdletBinding()]param([Parameter(Mandatory)][byte]$State)
switch($State)
{
0 {Set-AudioDevice -PlaybackMute $false}
1 {Set-AudioDevice -PlaybackMute $true}
}
}
function Set-InputMute
{
# [CmdletBinding()]param([Parameter(Mandatory)][byte]$State)
# switch($State)
# {
# 0 {Set-AudioDevice -RecordingMute $false}
# 1 {Set-AudioDevice -RecordingMute $true}
# }
[CmdletBinding()]param([Parameter(Mandatory)][byte]$State)
if ($(Get-AudioDevice -Recording).Name -like "*Microphone*")
{
switch($State)
{
0 {Set-AudioDevice -RecordingMute $false}
1 {Set-AudioDevice -RecordingMute $true}
}
}
}
As you can see in the screenshot, I just set the audio device index to my TV Tuner audio in (index 2), and the skin gladly set both the input values to 5...
You do not have the required permissions to view the files attached to this post.