It is currently March 29th, 2024, 12:30 pm

Win7Audio string not updating = confusion [solved]

Get help with creating, editing & fixing problems with skins
User avatar
Mor3bane
Posts: 943
Joined: May 7th, 2016, 7:32 am

Win7Audio string not updating = confusion [solved]

Post by Mor3bane »

Hi, and Merry Yuletide.

I am putting together a small skin with many functionalities. Several authors and their ideas and code have been a big part of this skin. They are;
  • Youkai1977
    Balala
    Mak Kawa
    Krainz
    gran1972
    jsmorley
    eclectictech
Thanks all of you guys for sharing your amazing ideas and code examples. I have been learning so much with this idea, from all your input here in the forums.
I am having mixed results trying some new things based on the aforementioned's examples.
For example this one by Youkai - it works great on updating a string when the speaker config is changed in my windows RealTek sound manager.

Code: Select all

[MeasureAuto]
Measure=String
String=[MeasureFormat]
OnChangeAction=[!Refresh]
DynamicVariables=1

[MeasureFormat]
Measure=Plugin
Plugin=AudioLevel
DynamicVariables=1
Type=Format
I have tried to recombine that idea with changes made in my skin in the stead of opening RealTek. However, I have been having mixed results with my code.
There is a lot going on, so I will share the skin to hopefully help identify, with help, what I am doing wrong.

Essentially I am duplicating key features of the windows sound panel - and the basics are working well.

But if a setting is changed in the skin, the [MeasureAuto] seems to fail in that idea. I have tried variations - that are no longer in the skin - but unless the skin is fully refreshed - disabling features of the skin in the process - the [MeterConfig] string output does not update.

So that is not happening under two buttons - in the code they are [Button4] and [Button6} both would be fully working if the [MeterConfig] string output updates without fully refreshing the skin, because it breaks the function flow of the buttons.

After the skin is loaded there will be only 1 button visible (it will be made hidden=1 later down the track), the is a [!Refresh] feature with left mouse click.

To activate the 6 other buttons just click on the "Speaker Config" text which is a toggle for the buttons.

Any recommendations or advice or corrections are greatly welcome.

Thanks
Mor
Audio Wizard_xx.01.rmskin
You do not have the required permissions to view the files attached to this post.
Last edited by Mor3bane on December 24th, 2019, 10:48 pm, edited 1 time in total.
My DevArt Gallery

There are many ways to be different - there is only one way to be yourself - be amazing at it

The law of averages says what it means; even if you get everything right, you will get something wrong. Therefore; self managing error trapping initiates another set of averages - amongst the errors, some of them will not be errors, instead those instances will appear to be "luck". One cannot complain of the 'appearance' of 'infinite regress of causation', even if it does not have a predictable pattern, only that it requires luck to achieve.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Win7Audio string not updating = confusion

Post by balala »

Mor3bane wrote: December 23rd, 2019, 10:07 am the [MeterConfig] string output does not update.
I'd say I doubt it doesn't update there is nothing which would prevent it to update, so no way not to update. But since we have completely different hardware, it is hard to perfectly replicate the issue, so same way hard to say something useful. However what I see is that the only reason of the [MeasureAuto] measure seems to be to refresh the skin when the value returned by the [MeasureFormat] measure changes. If so, what if you move the OnChangeAction option directly to [MeasureFormat], then you remove the [MeasureAuto] measure. I don't see why you should use a String measure, unless I'm missing something.
A few other general remarks:
  • Instead of setting the Hidden option of some meters through !SetOption bangs, I'd directly hide or show the appropriate meter, using !HideMeter / !ShowMeter bangs. For instance I'd replace the [!SetOption "HeadsetPNG" "Hidden" "0"] and [!SetOption "SpeakerPNG" "Hidden" "1"] bangs used into the RightMouseUpAction (and similarly in the LeftMouseDownAction) option of the [Button6] meter with [!ShowMeter "HeadsetPNG"] and [!HideMeter "SpeakerPNG"]
  • You're using too many [!Redraw] bangs. Doesn't worth to use more then one into a single option. There are more such situations for instance into the MouseLeaveAction option of [Button4], or the MouseLeaveAction, RightMouseUpAction or LeftMousedownAction options of [Button6].
  • Definitely doesn't worth to use a [!Redraw] bang along with [!Update] (for example into the MouseLeaveAction, MouseScrollUpAction or MouseScrollDownAction options of the [Button4] meter, but not only). When an update is done (either automatically by the update cycle, or with an [!Update] bang), a redraw is also done, redrawing once again the skin is usless, especially that redrawing the skin is expensive (regarding the involved resources). That's why [!Update] is enough, without [!Redraw].
  • It always is preferably not to use LeftMouseDownAction, if possible. Here is why. That's why I probably would replace the LeftMouseDownAction option of meters like [MeterText] or [Button1] - [Button6], with LeftMouseUpAction.
  • Definitely not too important, but Author doesn't belong anymore to [Rainmeter] (where it has been deprecated), but to [Metadata].
  • Mistakenly, the Contextaction5 option of the [Rainmeter] section within the @Resources\roundVariables.inc file is written as ContextAction45. This probably is just a copy / paste issue, but it is a issue, which prevents the appropriate (Varibles) context menu element to be shown. So replace ContextAction45 with ContextAction5.
User avatar
Mor3bane
Posts: 943
Joined: May 7th, 2016, 7:32 am

Re: Win7Audio string not updating = confusion

Post by Mor3bane »

Wow! So much redundant code by me.
I fixed everything to your recommendations, and all performs with no difficulties.

So balala, when you scroll through the output devices the speaker channel meter updates from say 2ch to 4ch and vice/versa?

I am not getting that result - which was indeed the main thing I was asking for help on.

That [MeterConfig] updating as per user input by mouse action is really what I am hoping the main feature of this skin would be.

I've reposted the more tidy version xx.02, just in case you might find something we haven't seen yet, but without the annoying redundant code bangs.

Thanks again, and happy holidays! :rosegift:
Audio Wizard_xx.02.rmskin
You do not have the required permissions to view the files attached to this post.
My DevArt Gallery

There are many ways to be different - there is only one way to be yourself - be amazing at it

The law of averages says what it means; even if you get everything right, you will get something wrong. Therefore; self managing error trapping initiates another set of averages - amongst the errors, some of them will not be errors, instead those instances will appear to be "luck". One cannot complain of the 'appearance' of 'infinite regress of causation', even if it does not have a predictable pattern, only that it requires luck to achieve.
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: Win7Audio string not updating = confusion

Post by mak_kawa »

Hi Mor3bane

When I loaded your skin, MeterConfig string is "44100Hz PCM 32b 2ch" obtained by MeasureFormat.
And when I scroll up/down mouse wheel on Button4, MeterConfig string display changes between "Digital Audio (S/PDIF) and "Speakers" obtained by MeasureWinSevenAudio specified with !SetOption bang in MouseScrollUp/DownAction.

So, I am still not sure what you intend, your skin code works as it is.
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: Win7Audio string not updating = confusion

Post by mak_kawa »

I suspect if Win7AudioPlugin can change sound format as "44100Hz PCM 32b 2ch" for the device. The plugin can only change sound device as Speakers/Headphone and S/PDIF??

Sorry if I am wrong/misunderstanding.
User avatar
Mor3bane
Posts: 943
Joined: May 7th, 2016, 7:32 am

Re: Win7Audio string not updating = confusion

Post by Mor3bane »

Hi mak_kawa,

Yes that is intended behaviour. However, when switching between devices their output usually changed - on most relatively new systems there would be both 2ch for headset or monitor sound, and 4ch for music e.g. front R&L and Rear/Side R&L.

So the behaviour I am trying to achieve, is that the speaker config updates according to the amount of chanells of speaker. On my system i can have 5 that are; mono, stereo, quadrophonic, 5.1, and 7.1 or ch2, ch2, ch4, ch6, ch8, respectively.

What brought this on is video formatting varies depending on the encoding - I have to manually go through all of the clicking and app accessing to change to ch2, or ch4, or ch6 most commonly. I have games the do 7.1 or ch8, and old B&W movies that are mono so the other options sometimes results in no output until I access my sound manager (RealTek Audio Manager).

SO having a skin that could at least update by mouse action on the button4 or button6 i would be ready for when more fancy things come available.

I will elaborate on what "more fancy" means:
The AudioLevel plugin by dgrace (rainmeter developer) is the key utility in this skin. But it cannot actively manage speaker configuration. So I have reached out to him but am awaiting a reply in the plugins forums thread.

I may try to make my own plugin but it would be a steep learning curve without some base code to work from. That said, I am trying to get all of the functionality I can in the meantime.

I hope that clarifies what I am trying to get going.

Merry Xmas eve-eve.
My DevArt Gallery

There are many ways to be different - there is only one way to be yourself - be amazing at it

The law of averages says what it means; even if you get everything right, you will get something wrong. Therefore; self managing error trapping initiates another set of averages - amongst the errors, some of them will not be errors, instead those instances will appear to be "luck". One cannot complain of the 'appearance' of 'infinite regress of causation', even if it does not have a predictable pattern, only that it requires luck to achieve.
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: Win7Audio string not updating = confusion

Post by mak_kawa »

Hi Mor3bane

Yes I now understand what you are trying. But just a guess, to achieve it, we need a plugin with interactive interface that can change the format of audio device. And Win7AudioPlugin and of course AudioLevel plugins don't seem to have such functions.

Just an idea...If there is a command line program that changes audio format, we can use it with RunCommand plugin in Rainmeter skin. But is there such program? I have searched NirCmd site, but no luck so far.
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: Win7Audio string not updating = confusion

Post by mak_kawa »

Or...is there a PowerShell script for audio format change?!
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Win7Audio string not updating = confusion

Post by balala »

Mor3bane wrote: December 23rd, 2019, 10:38 pm So balala, when you scroll through the output devices the speaker channel meter updates from say 2ch to 4ch and vice/versa?
No, it doesn't. As far as I can say, the only case when scrolling does something is if I scroll on [Button4]. When I'm hovering the mouse over it, Audio Output Scroller is shown and if I scroll the 48000Hz PCM 32b 2ch changes to Speaker/Headphone, but nothing else. When I'm leaving the button, the string changes back to 48000Hz PCM 32b 2ch.
Mor3bane wrote: December 23rd, 2019, 10:38 pm I've reposted the more tidy version xx.02, just in case you might find something we haven't seen yet, but without the annoying redundant code bangs.
In fact there still are two issues:
  • In the MouseLeaveAction option of the [Button6] meter a [!Redraw] bang remained along with a [!Update]. Remove the [!Redraw].
  • I still think the LeftMouseDownAction options should be changed to LeftMouseUpAction (meters like [MeterText] or [Button1] - [Button6]). I described why.
Mor3bane wrote: December 23rd, 2019, 10:38 pm Thanks again, and happy holidays! :rosegift:
Wish you the same: happy holidays and a Merry Christmas.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5384
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Win7Audio string not updating = confusion

Post by eclectic-tech »

@mor3bane

The skin needs to refresh to see the changes made when selecting devices and speaker configurations. You would want the skin to remain in the same "state" but show the change...

To do that, I would create a new variable, let's name it STATE, and toggle the value between 0 or 1. This can be used to control the visibility of the control buttons and remembered when the skin is refreshed. I use this variable in all control buttons using Hidden=#State# to hide/show them.

Mouse actions WRITE a new value in the variables section so it is remembered when the skin is refreshed.

I modified mouse actions to "write" values before [!Refresh] and removed several !SetOptions that were not needed since the skin is going to !Refresh. I also changed the audio index numbers to match my system (you will need to reset them to match yours).

Here is the modded code from your second posting... I won't be around for the next few days, but hopefully, this gets you closer.

Merry Christmas!

Code: Select all

[Rainmeter]
Update=40
Group=Wizard

[Metadata]
Author=Code Sapient

[Variables]
@include=#@#RoundVariables.inc
Color=#GlobalFontColor#
ColorZ=#ColorOffset#
Goth=#Gothic#
Gothd=#Gothicd#
SelectTint=#MySepiaTint#
Sound=#@#bloop.wav
Font=Calibri
Size=13
;---------------------------------------------------
; <- Audio Source 3 -> Headset
; <- Audio Source 2 -> HDMI 
; <- Audio Source 1 -> Speaker
;---------------------------------------------------
State=1

;===========================*PARENTS*=====================================

[MeasureWinSevenAudio]
Measure=Plugin
Plugin=Win7AudioPlugin
; Used to control which icon ("Speaker" or "Headset") is displayed
IfMatch=(?i)head
IfMatchAction=[!SetOption "HeadsetPNG" "Hidden" "0"][!WriteKeyValue "HeadsetPNG" "Hidden" "0"][!SetOption "SpeakerPNG" "Hidden" "1"][!WriteKeyValue "SpeakerPNG" "Hidden" "1"][!Update]
IfNotMatchAction=[!SetOption "HeadsetPNG" "Hidden" "1"][!WriteKeyValue "HeadsetPNG" "Hidden" "1"][!SetOption "SpeakerPNG" "Hidden" "0"][!WriteKeyValue "SpeakerPNG" "Hidden" "0"][!Update]

[MeasureFormat]
Measure=Plugin
Plugin=AudioLevel
DynamicVariables=1
;OnChangeAction=[!Refresh]
Type=Format

[MeasureAudio]
Measure=Plugin
Plugin=AudioLevel
Port=Output
FFTSize=1024
FFTAttack=5
FFTDecay=15
Bands=1

[MeasureBand0]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudio
Type=Band
BandIdx=0

[MeasureOutput]
Measure=Plugin
Plugin=AudioLevel
Port=Output

[MeasureOutputDevices]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureOutput
Type=DeviceList

[MeasureInput]
Measure=Plugin
Plugin=AudioLevel
Port=Input

[MeasureInputDevices]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureInput
Type=DeviceList

;===========================*IMAGES*======================================

[Background]
Meter=Image
ImageName=#@##MyBackgroundImage#
X=1
Y=1
Group=Wizard

[MeterImageTop]
Meter=Image
ImageAlpha=200
ImageName=#@#ChapterC.png
ImageTint=#Gothd#
X=56
Y=43
W=150
H=38
Group=Wizard
AntiAlias=1

[MeterImageBottom]
Meter=Image
ImageAlpha=200
ImageName=#@#ChapterC.png
ImageTint=#Gothd#
ImageFlip=Vertical
X=56
Y=170
W=150
H=38
Group=Wizard
AntiAlias=1

;===========================*STRINGS*=====================================

[MeterText]
Meter=STRING
FontFace=Testamentos-Jed@
FontColor=#Gothd#
FontSize=9
StringAlign=Center
X=130
Y=81
ClipString=1
StringCase=None
StringStyle=Bold
StringEffect=Border
FontEffectColor=0,0,0,255
Text=Speaker Config
SolidColor=0,0,0,1
LeftMouseDownAction=[!WriteKeyValue Variables State (1-#State#)][!SetVariable State (1-#State#)][!UpdateMeter *][!Redraw]
;[!ToggleMeterGroup "buttons"]
Antialias=1
DynamicVariables=1

[MeterConfig]
Meter=STRING
MeasureName=MeasureFormat
FontFace=#Font#
FontColor=#MySepiaTint#
FontSize=#Size#
StringAlign=Center
X=130
Y=102
ClipString=1
StringCase=None
Text=%1
Antialias=1
DynamicVariables=1

[MasterShape0]
Meter=Shape
Shape=Rectangle 37,118,192,20,5 | Fill Color 0,0,0,255
Y=10

[MeterBand0]
Meter=Bar
MeasureName=MeasureBand0
X=37
Y=128
W=100
H=10
BarImage=#@#Spectrum.png
BarOrientation=Horizontal

[MasterShape1]
Meter=Shape
Shape=Rectangle 37,118,187,13,5 | Fill Color 0,0,0,1 | StrokeWidth 2 | Stroke Color 255,255,255,215
Y=10

[MasterShape2]
Meter=Shape
Shape=Rectangle 36,116,189,18,5 | Fill Color 0,0,0,1 | StrokeWidth 2 | Stroke Color 75,55,45,255
Y=10

[MasterShape3]
Meter=Shape
Shape=Rectangle 34,114,192,20,5 | Fill Color 0,0,0,1 | StrokeWidth 2 | Stroke Color #MySepiaTint#
Y=10

[MeterButtonHover]
Meter=STRING
FontFace=#Font#
FontColor=#MySepiaTint#
FontSize=#Size#
StringAlign=Center
X=130
Y=146
ClipString=1
StringCase=None
Text=" "
Antialias=1

;===========================*BUTTONS*======================================

[Button1]
Meter=Image
ImageName=#@##MyBackgroundImage#
X=228
Y=134
W=35
H=35
Antialias=1
LeftMouseDownAction=[!SetClip " "][!WriteKeyValue Variables State 1][!Refresh]
Hidden=0
Group=

[Button2]
Meter=Image
ImageName=#@##MyBackgroundImage#
X=209
Y=184
W=35
H=35
Antialias=1
LeftMouseDownAction=[!SetClip "Output Devices:#CRLF#[MeasureOutputDevices]"][!SetOption "MeterButtonHover" "Text" "Output Devices Copied"]
MouseOverAction=[!SetOption "MeterButtonHover" "Text" "Output Devices"][!Update]
MouseLeaveAction=[!SetOption "MeterButtonHover" "Text" """ """][!Update]
DynamicVariables=1
Hidden=#State#
Group=buttons

[Button3]
Meter=Image
ImageName=#@##MyBackgroundImage#
X=169
Y=218
W=35
H=35
Antialias=1
LeftMouseDownAction=[!SetClip "Input Devices:#CRLF#[MeasureInputDevices]"][!SetOption "MeterButtonHover" "Text" "Input Devices Copied"]
MouseOverAction=[!SetOption "MeterButtonHover" "Text" "Intput Devices"][!Update]
MouseLeaveAction=[!SetOption "MeterButtonHover" "Text" """ """][!Update]
DynamicVariables=1
Hidden=#State#
Group=buttons

[Button4]
Meter=Image
ImageName=#@##MyBackgroundImage#
X=114
Y=232
W=35
H=35
Antialias=1
LeftMouseDownAction=[" "]
DynamicVariables=1
MouseOverAction=[!SetOption "MeterButtonHover" "Text" "[MeasureWinSevenAudio]"][!Update]
MouseLeaveAction=[!SetOption "MeterButtonHover" "Text" """ """][!SetOption "MeterConfig" "Text" "[MeasureFormat]"][!Update]
MouseScrollUpAction=[!CommandMeasure "MeasureWinSevenAudio" "ToggleNext"][PLAY "#Sound#"][!SetOption "MeterButtonHover" "Text" "[MeasureWinSevenAudio]"][!Refresh]
MouseScrollDownAction=[!CommandMeasure "MeasureWinSevenAudio" "TogglePrevious"][PLAY "#Sound#"][!SetOption "MeterButtonHover" "Text" "[MeasureWinSevenAudio]"][!Refresh]
Hidden=#State#
Group=buttons

[Button5]
Meter=Image
ImageName=#@##MyBackgroundImage#
X=60
Y=218
W=35
H=35
MouseOverAction=[!SetOption "MeterButtonHover" "Text" "RealTek Audio"][!Update]
MouseLeaveAction=[!SetOption "MeterButtonHover" "Text" """ """ ][!Update]
LeftMouseDownAction=["C:\Program Files\Realtek\Audio\HDA\RtkNGUI64.exe"]
RightMouseDownAction=[" "]
DynamicVariables=1
Hidden=#State#
Group=buttons

[Button6]
Meter=Image
ImageName=#@##MyBackgroundImage#
X=21
Y=184
W=35
H=35
MouseOverAction=[!SetOption "MeterButtonHover" "Text" "Speakers / Headset"][!Update]
MouseLeaveAction=[!SetOption "MeterButtonHover" "Text" """ """ ][!SetOption "MeterConfig" "Text" "[MeasureFormat]"][!Update][!Redraw]
RightMouseUpAction=[!WriteKeyValue "HeadsetPNG" "Hidden" "0"][!WriteKeyValue "SpeakerPNG" "Hidden" "1"][!CommandMeasure "MeasureWinSevenAudio" "SetOutPutIndex 2"][PLAY "#Sound#"][!Refresh]
LeftMouseDownAction=[!WriteKeyValue "HeadsetPNG" "Hidden" "1"][!WriteKeyValue "SpeakerPNG" "Hidden" "0"][!CommandMeasure "MeasureWinSevenAudio" "SetOutPutIndex 3"][PLAY "#Sound#"][!Refresh]
DynamicVariables=1
Hidden=#State#
Group=buttons

[Button7]
Meter=Image
ImageName=#@##MyBackgroundImage#
X=0
Y=134
W=35
H=35
MouseOverAction=[!SetOption "MeterButtonHover" "Text" "Mixer / Devices"][!Update]
MouseLeaveAction=[!SetOption "MeterButtonHover" "Text" """ """ ][!Update]
LeftMouseUpAction=[%windir%\system32\control.exe mmsys.cpl]
RightMouseUpAction=[%windir%\system32\sndvol.exe -T 75611119 0]
DynamicVariables=1
Hidden=#State#
Group=buttons

[HeadsetPNG]
Meter=Image
ImageName=#@#headset.png
X=152
Y=185
W=35
H=35
Antialias=1
LeftMouseDownAction=
Hidden=1
Group=

[SpeakerPNG]
Meter=Image
ImageName=#@#speakers.png
X=74
Y=184
W=35
H=35
Antialias=1
LeftMouseDownAction=
Hidden=0
Group=