Page 1 of 1

Idea/help for expression needed

Posted: Sun Jan 09, 2022 9:52 pm
by TKS
I have a global with oscillates from 0.3 to 1.3:

Code: Select all

value := sin(TIME) + 0.3

I would like to increase another global (myTrigger) each time this value hits 1.3

Code: Select all

if(value == 1.3, myTrigger++, myTrigger)
Problem: with float, you can't compare exact values.
Workarounds (if value > 1.299) or using the "step" operator are not precise enough, it either doesn't trigger at all or multiple times.

Any ideas?

Re: Idea/help for expression needed

Posted: Mon Jan 10, 2022 12:31 pm
by Sadler
How about "if floor(value*100) = 130"

Just tried this myself - no cigar.

This seemed to work however:
Set the global oscillator to oscillate between 0 and 1.3001
Set the global oscillator to oscillate between 0 and 1.3001
Screenshot 2022-01-10 124243.png (15.55 KiB) Viewed 4094 times

Re: Idea/help for expression needed

Posted: Mon Jan 10, 2022 3:53 pm
by TKS
Sadler wrote: This seemed to work however:
Screenshot 2022-01-10 124243.png
Yep, found an okayish solution with the trigger-modifier myself, even when it would be more convenient to have a "TriggerUp" and additionally a "TriggerDown" modifier. Thanks a lot, Sadler!

The only thing which still annoys me is that I didn't find a solution (other then restarting MMV) to reset the value of the trigger modifier to "0" when a video starts...

Re: Idea/help for expression needed

Posted: Mon Jan 10, 2022 4:38 pm
by Sadler
I didn't find a solution (other then restarting MMV) to reset the value of the trigger modifier to "0" when a video starts
Could you put a Restart module after your trigger then reset when PlayBackTime = 0 ???

There isn't any mechanism to update globals or push event notifications to other modules, never mind their params or modifiers. I believe there's been some discussion on here but since TD fills that role, that's the advice given.

Re: Idea/help for expression needed

Posted: Mon Jan 10, 2022 4:54 pm
by Magic
In response to your original post, you are making things way too complicated for yourself. All you want is a trigger that goes off every so often. So just use an Increase modifier as your timer. Adjust parameter as needed to make slower or faster. Then put an Integer trigger afterwards.

If you need an oscillator for something additional, then put the Increase modifier in a global, and do sin(myGlobal). This way the timing will be synchronized.