It is currently December 7th, 2021, 1:02 pm

Bell ring clock skin

Help with creating, editing & fixing problems with skins
User avatar
jsmorley
Developer
Posts: 22419
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Bell ring clock skin

Post by jsmorley »

Yincognito wrote: July 18th, 2021, 1:55 am Any particular reason to use 2 AT measures since 1 AT can hold both action lists, and doesn't force the user to use both?
Regarding testing, you're probably right, but in this case it would take lots of time changes in the OS to make sure the code is properly working in all more or less fringe scenarios. That is why I opted for an explanation rather than posting a full code as well. I agree on the thinking twice before doing something principle though.


Since we're at this, do you see a drawback in using !Delay in my approach? Since in a way, that's also kind of blocking, as far as I recall...
One or two ActionTimer measures, it's six of one half dozen of the other in my view. The key is that the "minute" play must not be allowed to start until the "hour" play is done. The first ActionTimer (or ActionList) must call the second one when it is fully done.

Yes, !Delay is blocking. That is kinda the point of it in a sense. I'd never use it for delays over a second or so myself.

P.S. I wasn't pointing at you at all in my comment about testing before posting. I was trying to gently point out that that original Lua solution posted was entirely broken, and really should never have been posted.
User avatar
Yincognito
Rainmeter Sage
Posts: 4108
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Bell ring clock skin

Post by Yincognito »

jsmorley wrote: July 18th, 2021, 2:02 am One or two ActionTimer measures, it's six of one half dozen of the other in my view. The key is that the "minute" play must not be allowed to start until the "hour" play is done.

Yes, !Delay is blocking. That is kinda the point of it in a sense. I'd never use it for delays over a second or so myself.
I see. Then IfConditions would probably be suited over the OnChangeActions, since you could sequentially play hours then minutes if the hours changed and the minutes are 0 (which only happens once every 4 set of "ringings"), and otherwise play just the minutes.

I think I'm gonna put this into code, it's kind of difficult to anticipate exactly what will happen just in "theory"... :???:
jsmorley wrote: July 18th, 2021, 2:02 amP.S. I wasn't pointing at you at all in my comment about testing before posting. I was trying to gently point out that that original Lua solution posted was entirely broken, and really should never have been posted.
I realized that. I was trying to be gentle as well, towards everyone involved. :D
User avatar
jsmorley
Developer
Posts: 22419
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Bell ring clock skin

Post by jsmorley »

Yincognito wrote: July 18th, 2021, 2:11 am I see. Then IfConditions would probably be suited over the OnChangeActions, since you could sequentially play hours then minutes if the hours changed and the minutes are 0 (which only happens once every 4 set of "ringings"), and otherwise play just the minutes.

I think I'm gonna put this into code, it's kind of difficult to anticipate exactly what will happen just in "theory"... :???:
Yeah, you have several issues to solve as gracefully as possible.

1) The hours play should only be fired when the hour first changes, the best test is the minutes and seconds are zero.
I probably wouldn't use OnChangeAction on the hours, although I guess you could. The better test for me is any hour, but minutes and seconds are zero.
2) The minutes play should only be fired when the minutes first change to one of 15/30/45, and the seconds are zero.
On reflection, I think it is dumb to fire the minutes when they are at zero. The hours ringing tells you the minutes are at zero, and not having "both" ever fire greatly simplifies things.
3) You will need to !SetOption or !SetVariable the "repeat" count in the ActionTimer as appropriate for the hours / minutes.
4) The Play commands must not be played on top of themselves. Executing a second will instantly kill the first.
I wouldn't even consider !Delay. I'd use the "wait" parameter in the ActionTimer measure(s). How long to wait? That will need to be trial and error. Keep in mind you are not waiting some time "in between" the sounds, but a total amount that includes the length of the sound and any time in between.

The play command is obviously not "asynchronous", but it is also not "serial", it's more like "exclusive".


In my view, the key to solving this is to lay out the "rules" as I have above. I'm sure I missed something or other, and while no plan of attack survives the first shot being fired, I think it's a good starting point.
User avatar
death.crafter
Rainmeter Sage
Posts: 1206
Joined: April 24th, 2021, 8:13 pm

Re: Bell ring clock skin

Post by death.crafter »

jsmorley wrote: July 18th, 2021, 1:09 am In and of itself, I believe that is going to ring on every single update. You will need to put this in a different function, and call it with an IfCondition on the Time measure, where it will only fire once when the hour and / or minute first turns. Some kind of If seconds = 0. Either that, or build the "only fire once when the seconds are zero" test into the Lua.

In addition there is no way in the world you can possibly have a sound short enough to be allowed to even start to play through before that loop will instantly tell it to play again, stopping the first one. You have to keep in mind how the Play command works... I believe you will hear the sound once, no matter the hour or minute.
I kind of thought about updating it every 15 minutes but then again that wouldn't work too. Sorry for the wrong info freeraider.
from the Realm of Death
User avatar
death.crafter
Rainmeter Sage
Posts: 1206
Joined: April 24th, 2021, 8:13 pm

Re: Bell ring clock skin

Post by death.crafter »

Okay, a more feasible solution, if not the perfect one.

Code: Select all

[Variables]
Hour0=
Hour1=[Play hourSound]
....

Minute0=[!Delay "([Hour:] =0 ? soundDuration : 0)"][Play minuteStartSound]
Minute1=[Play minuteSound]
Minute2=[Play minuteSound][!Delay soundDuration][Play minuteSound]
Minute3=[Play minuteSound][!Delay soundDuration][Play minuteSound][!Delay soundDuration][Play minuteSound]

[Hour]
Measure=Time
Time=%#H
OnChangeAction=[#Hour[&Hour]]
DynamicVariables=1

[MinuteRaw]
Measure=Time
Time=%M

[Minute]
Measure=Calc
Formula=Floor(MinuteRaw/15)
OnChangeAction=[#Minute[&Minute]]
DynamicVariables=1

[StartoftheDay]
Measure=Time
Format=%H:%M
IfMatch=^00:00$
IfMatchAction=[!Play hourStartSound]
Edit: On a second note, you can use lua to set the variables in the begining.

Lua:

Code: Select all

function Initialize()
	local s='[Play hourSound]'
	for i= 2, 23, 1 do
		s=s+'[!Delay soundDuration][Play hourSound]'
		SKIN:Bang('!SetVariable', 'Hour'..i, s)
	end
	SKIN:Bang('!Update')
end
Okay, so I edited the skin to remove the delay I had before in [Minute]'s OnChangeAction. Since there is no alarms to bell at 00:00. For that, I added another Time measure.
Last edited by death.crafter on July 18th, 2021, 4:53 am, edited 5 times in total.
from the Realm of Death
User avatar
Yincognito
Rainmeter Sage
Posts: 4108
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Bell ring clock skin

Post by Yincognito »

I was delayed by a damn typo I had in the skin ("Hour" vs "Hours") and a complete misunderstanding of what the OP wants, but:
Test_1.0.0.rmskin
Code:

Code: Select all

[Variables]
Interval=2500

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
BackgroundMode=2
SolidColor=47,47,47,255

---Measures---

[Ring]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat HourRing,#Interval#,[HourRings] | Wait #Interval# | Repeat MinuteRing,#Interval#,[MinuteRings] | Wait #Interval#
HourRing=[Play "#@#Bell1.wav"]
MinuteRing=[Play "#@#Bell2.wav"]
UpdateDivider=-1
DynamicVariables=1

[Hours]
Measure=Time
Format=%H

[Minutes]
Measure=Time
Format=%M

[HourRings]
Measure=Calc
Formula=(Trunc(Hours/1))
DynamicVariables=1

[MinuteRings]
Measure=Calc
Formula=(Trunc(Minutes/15))
OnChangeAction=[!UpdateMeasure Ring][!CommandMeasure Ring "Stop 1"][!CommandMeasure Ring "Execute 1"]
DynamicVariables=1

---Meters---

[Time]
Meter=String
FontFace=Consolas
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
MeasureName=Hours
MeasureName2=Minutes
LeftMouseUpAction=[Play "#@#Bell1.wav"]
Text="%1:%2"
The things are much more simple than I and jsmorley previously thought. The OP actually wants both bells every 15 minutes, depending on the hours and the minutes, meaning a single OnChangeAction is enough (for minutes' integer division by 15) and the ringing can be used sequentially (i.e. hours then minutes) directly in a single ActionList in the AT measure.

P.S. Pardon my "bells", LOL. I also left a LeftMouseUpAction in the meter by mistake, but you can use to test sounds with that.
You do not have the required permissions to view the files attached to this post.
Last edited by Yincognito on July 18th, 2021, 4:13 am, edited 1 time in total.
User avatar
Yincognito
Rainmeter Sage
Posts: 4108
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Bell ring clock skin

Post by Yincognito »

death.crafter wrote: July 18th, 2021, 3:40 am

Code: Select all

Formula=MinuteRaw%15
You still use modulus (%), I see - guess you didn't catch my last line here. That would fire every minute, not every 15 minutes...
Also, Measure=[Calc] is probably some typo.
User avatar
death.crafter
Rainmeter Sage
Posts: 1206
Joined: April 24th, 2021, 8:13 pm

Re: Bell ring clock skin

Post by death.crafter »

Yincognito wrote: July 18th, 2021, 4:02 am You still use modulus (%), I see - guess you didn't catch my last line here. That would fire every minute, not every 15 minutes...
Also, Measure=[Calc] is probably some typo.
Haha. You didn't catch the method this time. Even if minute changes, Minute%15 wouldn't change until it crosses 0, 15, 30 or 45. So basically, the [Minute] will have just 4 values, 0, 1, 2, 3. So in the latest update of the post, I just took care of delay duration and stuff.

And thanks for catching the [Calc].

Wait, may be I am dumb. I ought to use / and not %. Sorry my bad. :Whistle
from the Realm of Death
User avatar
Yincognito
Rainmeter Sage
Posts: 4108
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Bell ring clock skin

Post by Yincognito »

death.crafter wrote: July 18th, 2021, 4:08 am Haha. You didn't catch the method this time.
[...]
Wait, may be I am dumb. I ought to use / and not %. Sorry my bad. :Whistle
So, which one is it, after all? :p
User avatar
death.crafter
Rainmeter Sage
Posts: 1206
Joined: April 24th, 2021, 8:13 pm

Re: Bell ring clock skin

Post by death.crafter »

Yincognito wrote: July 18th, 2021, 4:15 am So, which one is it, after all? :p
I already edited the post with Round(MinuteRaw/15). Thanks for pointing out. Actually I thought of dividing but I used %.

Today I am unconciously disturbed :rolmfao:
from the Realm of Death