It is currently January 22nd, 2021, 4:14 pm

Dynamic GIF problems

Help with creating, editing & fixing problems with skins
CMDR_Evolution
Posts: 9
Joined: October 30th, 2020, 6:25 pm

Dynamic GIF problems

Post by CMDR_Evolution »

Hello Rainmeter community,

Sorry if this isn't very clear but hopefully it makes more sense to you than it does for me!

What I'm trying to do is to have an animated GIF's cycle speed dependant on a variable. Basically, when I can get the if formula sorted, then I'll be changing the input for a new PC to measure PSU power. In my current machine, it hasn't got a measurable PSU so this skin is set up with a volume plugin I use for another skin.

So, currently, what I want the skin to do is to cycle the GIF slower for lower volume levels and faster for higher volumes. I added some extra code for a text string to show me what the number is and that bit works, it's just the animation speed that doesn't ever change. I've been playing around all day and just can't get my attempts to work.

If that sounds like something which would be easy for you, I'd greatly appreciate your pearls of wisdom as I'm in way over my head :(. Here's the mess I have after countless adjustments throughout the day:

Code: Select all

[Rainmeter]
Author=Alan
Update=#UpdateSpeed#

[Variables]
UpdateSpeed=100

[ImageNumberCalc]
Measure=Calc
Formula=Counter % 90

[MeasureWin7Audio]
Measure=Plugin
Plugin=Win7AudioPlugin.dll

;[MeasurePowerCalc]
;Measure=Registry
;RegHKey=HKEY_CURRENT_USER
;RegKey=Software\FinalWire\AIDA64\SensorValues
;RegValue=Value.SCPUUTI 

[PercentageCalc]
Measure=Calc
Formula=MeasureWin7Audio
Substitute="-1":"0"
IfConditionMode=1
IfCondition1=(PercentageCalc <= 20)
IfTrueAction1=[!SetVariable UpdateSpeed "100"]
IfCondition2=(PercentageCalc <= 40)
IfTrueAction2=[!SetVariable UpdateSpeed "80"]
IfCondition3=(PercentageCalc <= 60)
IfTrueAction3=[!SetVariable UpdateSpeed "60"]
IfCondition4=(PercentageCalc <= 80)
IfTrueAction4=[!SetVariable UpdateSpeed "40"]
IfCondition5=(PercentageCalc <= 100)
IfTrueAction5=[!SetVariable UpdateSpeed "20"]
DynamicVariables=1
;Forumla=(MeasureWin7Audio > 79) ? 1 : ((MeasureWin7Audio > 59) ? 2 : ((MeasureWin7Audio > 39) ? 3 : ((MeasureWin7Audio > 19) ? 4 : 5)))
;UpdateDivider=(1/#UpdateSpeed#)

[MeterVolumePercent]
Meter=String
MeasureName=PercentageCalc
FontColor=000,175,255,240
StringAlign=center
StringEffect=Shadow
StringStyle=Bold
FontName=Ubuntu
FontSize=16
Antialias=1
X=905
Y=10
Text="%1%"

[MeterBarPosition]
Meter=Image
X=0
Y=0
ImageName=#@#PSU-[ImageNumberCalc].png
AntiAlias=1
DynamicVariables=1
UpdateDivider=(100/#UpdateSpeed#)
User avatar
balala
Rainmeter Sage
Posts: 12095
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Dynamic GIF problems

Post by balala »

CMDR_Evolution wrote: January 8th, 2021, 5:04 pm Hello Rainmeter community,

Sorry if this isn't very clear but hopefully it makes more sense to you than it does for me!

What I'm trying to do is to have an animated GIF's cycle speed dependant on a variable. Basically, when I can get the if formula sorted, then I'll be changing the input for a new PC to measure PSU power. In my current machine, it hasn't got a measurable PSU so this skin is set up with a volume plugin I use for another skin.

So, currently, what I want the skin to do is to cycle the GIF slower for lower volume levels and faster for higher volumes. I added some extra code for a text string to show me what the number is and that bit works, it's just the animation speed that doesn't ever change. I've been playing around all day and just can't get my attempts to work.

If that sounds like something which would be easy for you, I'd greatly appreciate your pearls of wisdom as I'm in way over my head :(. Here's the mess I have after countless adjustments throughout the day:

Code: Select all

[Rainmeter]
Author=Alan
Update=#UpdateSpeed#

[Variables]
UpdateSpeed=100

[ImageNumberCalc]
Measure=Calc
Formula=Counter % 90

[MeasureWin7Audio]
Measure=Plugin
Plugin=Win7AudioPlugin.dll

;[MeasurePowerCalc]
;Measure=Registry
;RegHKey=HKEY_CURRENT_USER
;RegKey=Software\FinalWire\AIDA64\SensorValues
;RegValue=Value.SCPUUTI 

[PercentageCalc]
Measure=Calc
Formula=MeasureWin7Audio
Substitute="-1":"0"
IfConditionMode=1
IfCondition1=(PercentageCalc <= 20)
IfTrueAction1=[!SetVariable UpdateSpeed "100"]
IfCondition2=(PercentageCalc <= 40)
IfTrueAction2=[!SetVariable UpdateSpeed "80"]
IfCondition3=(PercentageCalc <= 60)
IfTrueAction3=[!SetVariable UpdateSpeed "60"]
IfCondition4=(PercentageCalc <= 80)
IfTrueAction4=[!SetVariable UpdateSpeed "40"]
IfCondition5=(PercentageCalc <= 100)
IfTrueAction5=[!SetVariable UpdateSpeed "20"]
DynamicVariables=1
;Forumla=(MeasureWin7Audio > 79) ? 1 : ((MeasureWin7Audio > 59) ? 2 : ((MeasureWin7Audio > 39) ? 3 : ((MeasureWin7Audio > 19) ? 4 : 5)))
;UpdateDivider=(1/#UpdateSpeed#)

[MeterVolumePercent]
Meter=String
MeasureName=PercentageCalc
FontColor=000,175,255,240
StringAlign=center
StringEffect=Shadow
StringStyle=Bold
FontName=Ubuntu
FontSize=16
Antialias=1
X=905
Y=10
Text="%1%"

[MeterBarPosition]
Meter=Image
X=0
Y=0
ImageName=#@#PSU-[ImageNumberCalc].png
AntiAlias=1
DynamicVariables=1
UpdateDivider=(100/#UpdateSpeed#)
Note a few mistakes in the posted code:
  • The IfCondition1 and IfTrueAction1 options of the [PercentageCalc] measure should be IfCondition and IfTrueAction. These options (as well as many others) have to be numbered only starting from the second option.
  • Checking if the value of the measure is less then certain numeric valus is not enough, because you have to add to most of those IfConditions two checks. You have to check if the value is between (for instance) 20 and 40, so if it is gretaer than 20 AND less than 40. That's why the conditions should look like this:

    Code: Select all

    [PercentageCalc]
    ...
    IfCondition=(PercentageCalc<=20)
    ...
    IfCondition2=((PercentageCalc>20)&&(PercentageCalc<=40))
    ...
    IfCondition3=((PercentageCalc>40)&&(PercentageCalc<=60))
    ...
    IfCondition4=((PercentageCalc>60)&&(PercentageCalc<=80))
    ...
    IfCondition5=(PercentageCalc>80)
    ...
  • Setting the UpdateSpeed is completely useless in this case because the set value can't be used on the [Rainmeter] section, which doesn't support dynamic variables (second paragraph here - dynamic variables are supported only on meters and measures, not on sections like [Rainmeter]). In fact [Rainmeter] doesn't support neither the dynamic variables nor changes through the !SetOption bang, for instance.
  • Instead of the provided solution I'd use an ActionTimer plugin measure, to get a periodically updated variable, which can be used then in the [MeterBarPosition] Image meter (I suppose you have copied the measure from another code, but its name is a little bit weird - however this is not an issue).
  • Even if is commented out, the UpdateDivider option of the [PercentageCalc] measure, as posted, is wrong. The UpdateDivider has to be an integer.
If you are interesetd (I suppose you are) in how to add and use the ActionTimer plugin measure and you don't know, let me know to help you.
CMDR_Evolution
Posts: 9
Joined: October 30th, 2020, 6:25 pm

Re: Dynamic GIF problems

Post by CMDR_Evolution »

Thank you so much balala,

Hmmm, it looks like I was way off then.

So, based on what you've said:
*The IfCondition1 and IfTrueAction1 don't need to be numbered (done)

*The middle ifConditions needs to be between numbers (done)

*However, setting the ifCondition to update the speed is not possible, so there's no way to make this all work anyway?

*Instead, actiontimer will be able to read a number from a plugin or the registry from 1-100, then adjust the speed with a different method?

Thank you
User avatar
balala
Rainmeter Sage
Posts: 12095
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Dynamic GIF problems

Post by balala »

CMDR_Evolution wrote: January 8th, 2021, 7:13 pm *However, setting the ifCondition to update the speed is not possible, so there's no way to make this all work anyway?

*Instead, actiontimer will be able to read a number from a plugin or the registry from 1-100, then adjust the speed with a different method?
But there is. As said, you can use an ActionTimer plugin measure to get the appropriate frame numbers.
To help you, please pack the PSU-XX.png images together and upload the package. Would be much easier for me if I have the needed frames. Thanks.
CMDR_Evolution
Posts: 9
Joined: October 30th, 2020, 6:25 pm

Re: Dynamic GIF problems

Post by CMDR_Evolution »

Hello Balala,

That would be amazing, thank you! I've put the skin into a package although I couldn't add the win7audio plugin for some reason. I couldn't see a way to add it directly to the post so here it is on google drive: https://drive.google.com/file/d/1gxHV2T4j7k66nGVyVL2v3t3vY0Wl3fTI/view?usp=sharing

I'm sure you already have this anyway but if not, here's the page for it: https://docs.rainmeter.net/manual/plugins/win7audio/. Mind you, anything would be fine. I've just been using audio to test this and I'll be changing it to the PSU when I get my new PC ready.

I really appreciate your help and look forward to hearing back. All the best
User avatar
balala
Rainmeter Sage
Posts: 12095
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Dynamic GIF problems

Post by balala »

CMDR_Evolution wrote: January 9th, 2021, 4:39 pm I couldn't see a way to add it directly to the post so here it is on google drive:
You can add it below the field where you are writing your reply, on the Attachments tab:
Attachments.png
CMDR_Evolution wrote: January 9th, 2021, 4:39 pm I'm sure you already have this anyway but if not, here's the page for it: https://docs.rainmeter.net/manual/plugins/win7audio/.
No need for the plugin, Win7Audio is included into Rainmeter setup, unlike external plugins, which have been developed by users and are not included (like Chameleon, for instance, but there are many more).

Ok, now I'm gonna try to create a good code and will come back once it's ready. Stay tunned...
You do not have the required permissions to view the files attached to this post.
CMDR_Evolution
Posts: 9
Joined: October 30th, 2020, 6:25 pm

Re: Dynamic GIF problems

Post by CMDR_Evolution »

balala wrote: January 9th, 2021, 7:06 pm You can add it below the field where you are writing your reply, on the Attachments tab:
Attachments.png
Oh I see, sorry about that and thank you. I've tried to attach it here but it's unfortunately too large. Hopefully the Google drive link was okay. Please let me know if I should split it into a couple and upload them here.
balala wrote: January 9th, 2021, 7:06 pmNo need for the plugin, Win7Audio is included into Rainmeter setup, unlike external plugins, which have been developed by users and are not included (like Chameleon, for instance, but there are many more).
That's good to hear, thanks.
balala wrote: January 9th, 2021, 7:06 pmOk, now I'm gonna try to create a good code and will come back once it's ready. Stay tunned...
Thank you Balala. I really appreciate it and sorry for my stupidity
User avatar
balala
Rainmeter Sage
Posts: 12095
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Dynamic GIF problems

Post by balala »

balala wrote: January 9th, 2021, 7:06 pm Ok, now I'm gonna try to create a good code and will come back once it's ready. Stay tunned...
Here is the rewritten code. Replace the old one with this. I didn't touch the other files (the frames for instance), so don't have to worry about them.

Code: Select all

[Rainmeter]
Update=1000
OnRefreshAction=[!CommandMeasure "MeasureAnimation" "Execute 1"]

[Variables]
UpdateSpeed=0
Animation=0
U=[!UpdateMeasure "MeasureAnimation"][!UpdateMeter "MeterImage"][!Redraw]

;[ImageNumberCalc]
;Measure=Calc
;Formula=Counter % 90

[MeasureWin7Audio]
Measure=Plugin
Plugin=Win7AudioPlugin.dll
Substitute="-1":"0"
;IfConditionMode=1
IfCondition=(#CURRENTSECTION#<=33)
IfTrueAction=[!SetVariable UpdateSpeed "30"][!UpdateMeasure "MeasureAnimation"]
IfCondition2=((#CURRENTSECTION#>33)&&(#CURRENTSECTION#<=66))
IfTrueAction2=[!SetVariable UpdateSpeed "20"][!UpdateMeasure "MeasureAnimation"]
IfCondition3=(#CURRENTSECTION#>66)
IfTrueAction3=[!SetVariable UpdateSpeed "10"][!UpdateMeasure "MeasureAnimation"]

[MeasureAnimation]
Measure=Plugin
Plugin=ActionTimer
Group=Sliders
ActionList1=Repeat Anim,#UpdateSpeed#,90
Anim=[!SetVariable Animation "((#Animation#+1)%90)"]#U#
IfCondition=(#Animation#>=89)
IfTrueAction=[!CommandMeasure "MeasureAnimation" "Stop 1"][!SetVariable Animation "0"]#U#[!CommandMeasure "MeasureAnimation" "Execute 1"]
DynamicVariables=1

[MeterImage]
Meter=Image
X=0
Y=0
ImageName=#@#PSU-#Animation#.png
AntiAlias=1
DynamicVariables=1
UpdateDivider=-1
See that I got rid of the [PercentageCalc] measure, which is not needed. The Ifconditions can be added directly to the [MeasureWin7Audio] measure and as usually the less measures, the better. I added the [MeasureAnimetion] ActionTimer plugin measure as well.
I also added an UpdateDivider=-1 option to the [MeterImage] meter, to never get it updated. When the animation plays, the [MeasureAnimation] measure updates regularly the Image meter (through the [!UpdateMeter "MeterImage"] bang of the U variable).
If you'd like to adjust the speed of animation, replace the values set to the UpdateSpeed variable into the !SetVariable bangs of the IfTrueAction options of the [MeasureWin7Audio] measure.
Please test the code and let me know what you think ybout it.
User avatar
balala
Rainmeter Sage
Posts: 12095
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Dynamic GIF problems

Post by balala »

CMDR_Evolution wrote: January 9th, 2021, 8:00 pm Oh I see, sorry about that and thank you. I've tried to attach it here but it's unfortunately too large. Hopefully the Google drive link was okay. Please let me know if I should split it into a couple and upload them here.
There is a limit of the file size you can upload. But it's ok with the Google Drive link, I downloaded the package and got the frames. So, no need to split anything, it alright.
CMDR_Evolution wrote: January 9th, 2021, 8:00 pm I really appreciate it and sorry for my stupidity
No stupidity at all, forget this. No experience, doesn't mean stupidity (should see what have I asked when posted my first question). Don't worry, if you'll keep using Rainmeter (which I recommend, me at least love it), you gonna realize all these and much more.
CMDR_Evolution
Posts: 9
Joined: October 30th, 2020, 6:25 pm

Re: Dynamic GIF problems

Post by CMDR_Evolution »

Hi again Balala,

Oh wow! I'm very impressed! This is exactly what I was trying to do and hoping for :D.

I've had a play around with the numbers and added some extra conditions to make the animation slower (to reduce the small usage on the GPU) and to change every 10%. I'm really pleased with it, thank you! :thumbup:

With your brilliant work, I'm sure a lot of people could find a lot of use in the future when they stumble across this thread - for a skin that adjusts GIF animation speeds based on an input/sensor etc. Thanks again mate :D