It is currently April 26th, 2024, 11:34 pm

Adjust Mic Volume Level?

Get help with creating, editing & fixing problems with skins
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: Adjust Mic Volume Level?

Post by death.crafter »

Yincognito wrote: August 14th, 2021, 7:18 pm Still nothing is shown though. EDIT: Ran it the 2nd time and it does show stuff, but it doesn't show my AMD HDMI Output for the output and it doesn't select (although it's shown in the context menu) my Analog Audio In (AverMedia H830 USB Hybrid DVB-T) (plugged in, but not running, TV Tuner device) for the input.
That is internal functions of cmdlet I guess. If you can select the device using powershell then I will look more in to it.
from the Realm of Death
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Adjust Mic Volume Level?

Post by Yincognito »

death.crafter wrote: August 14th, 2021, 7:36 pm That is internal functions of cmdlet I guess. If you can select the device using powershell then I will look more in to it.
Yeah, I can't make it the default in PS either:
InDefault.jpg
Maybe the tuner needs to be running for that, I don't know. Even if it did and it would work, making it the deafult would make little sense as it's set to be recorded from by the tuner software anyway, and back in Windows the mic should be the default.

EDIT: Just tested and the above command doesn't work, even if I start the TV tuner. Have no idea what that might be, but then, it's not terribly important... :confused:

EDIT2: Not sure if this helps (maybe some connection with other errors?), but I tried to delete the module DLL with Rainmeter still running (no audio skins active though) and it didn't work. Only after closing Rainmeter I was able to delete the file.
You do not have the required permissions to view the files attached to this post.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Adjust Mic Volume Level?

Post by sl23 »

Sorry for jumping in, but could you please help with this:
Using jsmorley's skin, how do I remove the scroll actions from the SliderBar? I have the Scroll actions working but I have to include code that I don't need.
Another problem I'm trying to solve, is the Left and Right click to set the Mic Volume at 25 and 80 respectively.

Code: Select all

[DeviceVolume]
Measure=Plugin
Plugin=PowershellRM
ScriptFile=DeviceVolume.ps1

[InputVolume]
Measure=Plugin
Plugin=PowershellRM
Parent=DeviceVolume
Line=Get-Volume -Type Input
IfCondition=InputVolume = -1
IfTrueAction=[!SetOption MicIcon Text "[\xE720]"][!SetOption MicVolumeText Text "Muted"][!UpdateMeter *][!Redraw]
IfFalseAction=[!SetOption MeterInputSlider X "(([InputVolume:] * (200 - 20) / 100) + 20)"][!SetOption MicVolumeText Text "[*MeasureInputPercent:%,0*]"][!UpdateMeter *][!Redraw]
IfCondition2=InputVolume = 0
IfTrueAction2=[!SetOption MicIcon Text "[\xE720]"]
IfCondition3=(InputVolume > 0) && (InputVolume <= 35)
IfTrueAction3=[!SetOption MicIcon Text "[\xE720]"]
IfCondition4=(InputVolume > 35) && (InputVolume <= 65)
IfTrueAction4=[!SetOption MicIcon Text "[\xE720]"]
IfCondition5=InputVolume > 65
IfTrueAction5=[!SetOption MicIcon Text "[\xE720]"]
IfConditionMode=1
Substitute="-1":"Muted","1.000001":"1","2.999999":"3","9.000001":"9"

[MeasureInputMouse]
Measure=Plugin
Plugin=Mouse
RelativeToSkin=1
RequireDragging=1
DynamicVariables=1

[MeasureInputPercent]
Measure=Calc
Formula=[MeterInputSlider:X]
MinValue=20
MaxValue=200
DynamicVariables=1
OnChangeAction=[!SetVariable InputVolume "([MeasureInputPercent:%,0])"][!CommandMeasure DeviceVolume "Set-InputVolume"]

[MicVolumeText]
Meter=String
MeasureName=InputVolume
MeterStyle=sAllText
FontColor=#Color2#
Text=%1
Percentual=1
NumOfDecimals=0
Hidden=1
Group=Input
X=197
Y=27

[InputRoundBar]
Meter=Roundline
MeasureName=MeasureInputPercent
MeterStyle=sRoundBar
LineColor=#Color2#
LineWidth=4
Solid=0
Hidden=1
Group=Input
X=197
Y=37

==========================================



[MeterInputSlideBar]
Meter=Shape
X=20
Y=80
Shape=Rectangle 0,0,200,10,5 | Fill Color 150,150,150,255 | StrokeWidth 0
Shape2=Rectangle 0,0,[MeterInputSlider:X],10,5 | Fill Color 56,150,51,255 | StrokeWidth 0
DynamicVariables=1
MouseScrollUpAction=[!SetVariable InputVolume "(Clamp(#InputVolume#-5,0,100))"][!CommandMeasure DeviceVolume "Set-InputVolume"][!Update]
MouseScrollDownAction=[!SetVariable InputVolume "(Clamp(#InputVolume#+5,0,100))"][!CommandMeasure DeviceVolume "Set-InputVolume"][!Update]

[MeterInputSlider]
Meter=Shape
Y=75
Shape=Ellipse 10,10,10,10 | Fill Color 106,222,100,255 | StrokeWidth 0
LeftMouseDownAction=[!CommandMeasure MeasureInputMouse "Start"]
It's basically those last 2 Sections. I want to remove them, but can't due to formulas and such referencing them in some way. Everything I try just breaks the whole MicInput measuring part of the skin! :?
- MuLab -
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Adjust Mic Volume Level?

Post by Yincognito »

sl23 wrote: August 14th, 2021, 8:21 pm Sorry for jumping in, but could you please help with this:

Code: Select all

[DeviceVolume]
Measure=Plugin
Plugin=PowershellRM
ScriptFile=DeviceVolume.ps1

[InputVolume]
Measure=Plugin
Plugin=PowershellRM
Parent=DeviceVolume
Line=Get-Volume -Type Input
IfCondition=InputVolume = -1
IfTrueAction=[!SetOption MicIcon Text "[\xE720]"][!SetOption MicVolumeText Text "Muted"][!UpdateMeter *][!Redraw]
IfFalseAction=[!SetOption MeterInputSlider X "(([InputVolume:] * (200 - 20) / 100) + 20)"][!SetOption MicVolumeText Text "[*MeasureInputPercent:%,0*]"][!UpdateMeter *][!Redraw]
IfCondition2=InputVolume = 0
IfTrueAction2=[!SetOption MicIcon Text "[\xE720]"]
IfCondition3=(InputVolume > 0) && (InputVolume <= 35)
IfTrueAction3=[!SetOption MicIcon Text "[\xE720]"]
IfCondition4=(InputVolume > 35) && (InputVolume <= 65)
IfTrueAction4=[!SetOption MicIcon Text "[\xE720]"]
IfCondition5=InputVolume > 65
IfTrueAction5=[!SetOption MicIcon Text "[\xE720]"]
IfConditionMode=1
Substitute="-1":"Muted","1.000001":"1","2.999999":"3","9.000001":"9"

[MeasureInputMouse]
Measure=Plugin
Plugin=Mouse
RelativeToSkin=1
RequireDragging=1
DynamicVariables=1

[MeasureInputPercent]
Measure=Calc
Formula=[MeterInputSlider:X]
MinValue=20
MaxValue=200
DynamicVariables=1
OnChangeAction=[!SetVariable InputVolume "([MeasureInputPercent:%,0])"][!CommandMeasure DeviceVolume "Set-InputVolume"]

[MicVolumeText]
Meter=String
MeasureName=InputVolume
MeterStyle=sAllText
FontColor=#Color2#
Text=%1
Percentual=1
NumOfDecimals=0
Hidden=1
Group=Input
X=197
Y=27

[InputRoundBar]
Meter=Roundline
MeasureName=MeasureInputPercent
MeterStyle=sRoundBar
LineColor=#Color2#
LineWidth=4
Solid=0
Hidden=1
Group=Input
X=197
Y=37

==========================================



[MeterInputSlideBar]
Meter=Shape
X=20
Y=80
Shape=Rectangle 0,0,200,10,5 | Fill Color 150,150,150,255 | StrokeWidth 0
Shape2=Rectangle 0,0,[MeterInputSlider:X],10,5 | Fill Color 56,150,51,255 | StrokeWidth 0
DynamicVariables=1
MouseScrollUpAction=[!SetVariable InputVolume "(Clamp(#InputVolume#-5,0,100))"][!CommandMeasure DeviceVolume "Set-InputVolume"][!Update]
MouseScrollDownAction=[!SetVariable InputVolume "(Clamp(#InputVolume#+5,0,100))"][!CommandMeasure DeviceVolume "Set-InputVolume"][!Update]

[MeterInputSlider]
Meter=Shape
Y=75
Shape=Ellipse 10,10,10,10 | Fill Color 106,222,100,255 | StrokeWidth 0
LeftMouseDownAction=[!CommandMeasure MeasureInputMouse "Start"]
It's basically those last 2 Sections. I want to remove them, but can't due to formulas and such referencing them in some way. Everything I try just breaks the whole MicInput measuring part of the skin! :?
Something along these lines (I literally deleted everything, LOL), and then create or recreate whatever stuff you want to add back, and adjust them properly:

Code: Select all

[DeviceVolume]
Measure=Plugin
Plugin=PowershellRM
ScriptFile=DeviceVolume.ps1

[InputVolume]
Measure=Plugin
Plugin=PowershellRM
Parent=DeviceVolume
Line=Get-Volume -Type Input
Substitute="-1":"Muted","1.000001":"1","2.999999":"3","9.000001":"9"
MinValue=0
MaxValue=100

[MicVolumeText]
Meter=String
MeasureName=InputVolume
MeterStyle=sAllText
FontColor=#Color2#
Text=%1
Percentual=1
NumOfDecimals=0
Hidden=1
Group=Input
X=197
Y=27

[InputRoundBar]
Meter=Roundline
MeasureName=InputVolume
MeterStyle=sRoundBar
LineColor=#Color2#
LineWidth=4
Solid=0
Hidden=1
Group=Input
X=197
Y=37
For something more, it's up to jsmorley to have a say on it, as it's his code and such. ;-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Adjust Mic Volume Level?

Post by sl23 »

Thank you for fixing that :thumbup:
- MuLab -
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Adjust Mic Volume Level?

Post by Yincognito »

sl23 wrote: August 14th, 2021, 9:11 pm Thank you for fixing that :thumbup:
Didn't "fix" anything, just deleted though... :p
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Adjust Mic Volume Level?

Post by sl23 »

Woteva! :sly: :lol:
- MuLab -
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Adjust Mic Volume Level?

Post by sl23 »

I was wondering if it would be possible to save resources when no input device is detected?

1. Disable the measuring of the input device as I am getting errors on every update cycle.
2. Disable the AudioDeviceCmdlets.dll to stop the memory leak.
3. Disable certain Measures and Meters.

If I connect a mic, then enable, disconnect mic and disable.

As this is using PowershellRM I have no idea what I'm doing here! :oops: :confused:
Is there any chance of some help please?

Here's the Powershell script:

Code: Select all

$env:PSModulePath+="$([System.IO.Path]::PathSeparator)$($RmAPI.VariableStr('@'))Addons"

Import-Module AudioDeviceCmdlets

function Get-Volume {
    param(
        [Parameter(Mandatory)]
        [string]
        $Type
    )
    switch($Type) {
        'Output' {
            if (Get-AudioDevice -PlaybackMute) {
                return -1
            } else {
                return $((Get-AudioDevice -PlaybackVolume) -replace '%', '')
            }
        }
        'Input' {
            if (Get-AudioDevice -RecordingMute) {
                return -1
            } else {
                return $((Get-AudioDevice -RecordingVolume) -replace '%', '')
            }
        }
    }
}

function Set-OutputVolume {
    Set-AudioDevice -PlaybackVolume $RmAPI.Variable('OutputVolume')
}

function OutputToggle-Mute {
	Set-AudioDevice -PlaybackMuteToggle
}	

function Set-InputVolume {
    Set-AudioDevice -RecordingVolume $RmAPI.Variable('InputVolume')
}

function InputToggle-Mute {
	Set-AudioDevice -RecordingMuteToggle
}	
Last edited by sl23 on April 22nd, 2022, 9:27 am, edited 1 time in total.
- MuLab -
User avatar
sl23
Posts: 1140
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Adjust Mic Volume Level?

Post by sl23 »

i've been playing with the Rainmeter code to disable the Measures if no Input Volume is detected, but I just can't get this to work.
The only thing I can do is to have a button to manually enable/disable just the measures when required, but would really prefer it to be automatic and encompass the points in my post above.

Current attempt!

Code: Select all

[DeviceVolume]
Measure=Plugin
Plugin=PowershellRM
ScriptFile=DeviceVolume.ps1

[InputVolume]
Measure=Plugin
Plugin=PowershellRM
Parent=DeviceVolume
Line=Get-Volume -Type Input
IfCondition=InputVolume = -1
IfTrueAction=[!SetOption MicIcon Text "[\xEC54]"][!UpdateMeter *][!Redraw]
IfFalseAction=[!SetOption MicVolumeText Text ""][!UpdateMeter *][!Redraw]
IfCondition2=InputVolume = 0
IfTrueAction2=[!SetOption MicIcon Text "[\xE720]"][!UpdateMeter *][!Redraw]
IfCondition3=(InputVolume > 0) && (InputVolume <= 35)
IfTrueAction3=[!SetOption MicIcon Text "[\xE720]"][!UpdateMeter *][!Redraw]
IfCondition4=(InputVolume > 35) && (InputVolume <= 65)
IfTrueAction4=[!SetOption MicIcon Text "[\xE720]"][!UpdateMeter *][!Redraw]
IfCondition5=InputVolume > 65
IfTrueAction5=[!SetOption MicIcon Text "[\xF12E]"][!UpdateMeter *][!Redraw]

IfCondition6=InputVolume = -1
IfTrueAction=[!DisableMeasure InputVolume][!HideMeter InputRoundBar][!UpdateMeasure *][!Redraw]

IfConditionMode=1
Substitute="-1":"Muted","1.000001":"1","2.999999":"3","9.000001":"9"
MinValue=0
MaxValue=100
Anyone?
- MuLab -
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Adjust Mic Volume Level?

Post by Yincognito »

sl23 wrote: April 20th, 2022, 10:40 pm I was wondering if it would be possible to save resources when no input device is detected?

1. Disable the measuring of the input device as I am getting errors on every update cycle.
2. Disable the AudioDeviceCmdlets.dll to stop the memory leak.
3. Disable certain Measures and Meters.

If I connect a mic, then enable, disconnect mic and disable.

As this is using PowershellRM I have no idea what I'm doing here! :oops: :confused:
Is there any chance of some help please?

Here's the Powershell script:

Code: Select all

$env:PSModulePath+="$([System.IO.Path]::PathSeparator)$($RmAPI.VariableStr('@'))Addons"

Import-Module AudioDeviceCmdlets

function Get-Volume {
    param(
        [Parameter(Mandatory)]
        [string]
        $Type
    )
    switch($Type) {
        'Output' {
            if (Get-AudioDevice -PlaybackMute) {
                return -1
            } else {
                return $((Get-AudioDevice -PlaybackVolume) -replace '%', '')
            }
        }
        'Input' {
            if (Get-AudioDevice -RecordingMute) {
                return -1
            } else {
                return $((Get-AudioDevice -RecordingVolume) -replace '%', '')
            }
        }
    }
}

function Set-OutputVolume {
    Set-AudioDevice -PlaybackVolume $RmAPI.Variable('OutputVolume')
}

function OutputToggle-Mute {
	Set-AudioDevice -PlaybackMuteToggle
}	

function Set-InputVolume {
    Set-AudioDevice -RecordingVolume $RmAPI.Variable('InputVolume')
}

function InputToggle-Mute {
	Set-AudioDevice -RecordingMuteToggle
}	
In principle there's nothing complicated in the above Powershell script, but:
- it uses a DLL which as mentioned above, while it does work, gives some errors that cannot be stopped from Rainmeter
- you didn't share the whole code / packed skin
- there is a logical contradiction between the behavior produced by what you want and the principle of the skin: if you "disable" the DLL module (which should be easy to do via the Remove-Module cmdlet in the PowerShell script, although this will only remove the "objects" loaded from the DLL and not unload the DLL itself, according to Microsoft!) or the relevant measures, then, you won't be able to get the needed info to know when the mic has been connected again in order for the module or measure to be enabled as well, since all that info is based on the said module and having it enabled in the first place!
- while measures can be disabled (though doing that won't disable the module, as said above), meters can't, they can only be hidden

So, from my point of view, not answering is not related to not reading your post or not bothering to respond, but to the logical fallacy in the request. It's like you'd want your phone to automatically shut down when you're not using it, but still detect when you're again touching it to turn itself on ... although its shutdown state prevents any such action to be detected (which is why a stand-by mode exists in these cases, in the first place).
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth