Page 1 of 1

scripting a pad with a blinking "on" state [SOLVED]

Posted: 03 Apr 2017 22:00
by dburns
Hey Guys,
I'm trying to script a pad to be blinking on and off while "on" and switching to a darker colour when off. I created an expression for the blink which works great if I plug it into the "light=" properties-

blink=sin(time*3)/3+.1+.1

I can use the script below to toggle a pad's light bright and dark -

on expression x rising-
if (!light) light=.8;
else light = 0;

... but the pad is either lit up when on or dark when off. I'm looking for a flashing "on" signal kinda thing. I specifically need to use a pad not a switch. Any help appreciated.

Re: scripting a pad with a blinking "on" state

Posted: 04 Apr 2017 10:22
by oldgearguy
instead of doing this,

on expression x rising-
if (!light) light=.8;
else light = 0;

what about if you defined a global variable called offset and initialized it to 0:
offset = 0;

and changed your blink expression to:

blink=sin(time*3)/3+.1+.1 + offset

and your then expression is:

if (!light) offset = 0; // or whatever value you need to make it bright enough
else offset = -2; // or whatever value you need to make it dark as needed


The idea being that the light property has a range of -2 to +2 and sine() is -1 to +1 so if you add an offset to the equation, you can override whatever sine() produces.

Re: scripting a pad with a blinking "on" state

Posted: 04 Apr 2017 21:16
by dburns
That's some mighty fine logical thinking. But I couldn't get liftoff. It doesn't seem to me to be toggling. This is so easy to do with a second object, but the whole point is to do it with the one pad only.

I'm wondering how to script something that takes a pad press and sequentially switches between two states. That way i could make "state one = blink" and "state two = off"......somehow.

Re: scripting a pad with a blinking "on" state

Posted: 05 Apr 2017 07:53
by lABl
Hi there,

I've attached an example, you can change a little bit the behavior from these three variables if you wish:

flashMaxLight
pulseRate
pulseWidth


Hope that helps,
Cheers!

Re: scripting a pad with a blinking "on" state

Posted: 05 Apr 2017 15:11
by dburns
Hey IABI, you are bang on. I will study this and try to learn. Thank you so much, I can honestly say I would've never come to this logic on my own.

Thank You again!