It is currently October 26th, 2021, 11:09 am

Dynamic UpdateDivider!?

Help with creating, editing & fixing problems with skins
JRaynor
Posts: 3
Joined: August 25th, 2021, 3:51 am

Dynamic UpdateDivider!?

Post by JRaynor »

Hi there!

I'm trying to use the AudioLevel plugin in a way that it uses the CPU as little as possible.

So I tried to update UpdateDivider to -1 when there's no audio on Windows but I'm not getting the code to work properly.

I tried some variations of the IfCondition statement but none of them worked as it should.
I don't even know if this is possible or not...

Any help or clarification is welcome.
Thanks!

(Google Translated...)

Code: Select all


[MeasureAudio]
Measure=Plugin
Plugin=AudioLevel
Port=Output
RMSAttack=300
RMSDecay=300
RMSGain=5

IfCondition=(MeasureAudio <> 0.0)
IfTrueAction=[!SetVariable AudioUD  "50"] [!Redraw]
IfFalseAction=[!SetVariable AudioUD "-1"] [!Redraw]

DynamicVariables=1
UpdateDivider=#AudioUD#
Group=AudioLevel

;-------------------------------------------------------------------------------------------------

[MeasureChL]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudio
Channel=L
Type=RMS
DynamicVariables=1
UpdateDivider=#AudioUD#
Group=AudioLevel

[MeasureChR]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudio
Channel=R
Type=RMS
DynamicVariables=1
UpdateDivider=#AudioUD#
Group=AudioLevel

;--------------------------------------------------------------------------------

[MeterChLBar]
MeasureName=MeasureChL
Meter=BAR
X=23
Y=(#AudioY#+3)
W=90
H=9
SolidColor=#BColor2#
BarColor=#DColor3#
BarOrientation=Horizontal
Flip=1
DynamicVariables=1
UpdateDivider=#AudioUD#
Group=AudioLevel

[MeterChRBar]
MeasureName=MeasureChR
Meter=BAR
X=135
Y=(#AudioY#+3)
W=90
H=9
SolidColor=#BColor2#
BarColor=#DColor3#
BarOrientation=Horizontal
Flip=0
DynamicVariables=1
UpdateDivider=#AudioUD#
Group=AudioLevel

User avatar
death.crafter
Posts: 1070
Joined: April 24th, 2021, 8:13 pm

Re: Dynamic UpdateDivider!?

Post by death.crafter »

JRaynor wrote: August 25th, 2021, 4:06 am

Code: Select all


[MeasureAudio]
Measure=Plugin
Plugin=AudioLevel
Port=Output
RMSAttack=300
RMSDecay=300
RMSGain=5

IfCondition=(MeasureAudio <> 0.0)
IfTrueAction=[!SetVariable AudioUD  "50"] [!Redraw]
IfFalseAction=[!SetVariable AudioUD "-1"] [!Redraw]

DynamicVariables=1
UpdateDivider=#AudioUD#
Group=AudioLevel

;-------------------------------------------------------------------------------------------------

[MeasureChL]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudio
Channel=L
Type=RMS
DynamicVariables=1
UpdateDivider=#AudioUD#
Group=AudioLevel

[MeasureChR]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudio
Channel=R
Type=RMS
DynamicVariables=1
UpdateDivider=#AudioUD#
Group=AudioLevel

;--------------------------------------------------------------------------------

[MeterChLBar]
MeasureName=MeasureChL
Meter=BAR
X=23
Y=(#AudioY#+3)
W=90
H=9
SolidColor=#BColor2#
BarColor=#DColor3#
BarOrientation=Horizontal
Flip=1
DynamicVariables=1
UpdateDivider=#AudioUD#
Group=AudioLevel

[MeterChRBar]
MeasureName=MeasureChR
Meter=BAR
X=135
Y=(#AudioY#+3)
W=90
H=9
SolidColor=#BColor2#
BarColor=#DColor3#
BarOrientation=Horizontal
Flip=0
DynamicVariables=1
UpdateDivider=#AudioUD#
Group=AudioLevel

If you are trying to make a visualizer, UpdateDivider=50 is kinda too large.

And this part:

Code: Select all

IfTrueAction=[!SetVariable AudioUD  "50"] [!Redraw]
IfFalseAction=[!SetVariable AudioUD "-1"] [!Redraw]
should be like this:

Code: Select all

IfTrueAction=[!SetVariable AudioUD  "50"][!Update]
IfFalseAction=[!SetVariable AudioUD "-1"][!Update]
The !Redraw bang only reDRAWs a skin. It doesn't update the measures or meters, which is needed to reflect the changes.

Also you are using the same UpdateDivider in the measure where the if conditions are present([MeasureAudio]). So if updatedivider is set to -1, it will never update again, that means the value won't change and you're stucj with UpdateDivider=-1 eternally.

I don't know about the efficiency tho. The result you'd get wouldn't be pleasant. But then again each to his own leaf.
from the Realm of Death
My Current Desktop
User avatar
CodeCode
Posts: 708
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Dynamic UpdateDivider!?

Post by CodeCode »

death.crafter wrote: August 25th, 2021, 7:30 am
Also you are using the same UpdateDivider in the measure where the if conditions are present([MeasureAudio]). So if updatedivider is set to -1, it will never update again, that means the value won't change and you're stucj with UpdateDivider=-1 eternally.
Would they be able to use [!OnChangeAction][!UpDate] ? To reanimate the affected measures?
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
death.crafter
Posts: 1070
Joined: April 24th, 2021, 8:13 pm

Re: Dynamic UpdateDivider!?

Post by death.crafter »

CodeCode wrote: August 25th, 2021, 7:43 am Would they be able to use [!OnChangeAction][!UpDate] ? To reanimate the affected measures?
You mean OnChangeAction=[!Update].

Well, that's an interesting idea. I will let you know after trying.

Edit:
Wait no. MeasureAudio returns values ranging from 0 to 1 and not 0 and 1. So you can't use OnChangeAction. It will be executed everytime the measure value changes. And skip updates if it stays same.
from the Realm of Death
My Current Desktop
User avatar
sl23
Posts: 893
Joined: February 17th, 2011, 7:45 pm
Location: a Galaxy S7 far far away

Re: Dynamic UpdateDivider!?

Post by sl23 »

If there's no audio and the visualiser is not running, wouldn't that in itself reduce CPU consumption?

Doesn't Rainmeter dynamically reduce consumption when things aren't being used? Sort of like a DAW when a plugin isn't being used, it is deactivated to conserve resources.

I think this is a good idea though. So you could use a process measure, for example, to adjust the Update Divider if your music player is open? Or add several processes if needed?
User avatar
death.crafter
Posts: 1070
Joined: April 24th, 2021, 8:13 pm

Re: Dynamic UpdateDivider!?

Post by death.crafter »

sl23 wrote: August 25th, 2021, 9:40 am If there's no audio and the visualiser is not running, wouldn't that in itself reduce CPU consumption?

Doesn't Rainmeter dynamically reduce consumption when things aren't being used? Sort of like a DAW when a plugin isn't being used, it is deactivated to conserve resources.
Unfortunately no. Though no audio is received, the measures and meters are updated at a low update rate. Yes there will be a little low usage since meters don't change at all, but still things are redrawn nonetheless.

You wouldn't notice if you have a high-end rig tho.
from the Realm of Death
My Current Desktop
User avatar
Yincognito
Rainmeter Sage
Posts: 4071
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Dynamic UpdateDivider!?

Post by Yincognito »

Dynamically changing the update divider is possible, and it can seriously reduce the CPU usage, if the skin / meters are large or the measures are CPU intensive. Don't know if it's suitable for this skin or how the changes would affect the other things in the skin though.

I can only confirm that it works, and the benefit is proportional with the original amount of CPU usage ... and this is true for high end systems as well.

EDIT: On a closer look, you might want to set the update divider to something like 1000 and such, instead of -1, so that the IfCondition can run again, irrespective if whether the RMS is 0 or not. That being said, AudioLevel measures will still take some CPU either way, that's just the way they operate.

P.S. An update of 50 ms is fine for a visualizer - mine is set to the same value. It brings a bit of slow-motion to the visual part, but it's just enough to slightly reduce the CPU usage while keeping the visualizer effect acceptable.
User avatar
death.crafter
Posts: 1070
Joined: April 24th, 2021, 8:13 pm

Re: Dynamic UpdateDivider!?

Post by death.crafter »

Yincognito wrote: August 25th, 2021, 10:35 am P.S. An update of 50 ms is fine for a visualizer - mine is set to the same value. It brings a bit of slow-motion to the visual part, but it's just enough to slightly reduce the CPU usage while keeping the visualizer effect acceptable.
50 ms is 20fps. You say it's fine but it's way too laggy🤷
from the Realm of Death
My Current Desktop
User avatar
Yincognito
Rainmeter Sage
Posts: 4071
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Dynamic UpdateDivider!?

Post by Yincognito »

death.crafter wrote: August 25th, 2021, 1:22 pm 50 ms is 20fps. You say it's fine but it's way too laggy🤷
Yep, and 25 ms is 40 FPS. Both intervals are a bit outside the classic movie standards (25 FPS to 30 FPS), but in Rainmeter they work reasonably well, for different types of animation. The 50 ms is indeed laggy for moving animations, where fluidity / smoothness in motion is critical, but for jumping bars or whatever that no one pays attention other than enjoying the trembling, it's not that bad, IMHO. Whether it's acceptable or not probably depends on the BPM / tempo of the played music as well.
User avatar
death.crafter
Posts: 1070
Joined: April 24th, 2021, 8:13 pm

Re: Dynamic UpdateDivider!?

Post by death.crafter »

Yincognito wrote: August 25th, 2021, 3:36 pm Yep, and 25 ms is 40 FPS. Both intervals are a bit outside the classic movie standards (25 FPS to 30 FPS), but in Rainmeter they work reasonably well, for different types of animation. The 50 ms is indeed laggy for moving animations, where fluidity / smoothness in motion is critical, but for jumping bars or whatever that no one pays attention other than enjoying the trembling, it's not that bad, IMHO. Whether it's acceptable or not probably depends on the BPM / tempo of the played music as well.
Me who has kept the default 16 in my vis and still get decent perfomance
tenor (1).gif
Actually it's about the Plugin used. I use Audio Analyzer. It gives decent performance over AudioLevel. Also, there is the fact that my vis is in whole one shape. So it doesn't eat much resources on redraw that's all.
You do not have the required permissions to view the files attached to this post.
from the Realm of Death
My Current Desktop