Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Blinking speed and offset

  • Blinking speed and offset

    Posted by Pierpaolo Ferlaino on October 7, 2015 at 10:38 am

    I have two problems with a blinking expression.
    I want a layer to blink and then the blink gradually slow down.

    I tried this expression


    freq =effect("frequency")("Slider");
    n = Math.sin(time*freq);
    if (sw<=0) 0 else 100

    and this one


    freq = effect("frequency")("Slider");
    amp = 100;
    n = freq.numKeys;

    if (n > 0 && freq.key(1).time < time){
    accum = freq.key(1).value*(freq.key(1).time - inPoint);
    for (i = 2; i <= n; i++){
    if (freq.key(i).time > time) break;
    k1 = freq.key(i-1);
    k2 = freq.key(i);
    accum += (k1.value + k2.value)*(k2.time - k1.time)/2;
    }
    accum += (freq.value + freq.key(i-1).value)*(time - freq.key(i-1).time)/2;
    }else{
    accum = freq.value * (time - inPoint);
    }
    sw = value + amp * Math.sin(accum * Math.PI * 2);
    if (sw<=50) 0 else 100;

    which I found on motionscript

    It works until my frequency is constant but when I use keyframes in the slider the blinking speeds up and then speeds down again when it reaches the new value...

    How can I make the blink gradually slow down?

    Moreover I want another layer to blink at the same speed but not in sync... Anyone can help?
    Thanks

    Kalleheikki Kannisto replied 10 years, 6 months ago 2 Members · 3 Replies
  • 3 Replies
  • Kalleheikki Kannisto

    October 7, 2015 at 5:52 pm

    Better blink expressions here:

    https://forums.creativecow.net/thread/227/14265

    Although you’ll have to connect the values to sliders that you can then animate.

  • Pierpaolo Ferlaino

    October 8, 2015 at 9:25 am

    Thanks for your answer.
    I tried the expression you mentioned but, for some reason, it does work if I link the values to a slider.

    What I’m trying to achieve is not a random blinking but a light constantly flashing at some speed then constantly slowing down to another value (eventually speeding up again at the original value).
    At the moment I pre-rendered a clip with my flashing light and used the timewarp effect but I’m guessing if it’s possible to do it using expression in some way.

  • Kalleheikki Kannisto

    October 14, 2015 at 8:42 am

    Your original expression (fixing the “sw” to “n”) works fine for what you describe.

    freq =effect("frequency")("Slider");
    n = Math.sin(time*freq);
    if (n<=0) 0 else 100

    If you animate the slider the blinking will speed up or slow down, unless you are using hold keyframes (which keep a constant value until the next keyframe).

    If you want another layer to blink differently, you can add something to the time value of the second line, for example

    n = Math.sin(time*freq+100*index);

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy