Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions I must be busy this morning, 2 posts!

  • I must be busy this morning, 2 posts!

    Posted by Olly Bea on April 11, 2008 at 10:56 am

    Hi

    I have this expression for opacity:

    g = thisComp.layer(“Bass 3”).effect(“Both Channels”)(“Slider”);

    if (g<5 || g>5) 100 – time*20 else 0

    I am trying to get the layer’s opacity to turn on (100%) then fade out over 5 secs if the value from the audio (converted audio keyframes) is greater than 5. But if the value from the converted audio is less than 5, opacity stays at 0%. Does anyone know where I am going wrong?

    Thanks, Olly

    P.S. Sorry Bert Brown I tried that link and the code didn’t seem to work.

    Olly Bea replied 18 years, 1 month ago 2 Members · 2 Replies
  • 2 Replies
  • Filip Vandueren

    April 11, 2008 at 1:37 pm

    Hi olly,

    The trouble with expressions is, they recalculate every frame, so the expression does not know that there was a peak a few frames ago.
    The solution is to actively look back at every frame for the last 5 seconds to see if there was a frame that peaked.
    This seems to work:


    prop=thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider");

    threshold=5;
    fadeOut=5; // in seconds

    t=time;
    while (t>time-fadeOut) {
    if (prop.valueAtTime(t)>=threshold) {
    break;
    }
    t-=thisComp.frameDuration;
    }

    linear (time, t, t+fadeOut, 100, 0)

  • Olly Bea

    April 11, 2008 at 2:26 pm

    that works brilliantly! Thanks loads

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