Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Random value every X frames offset?

  • Random value every X frames offset?

    Posted by Daniel Rivas on August 26, 2020 at 3:58 pm

    Hello, I’m using a simple random expression every 13.7 frames (every beat of a song) but the expression begins 5 frames into the clip (instead of 13.7 frame, a beat), so the effect changes every half beat, I need it to change every beat. I’m pretty new to expressions and I’m wondering if there’s a way to offset the beginning of an expression if i’m not missing something. Thanks.

    Composition fps = 23.976
    Song bpm = 105

    period = 13.7; // frames
    posterizeTime(1/(period*thisComp.frameDuration));
    random(-50,50);

    Daniel Rivas replied 5 years, 11 months ago 2 Members · 6 Replies
  • 6 Replies
  • Dan Ebberts

    August 26, 2020 at 4:27 pm

    Try it this way:

    period = 13.7; // frames
    seed = Math.floor(time/(period*thisComp.frameDuration));
    seedRandom(seed,true);
    random(-50,50);

    Dan

  • Daniel Rivas

    August 26, 2020 at 4:51 pm

    Hey, thanks for the quick response. The expression still applies every half beat but I thought I’d add that i’m using this expression on a trimmed adjustment layer that lasts 109 frames. I apologize in advance if the problem has been something obvious I haven’t noticed.

  • Dan Ebberts

    August 26, 2020 at 4:53 pm

    Where does the first beat occur relative to the layer’s in point?

    Dan

  • Dan Ebberts

    August 26, 2020 at 5:06 pm

    This might work better:

    period = 13.7; // frames
    offset = 5; // first beat relative to in point
    seed = Math.floor((timeToFrames(time-inPoint) – offset)/period);
    seedRandom(seed,true);
    random(-50,50);

    Dan

  • Daniel Rivas

    August 26, 2020 at 5:09 pm

    The first beat lands on the layer’s in point so I think ideally the expression should wait for the first 13 frames and then apply the random.

  • Daniel Rivas

    August 26, 2020 at 5:13 pm

    Hey, that worked. Just changed the offset to 13.7 and the effects are now vibing with the beat.

    Thanks a lot Dan.

    period = 13.7; // frames
    offset = 13.7; // first beat relative to in point
    seed = Math.floor((timeToFrames(time-inPoint) - offset)/period);
    seedRandom(seed,true);
    random(-50,50);

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