Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Is there a expression which can : value + previous value

  • Is there a expression which can : value + previous value

    Posted by Kurisuta Vd wilk on February 3, 2012 at 5:17 pm

    hello !

    i made a NUll object with : Converting audio to keyframes.

    With this data i would like to time remap a animation.

    When i link time remap to the slider
    The animation will go forward and back on the beat.

    Converted audio slider: linear(value,0,100,0,10)+time
    Animation layer time remap: thisComp.layer(“Audio Amplitude”).effect(“Both Channels”)(“Slider”)

    But i want it to go forward at the pace of the music but NOT backward.
    So i am looking for a expression which can count the current and the previous value together ..

    Hope this makes sense and someone can help me.
    Greetings Krista !!

    No knowledge is a Statement

    Sacha Crispin replied 3 years, 3 months ago 6 Members · 8 Replies
  • 8 Replies
  • Paul Roper

    February 3, 2012 at 6:01 pm

    Having variables accumulate over time in After Effects is a real pain, but Dan’s your man for this kinda thing; this will hopefully help you a lot:

    https://www.motionscript.com/design-guide/audio-count.html

    – Paul

  • Paul Roper

    February 3, 2012 at 6:07 pm

    …If you want to use Dan’s expression to control a 2-dimensional array (eg. 2D position), just change the last line ( n ) to this, where the *20 is to amplify the amount of movement – change it to suit your needs.

    [n*20,value[1]]

  • Immanuel Morales

    February 12, 2012 at 4:39 pm

    try using .valueAtTime([time]-[seconds]) and .frameDuration*[number of frames].

    var prev = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider").valueAtTime(time-thisComp.frameDuration*2);

  • Kurisuta Vd wilk

    February 14, 2012 at 10:12 am

    i cannot check it right now, but this sounds as a reasonable solution !!

    No knowledge is a Statement

  • Juan Irache

    September 22, 2019 at 11:42 am

    I was recently facing a similar problem, where I needed to do some calculation in every frame and add it to a total from the previous frame. The problem with looping through every frame to the current one in every frame is the render becomes increasingly painful for the machine in every frame.

    My solution was to make all the calculations on a text layer, in the first frame: I loop through all the frames, push the value of every frame to an array, and print the array as the Source Text. Someting like this:

    mSource = thisComp.layer("source layer");
    if (time == mSource.inPoint) {
    totalValue = 0
    values = [0];

    for (i=timeToFrames(mSource.inPoint); i

    Then, wherever the value has to appear, I pick the text from the first frame, split it by comma to create an array and pick the index corresponding to the frame I'm at:

    mSource = thisComp.layer("source layer");
    arr = thisComp.layer("text layer").text.sourceText.valueAtTime(mSource.inPoint);
    mIndex = timeToFrames(time - mSource.inPoint);
    val = arr.split(',')[mIndex];
    val

    The difference in rendering speed is night and day.

  • Sacha Crispin

    January 4, 2023 at 11:41 pm

    Hi Kurisuta! I’ve been trying to understand your explanation for 3 days now but can’t make it work. Would you mind sharing a project file or giving ampler explanation please? Thank you!

  • Dan Ebberts

    January 4, 2023 at 11:59 pm

    This might be helpful (the section on time remapping):

    http://www.motionscript.com/articles/speed-control.html#other-applications

  • Sacha Crispin

    January 6, 2023 at 8:56 pm

    Oh wow thank you so much Dan! Will browse your blog even more now when I’m looking for help from now on. Thank you so much. ❤

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