Forum Replies Created

  • Joss Gitlin

    February 13, 2021 at 5:46 am in reply to: Unable to get value at previous frame

    I finally got it!

    This expression checks the past 3 frames to see if they all fall below the threshold, and if so, executes a command.

    x = thisComp.layer(“A_BASS”).effect(“Both Channels”)(“Slider”);
    threshold = 50.0;

    wentBelow = false;
    isBelow = false;
    frame = Math.round(time / thisComp.frameDuration);
    oldFrame = Math.round(time / thisComp.frameDuration) – 3;

    d = 3;
    n = 0;
    while (frame > oldFrame){
    t = frame * thisComp.frameDuration;
    if (x.valueAtTime(t) >= threshold){
    n=100+x;
    wentBelow = false;
    break;
    }
    else wentBelow = true;
    if (wentBelow){
    d–;
    if (d < 1) {
    n = 102;
    break;
    }
    }
    else if (x.valueAtTime(t) < threshold){
    wentBelow = true;
    }
    frame–
    }

    n

  • Joss Gitlin

    February 13, 2021 at 4:57 am in reply to: Unable to get value at previous frame

    Well Dan, I’m ashamed to admit it, but I’m stuck.

    x = thisComp.layer(“A_BASS”).effect(“Both Channels”)(“Slider”);
    threshold = 50.0;

    below = false;
    frame = Math.round(time / thisComp.frameDuration);
    oldFrame = Math.round(time / thisComp.frameDuration) – 3;

    d = 3;
    n = 0;
    while (frame > oldFrame){
    t = frame * thisComp.frameDuration;
    if (below){
    if (x.valueAtTime(t) >= threshold){
    n=100+x;
    below = false;
    }
    else d–;
    }
    else if (x.valueAtTime(t) < threshold && d < 1){
    below = true;
    n=102;
    d = 3;
    }
    frame–
    }

    n

    I need the ‘else if’ statement to only trigger when the x value is below the threshold for 3 consecutive frames, which is what I’m attempting to use the d variable for.

  • Joss Gitlin

    February 10, 2021 at 2:40 am in reply to: Unable to get value at previous frame

    Gotcha. I saw you use a similar approach on your website for an audio threshold expression. I’ll look into that. I really only need to look back on the previous 3 frames

  • Joss Gitlin

    February 9, 2021 at 6:38 pm in reply to: Unable to get value at previous frame

    Oops. I had somehow left that extra “*time” in there!

    Is it not possible to get the value calculated by the expression at the previous frame? That’s exactly what I need to do…

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