ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Is there a expression which can : value + previous value

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Krista van der Wilk
Is there a expression which can : value + previous value
on Feb 3, 2012 at 5:17:08 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


Return to posts index

Paul Roper
Re: Is there a expression which can : value + previous value
on Feb 3, 2012 at 6:01:04 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:

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

- Paul


Return to posts index

Paul Roper
Re: Is there a expression which can : value + previous value
on Feb 3, 2012 at 6:07:23 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]]


Return to posts index


Immanuel Morales
Re: Is there a expression which can : value + previous value
on Feb 12, 2012 at 4:39:13 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);


Return to posts index

Krista van der Wilk
Re: Is there a expression which can : value + previous value
on Feb 14, 2012 at 10:12:43 am

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

No knowledge is a Statement


Return to posts index

Juan Irache
Re: Is there a expression which can : value + previous value
on Sep 22, 2019 at 11:42:45 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<timeToFrames(mSource.outPoint); i++) {
// Make my calculations here
totalValue += localValue;
values.push(totalValue);
}

values
} else {
'not first frame'
}


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.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]