It is currently April 23rd, 2024, 12:29 pm

Adjust Mic Volume Level?

Get help with creating, editing & fixing problems with skins
User avatar
Yincognito
Rainmeter Sage
Posts: 7149
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Adjust Mic Volume Level?

Post by Yincognito »

sl23 wrote: April 28th, 2022, 7:56 pm Tried it twice and nothing happened! :???:

Code: Select all

PS C:\Users\sl23> Get-PnpDevice | Where-Object {$_.FriendlyName -like '*Microphone Array*'} | Enable-PnpDevice -Confirm:$false
PS C:\Users\sl23> Get-PnpDevice | Where-Object {$_.FriendlyName -like '*Microphone Array*'} | Enable-PnpDevice -Confirm:$false
PS C:\Users\sl23>
Also tried Disabling to see if it affected anything, but nothing changed.
But you do have such a device on your computer, right? The plain Get-PnpDevice lists it, doesn't it?
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 »

Argh! No it doesn't. I'll have to try my laptop.

I am a bit confused on how the whole input side of things works in Windows. Not sure if I can explain properly... The list of devices are, in short, as at work now, microphone, stereo mix and line in. Are these all connected or separate? Do I need a device plugged in in order to control its volume as Rainmeter is doing so with nothing plugged in, as can be seen in Windows settings. But it's changing the stereo mix volume??? I still don't get what the stereo mix is for tbh! Doesn't audio just go out? Or does audio have to go through this? I seem to recall that this can be bypassed, not sure if I'm right though.

I will be getting a sound card for music production for pc, with mic usage, will that be recognised as a mic still or just as USB audio?

I'll have to copy Rainmeter setup to my laptop as it worked on the mic input perfectly. Not having the mic plugged in is probably causing the issue with power shell too, but I don't have a 6.5 to 3.5mm jack converter to test with at present. I thought that controlling a device meant controlling the device mechanics of Windows own mic controller, but looks like I got that wrong! Sorry.
- MuLab -
User avatar
Yincognito
Rainmeter Sage
Posts: 7149
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Adjust Mic Volume Level?

Post by Yincognito »

sl23 wrote: April 29th, 2022, 9:48 am Argh! No it doesn't. I'll have to try my laptop.

I am a bit confused on how the whole input side of things works in Windows. Not sure if I can explain properly... The list of devices are, in short, as at work now, microphone, stereo mix and line in. Are these all connected or separate? Do I need a device plugged in in order to control its volume as Rainmeter is doing so with nothing plugged in, as can be seen in Windows settings. But it's changing the stereo mix volume??? I still don't get what the stereo mix is for tbh! Doesn't audio just go out? Or does audio have to go through this? I seem to recall that this can be bypassed, not sure if I'm right though.

I will be getting a sound card for music production for pc, with mic usage, will that be recognised as a mic still or just as USB audio?

I'll have to copy Rainmeter setup to my laptop as it worked on the mic input perfectly. Not having the mic plugged in is probably causing the issue with power shell too, but I don't have a 6.5 to 3.5mm jack converter to test with at present. I thought that controlling a device meant controlling the device mechanics of Windows own mic controller, but looks like I got that wrong! Sorry.
Well, you should try those commands on devices you have, and they should mostly work in enabling and disabling stuff. Also, even though I don't have the system you do, a list of all your devices copy pasted from PS to a code box here would help, but again, I can't do the testing for you.

Stereo Mix is a tool that allows the user to record the output stream of a computer such as broadcasting radio, speaker outputs, live streaming audios, even system sounds. The devices are separate , but changing things on one will sometimes influence the practical result on others, like recording from your mic at 100%, but playing it at the general output volume of 50%. You don't need a device to be plugged in to control its volume, though not sure if you'd need that for disabling or enabling purposes.

For someone about to get such a card, you should be acquainted with how audio stuff works. The physical device itself will probably be present as an USB one, but it should have its elements in the audio section as well, similar to an USB mouse or hard drive.

Some alternative links you can try (be sure to check the other links in the comments as well) here.
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 »

This is getting problematic! I've disabled the Sound Mixer but can't re-enable it! :?

It was showing here, but isn't now...

Code: Select all

Windows Default Input Device:

Device Name:	Microphone (Rt)
Device ID:		{67a92437-c439-4917-8a59-d55cbe8348f2}
Device Format:	48000Hz PCM 32b 2ch
Device Status:	On

Device List:

{0.0.1.00000000}.{70542301-2735-411e-98af-6a015181115a}		Microphone (Realtek(R) Audio)
{0.0.1.00000000}.{e9d7554f-8366-4103-8589-3cb17d0c9d8d}		Line In (Realtek(R) Audio)
It shows up in Powershell when I use Get-PnpDevice, but I can't re-enable it for some reason! Windows 11 Settings are stupid! Least things that were disabled actually appeared in settings so you could see their current state!
EDIT: SOLVED! I found the Control Panel in Sys32 directory! Phew! :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 »

Current Input Device List...

Code: Select all

Device List:

{0.0.1.00000000}.{081bb7b5-bdc7-4d10-af8b-48db8b2cae3a}		Stereo Mix (Realtek(R) Audio)
{0.0.1.00000000}.{70542301-2735-411e-98af-6a015181115a}		Microphone (Realtek(R) Audio)
{0.0.1.00000000}.{e9d7554f-8366-4103-8589-3cb17d0c9d8d}		Line In (Realtek(R) Audio)
- 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 »

Well, after all the trial and error, I have found that NirSoft makes an app called SoundVolumesView that can disable/enable all sound devices easily and can be used via .lnk files. Sorted.

One thing I am wondering though is how to tackle disabling of the AudioDeviceCmdlet and re-enabling it. I could just do a manual button for each, but had a thought that maybe you could shed some light on?

I was thinking that when the [MicLevel] drops below a set point for a certain period, say a minute, it sets the UpdateDivider on the [DeviceVolume] to -1 soon as the [MicLevel] rises above the set threshold, it sets the UpdateDivider to the skins default of 50, what do you think?

Code: Select all

[mMic]
Measure=Plugin
Plugin=AudioLevel
Parent=mMicLevel
Type=RMS

[MicLevel]
Meter=String
MeterStyle=sAllText
MeasureName=mMic
NumOfDecimals=2
Percentual=1
Text=%1
Group=Sound
X=r
Y=10r

[DeviceVolume]
Measure=Plugin
Plugin=PowershellRM
ScriptFile=DeviceVolume.ps1
UpdateDivider=-1
This way, there's no need to disable anything as when the mic isn't used, the device isn't refreshed so often, which reduces the memory leak. :D

Also, about the adjusting Mic Volume, when the Mic is unplugged, the AudioDeviceCmdlet then adjusts the StereoMix, is that how it should be? Is that normal behaviour? Because it's almost like auto selecting the next device to control should the first be unavailable. Which I think is wrong, it shouldn't do that.
- MuLab -
User avatar
Yincognito
Rainmeter Sage
Posts: 7149
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Adjust Mic Volume Level?

Post by Yincognito »

sl23 wrote: April 29th, 2022, 10:02 pm Well, after all the trial and error, I have found that NirSoft makes an app called SoundVolumesView that can disable/enable all sound devices easily and can be used via .lnk files. Sorted.

One thing I am wondering though is how to tackle disabling of the AudioDeviceCmdlet and re-enabling it. I could just do a manual button for each, but had a thought that maybe you could shed some light on?

I was thinking that when the [MicLevel] drops below a set point for a certain period, say a minute, it sets the UpdateDivider on the [DeviceVolume] to -1 soon as the [MicLevel] rises above the set threshold, it sets the UpdateDivider to the skins default of 50, what do you think?

Code: Select all

[mMic]
Measure=Plugin
Plugin=AudioLevel
Parent=mMicLevel
Type=RMS

[MicLevel]
Meter=String
MeterStyle=sAllText
MeasureName=mMic
NumOfDecimals=2
Percentual=1
Text=%1
Group=Sound
X=r
Y=10r

[DeviceVolume]
Measure=Plugin
Plugin=PowershellRM
ScriptFile=DeviceVolume.ps1
UpdateDivider=-1
This way, there's no need to disable anything as when the mic isn't used, the device isn't refreshed so often, which reduces the memory leak. :D

Also, about the adjusting Mic Volume, when the Mic is unplugged, the AudioDeviceCmdlet then adjusts the StereoMix, is that how it should be? Is that normal behaviour? Because it's almost like auto selecting the next device to control should the first be unavailable. Which I think is wrong, it shouldn't do that.
Really? You found out just now? I've been saying this since my first reply in this thread, LOL, but then, folks were busy using a memory leaking DLL (granted, they didn't knew that, and the code / intent looked just fine otherwise)...

Also, now that you mentioned it, I remember I answered other similar threads in the past (sorry for not recalling this earlier), maybe the stuff here or here would be of some use to you, if you adjust it accordingly to your scenario. Not sure how this will suit the need to constantly run such commands, of course, as it's best suited for occasional use, but unfortunately, as you could see, there aren't many feasible solutions available. It would be great if there was no need for additional EXE / DLL dependencies though.

Regarding your idea of dynamically adjusting the update divider to keep the memory leaking under control, while it looks optimal on a first look and I could make a sketch on how such a code would look like, I doubt that it will produce the desired outcome. I could be wrong, but once the DLL has already leaked 500 MB, reducing the leakage by updating less often doesn't help much, since those 500 MB will continue to be used by Rainmeter, from my experience - i.e. they won't be "released". So, while this might slow down the leakage to some extent, it won't keep it under control (as in, not taking hundreds of MB for a good while). That's why I recommended setting the update divider of the relevant measures to a value (e.g. 1 second) that will allow that control to be possible right from the start, as doing so dynamically will not solve the harm already done. I can help with the dynamic adjustment if you really want to, but I wouldn't like to do it pointlessly, if it doesn't reasonably "solve" the underlying issue.

For example, letting this till it hits 100 MB of memory usage:

Code: Select all

[Variables]

[Rainmeter]
Update=50
DynamicWindowSize=1
AccurateText=1

[DeviceVolume]
Measure=Plugin
Plugin=PowershellRM.dll
ScriptFile=#@#DeviceVolume.ps1
UpdateDivider=-1

[InputVolume]
Measure=Plugin
Plugin=PowershellRM.dll
Parent=DeviceVolume
Line=Get-InputVolume
UpdateDivider=1

[Result]
Meter=String
SolidColor=47,47,47,255
FontColor=255,255,255,255
FontFace=Consolas
FontSize=16
AntiAlias=1
MeasureName=InputVolume
Text=Input Volume: %1%
LeftMouseUpAction=[!SetOption InputVolume UpdateDivider 20][!UpdateMeasure InputVolume][!UpdateMeter *][!Redraw]
DynamicVariables=1
and then left clicking it to set the updating of the relevant measure to once every second, illustrates very well that the memory already taken is taken for good, until of course, you exit Rainmeter and start it again. :confused:

P.S. I can't tell what AudioDeviceCmdlets really does behind the scenes. Sure, it is programmed in C# which, unlike C++, I can understand better by looking at the GitHub code, but obviously not near the level of the actual developer. If you have questions, suggestions or bug reports and such, you should post them there. Here, we are just users of the plugin, some more acquainted with various tools or programming languages, some less so.
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 »

Yincognito wrote: August 13th, 2021, 10:46 am For the record, if it's for local use, you can easily set the mic level using Win7Audio measures, assuming you identify your MIC's index in the output device list first.

If intended to be shared, probably some more measures (e.g. AudioLevel, Registry) would be needed to identify the MIC's ID and / or index so you can set it for use with the Win7Audio measure.

Another alternative is to use some NirCmd utilities to do that.
I didn't think you could use Rainmeter plugins to adjust mic volume? That was the reason I used the AudioDeviceCmdlet. Now I see the problem with this, I am trying to find alternative ways of monitoring and adjusting via left, right, scroll actions.

I had some experience with NirCmd, but hadn't known of others. I recently found SoundVolumeView and that works for left, right actions but not scroll. Also, I couldn't get NirCmd to work with mic at all.

Sorry for the run around! :oops: I'll take a look at those links and yes, I get your point about the dynamic adjustment not releasing the memory. However, the mic is used only in shortish bursts, so may not be an issue. But then again, if there's a whole better way of achieving the mouse actions using native plugins as you mentioned in that first post, I'm all ears! :D
- MuLab -
User avatar
Yincognito
Rainmeter Sage
Posts: 7149
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Adjust Mic Volume Level?

Post by Yincognito »

sl23 wrote: April 30th, 2022, 8:22 pm I didn't think you could use Rainmeter plugins to adjust mic volume? That was the reason I used the AudioDeviceCmdlet. Now I see the problem with this, I am trying to find alternative ways of monitoring and adjusting via left, right, scroll actions.

I had some experience with NirCmd, but hadn't known of others. I recently found SoundVolumeView and that works for left, right actions but not scroll. Also, I couldn't get NirCmd to work with mic at all.

Sorry for the run around! :oops: I'll take a look at those links and yes, I get your point about the dynamic adjustment not releasing the memory. However, the mic is used only in shortish bursts, so may not be an issue. But then again, if there's a whole better way of achieving the mouse actions using native plugins as you mentioned in that first post, I'm all ears! :D
No, the first part of the post I mentioned was just me halucinating, LOL - luckily, death.crafter and jsmorley quickly reminded me of that in the following posts. There is no way to control the mic volume using native Rainmeter methods, since it's an input device and not an output one. I was just referring to the last paragraph where I mentioned that what you wanted can be achieved using a NirSoft utility, that's all.

I don't follow regarding not being able to adjust the mic volume via SoundVolumeView using mouse scroll, only by using left/right actions (by the way, what you mean by left/right actions anyway?) - the following skin does just that, apart from having to launch the NirSoft utilities in slow motion and with a reasonable pause between so they could run (which I already mentioned that it was a disadvantage of this method earlier):
MicNir_1.0.0.rmskin
This uses the command line version of SoundVolumeView, since it's recommended and I thought it would run faster. Unfortunately, it isn't so fast after all, compared to what I expected, but at least it works ... and you have no memory leak by using this. Now of course, you can monitor the mic volume with AudioLevel just like before since it allows getting the relevant data much faster, but to toggle mute or change mic volume, left clicking and scrolling works just fine considering this is normally done much rarely. It isn't perfect since the utility can't stay in memory and has to be run every time, but if you look for that you could just keep SoundVolumeView in system tray or hidden, set the device you want to monitor or change and select to do that via mouse scroll while mouse is over the program's window.

P.S. A nice thing one can do with Sound Volume Command Line is to use multiple commands at the same time, though this doesn't work in every case. For example, this will decrease volume by 10% on the specified device and then get the newly set volume:

Code: Select all

svcl /stdout /changevolume "YourDeviceFriendlyID" -10 /getpercent "YourDeviceFriendlyID"
Changing the order matters, since this will get the device volume before similarly changing it:

Code: Select all

svcl /stdout /getpercent "YourDeviceFriendlyID" /changevolume "YourDeviceFriendlyID" -10
Sure, one can easily replicate this using CMD's own sequential execution, like:

Code: Select all

svcl /stdout /changevolume "YourDeviceFriendlyID" -10 & svcl /stdout /getpercent "YourDeviceFriendlyID"
but still, it's a nice little thing to have. If it was faster it would have been better, but I imagine the audio part is not tricky in Windows for no reason, so it is what it is.
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 »

I don't follow regarding not being able to adjust the mic volume via SoundVolumeView using mouse scroll, only by using left/right actions (by the way, what you mean by left/right actions anyway?)
LOL simple, I just meant mouse actions... Mouse scroll, Mouse Left click, Mouse right click.
you can monitor the mic volume with AudioLevel just like before since it allows getting the relevant data much faster
So I can have a meter display the current Mic volume using AudioLevel Plugin? Why aren't I doing this now? Same with the Mic Roundline meter?

Code: Select all

[mMicLevel]
Measure=Plugin
Plugin=AudioLevel
Port=Input
RMSAttack=50
RMSDecay=300
;Set your desired Mic-response here--------------------
RMSGain=10

[mMic]
Measure=Plugin
Plugin=AudioLevel
Parent=mMicLevel
Type=RMS

[MicVolumeText]
Meter=String
MeasureName=mMic OR mMicLevel - Neither works
MeterStyle=sAllText
FontSize=16
FontColor=#Green#
Text=%1
Percentual=1
NumOfDecimals=0
Hidden=1
Group=Input
X=r
Y=r
MicNir_1.0.0.rmskin
This doesn't work correctly. If I use my skin to adjust the volume in steps of 5%, this skin shows very odd and very different % values. eg currently my Volume skin shows 25% yours shows 8%. Mine up to 30%, yours at 10%. Mine 50%, yours 19%.

Scrolling down once on your skin from 100% showed 76%, and again showed 59%, whereas my skin showed 100%, 95% and 90% respectively.

Even stranger is that when I open the Sound Settings or the MS ControlPanel/Sound applet they change immediately and show the correct values in time with changes made in my skin! :???: Also, Mute/Unmute works on yours, but the text doesn't change unless those settings windows are open! Crazy!
SOLVED! The issue was that I just used DeviceFriendlyID=Microphone instead of DeviceFriendlyID=Realtek(R) Audio\Device\Microphone\Capture

But I've found that simply using SoundVolView desktop shortcut commands works for controlling the Mic Volume perfectly well:

Code: Select all

[MicButtonBg]
Shape=Ellipse 0,0,5 | FillColor #Trans# | StrokeWidth 2 | StrokeColor #White20#

LeftMouseUpAction=#@#Addons\svcl /stdout /setvolume "Realtek(R) Audio\Device\Microphone\Capture" 25 /getpercent "Realtek(R) Audio\Device\Microphone\Capture"
MiddleMouseUpAction=#@#Addons\SoundVolumeView.exe /Switch "Realtek(R) Audio\Device\Microphone\Capture"
RightMouseUpAction=#@#Addons\svcl /stdout /setvolume "Realtek(R) Audio\Device\Microphone\Capture" 80 /getpercent "Realtek(R) Audio\Device\Microphone\Capture"
;ms-settings:sound
#@#Addons\SoundVolumeView.exe /Switch "Realtek(R) Audio\Device\Stereo Mix\Capture"

MouseScrollUpAction=#@#Addons\SoundVolumeView.exe /ChangeVolume "Realtek(R) Audio\Device\Microphone\Capture" 5
MouseScrollDownAction=#@#Addons\SoundVolumeView.exe /ChangeVolume "Realtek(R) Audio\Device\Microphone\Capture" -5
ToolTipText=#CURRENTSECTION#
X=20r
Y=r

[Mic]
Meter=Shape
MeterStyle=MicButtonBg
X=40
Y=65
Both Mute/Unmute and Scroll work fine. The commands I've set for the button all seem good for setting the mic volume too.

I just need to be able to monitor the Mic Volume as a % and for a Roundline meter. Though I don't really understand how the Parent/Child measures work! :oops: Can this be done with AudioLevel Plugin as you suggested, or is that a misunderstanding on my part?

Thanks for the help, this has made this skin much more friendly! :thumbup: :D