Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Accumulating values (one more try)

  • Accumulating values (one more try)

    Posted by Quba Michalski on January 12, 2011 at 3:20 pm

    Hello,

    I have searched wide and tall and could not find the answer to my problem anywhere.

    I am trying to create a set of expressions that would allow me to drive the animation by audio without the need of using Trapcode’s Sound Keys. Generally the plan is as follows:

    I use the standard built-in convert audio to keyframes command and generate the volume amplitude keyframes (my audio is heavy on drums so there is no need to separate frequencies).

    By analyzing the audio amp graph I create a simple expression which sets the value of the keyframe to 1 if there is a drum hit and to 0 if there is none. I use the following expression on a Slider Controller named “Reader”:
    Math.round(linear(effect("Both Channels")("Slider"),6,7,0,1));

    I then want to have a second Slider Controller, named “Pusher” that will increase its value each time it sees the Reader jump from 0 to 1.

    I detect the change using a simple if/then statement:
    reader=effect("Reader")("Slider");
    if (reader > reader.valueAtTime(time-thisComp.frameDuration) { ... }

    Now in the { … } section I would like to insert code that would increase my value. it seems however that AE resets all values at each frame. I tried writing something simple as:
    pusher=effect("pusher")("Slider").valueAtTime(time-thisComp.frameDuration) + 1;

    …but it does not seem to permit any kind of accumulation and resets each frame, effectively simply jumping between default 0 and added 1 values.

    Is there any workaround for this? Is it possible to store and accumulate values in AE?

    Quba Michalski
    qubahq.com

    Quba Michalski replied 15 years, 4 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    January 12, 2011 at 5:28 pm

    Variables don’t persist from frame to frame, so the work around is to construct a loop that looks at all previous frames to figure out how many beats there have been. This should help:

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

    Dan

  • Quba Michalski

    January 13, 2011 at 10:07 am

    OK, honestly, is there anything you CAN’T do, Dan? Amazing! I am (as always) very impressed and deeply thankful 🙂

    Now I just gotta figure out how to add a little bit of transition between the resulting keyframes and we have ourselves an extremely useful expression. No worries, I will try to tackle this one on my own 🙂

    f’n magnets, how do they work?
    Dan Ebberts, how does he do it?

    Quba Michalski
    qubahq.com

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