Previous topicNext topic

Idea/help for expression needed

Questions, comments, feedback, etc.
Post Reply
TKS
Posts: 139
Joined: Mon May 17, 2021 10:40 am

Idea/help for expression needed

Post 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?
Sadler
Posts: 1139
Joined: Sat Aug 02, 2014 7:10 pm
Location: London, UK

Re: Idea/help for expression needed

Post 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 3357 times
TKS
Posts: 139
Joined: Mon May 17, 2021 10:40 am

Re: Idea/help for expression needed

Post 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...
Sadler
Posts: 1139
Joined: Sat Aug 02, 2014 7:10 pm
Location: London, UK

Re: Idea/help for expression needed

Post 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.
Magic
Site Admin
Posts: 3440
Joined: Wed Apr 09, 2014 9:28 pm

Re: Idea/help for expression needed

Post 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.
Post Reply