Killing Time(ers)

timothyallan

2007-08-20 13:22:32

Hi Florian, awesome bit of programming you've done :) . I have a quick question for you regarding MT Pro:

I have a midi button down press coming in at 7F.
First translater sets GA to 0.
Second translator triggers a timer that increments GA by 1 every 20ms

On midi button up 00 it kills that timer.

Also on that same button up 00 I have another timer that now starts decrementing GA by 1 every 20ms.

GA=GA-1
GA=GA-1
GA=GA-1
GA=GA-1
...

until GA = 0. How do I get the decrementing timer to stop when GA hits 0 without hitting any buttons? If timers could be executed GA times, it would solve it, but in the meantime? ;)

Cheers,
Tim

florian

2007-08-21 01:28:11

I assume the second timer's Outgoing Action is None? then you can do this:

Code: Select all

Incoming: Timer 2
Rules:
 ga=ga-1
 if ga>0 Exit Rules, Do Not execute outgoing action
Outgoing: Kill Timer 2
Another way of optimizing (but not improving otherwise) is to use a variable gb as the amount of add/subtract:

Code: Select all

Translator 1: start timer
Incoming: button down 7f
Rule:
 ga=0
 gb=1
Outgoing: start Timer 1

Translator 2: reverse ga direction
Incoming: button up 00
Rule:
 gb=-1
Outgoing: None

Translator 2: on timer
Incoming: Timer 1
Rules:
 ga=ga+gb
 if ga>0 Exit Rules, Do Not execute outgoing action
Outgoing: Kill Timer 1
That way you don't need a second timer.

Regards,
Florian