Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects Expressions › TIME REMAP EXPRESSION HELP NEEDED!

  • TIME REMAP EXPRESSION HELP NEEDED!

    Posted by Chouhdry Atif on December 24, 2020 at 4:46 pm

    Hi there I am working on a project where I have some motion graphic looped backgrounds which I want to react with my audio.

    so what I did is I made a NULL LAYER(C1) and put an expression slider to it..

    then I add a time remapping on my video background composition and put this expression

    ”

    a=0 // the start-value for time-remapping if not 0

    t=0;

    b=thisComp.frameDuration;

    while(time>t && time>=inPoint) {

    c=thisComp.layer(“c1”).effect(“Slider1”)(“Slider”).valueAtTime(t);

    a+=c*b;

    t+=b;

    }

    a-inPoint;

    ”
    so now this layer is connected with slider layer which is “C1”

    so now I want a global control layer with new slider controller “C2” from where I can control the reaction speed depending on different music’s.

    If I simply Pickwhip “C1” to AUDIO AMPLITUDE LAYER it reacts with audio but it’s too fast and if song duration is 3 minutes it stops reacting at half i.e. “1.5 minutes”.
    which is not I want.
    can you please tell me what expression or value I need to add on C1 so it works perfectly.

    Thank you very much for your time.

     

    Filip Vandueren replied 5 years, 9 months ago 2 Members · 3 Replies
  • 3 Replies
  • Filip Vandueren

    December 28, 2020 at 8:12 pm

    Make a new Slider on your Audio Amplitude Layer and name it “total”.

    Give it this expression:

    posterizeTime(0) // should force After Effects to only calculate once
    prop = effect("Both Channels")("Slider");
    total = 0
    for (k=1; k<=prop.numKeys; k++) {
    total+=prop.key(k).value;
    }
    total

    This gives us the total of all the keyframes added up.

    If you see that that value is maxed out like 1000000,00, then simply add an expression something like “value/10000” to your “Both Channels” slider, until the total is an actual value. What value it is does not matter at all, just that it is not “clipped” because it is a too high number.


    We can use this total we calculated to make sure the modulation of your timeremapping ends exactly at the end of the video’s time when the music ends.

    Like this:

    a=0 // the start-value for time-remapping if not 0
    e=19 // the end-value for timeremapping (just a 19second example here)
    b=(e-a)/thisComp.layer("Audio Amplitude").effect("total")("Slider").value;

    t=0;

    f = thisComp.frameDuration;
    while(time>t && time>=inPoint) {
    c=thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider").valueAtTime(t);
    a+=c*b;
    t+=f;
    }
    a-inPoint;

    If you find this modulation is not pumping enough, then what you actallu want is more exrreme differences between quiet and loud peaks of the “both-channels” effect.

    I find that squaring, or a higher power it works best, Expression for “Both Channels”:

    Math.pow(value/70,4)/1; // be sure to check the value doesn't clip again -> adjust /1000

    But it all depends on your source footage: zooming through a 6 minute video within 3 minutes will always be more dynamic than pumping through a 2 minute video with 3 mijnutes audio.

  • Chouhdry Atif

    December 30, 2020 at 3:11 am

    thank you so much for this HELP Filip but I can’t add any effect to AUDIO AMPLITUDE layer because I am working on a project which is like a template to sell, so I want it to be user friendly.

    I figured out everything but there is still one thing I am still stuck at, i.e. I want to control the speed of video reaction with a slider and I couldn’t figure out what expression it possible be?

  • Filip Vandueren

    December 30, 2020 at 9:20 am

    Hi Choudry,

    you can place my expressions on a different layer as well, that doesn’t really matter, just need to change some of the references.

    Raising the Audio amplitude to a power remains the best option to increase the effect the audio modulation has, just multiplying or adding a value to it doesn’t really work IMO.

    If you don’t use the sum of all audio amplitudes in calculate the modulation, then you’ll always run into some trouble, either too much or not all of the video’s running time will be used in the final result. So are you just going to ask the user of your templates to experiment with a scaling slider until the video doesn’t run out ?

    If you want the only user interaction to be that they manually have to create the Audio Amplitude layer (no way around that I guess, or you could bundle a script with the template maybe ?), then I propose this:

    A second null layer with:

    A slider to control the depth/punch of the audio (this would be the power the audio gets raised to) -> this is the only thing that needs to be visible for user interaction

    (so these next controls that are just there for calculation can be on a shy layer:)

    A Point Control (Power value) that “copies” the values of the audio amplitudes and adds a power function. (Point Control values don’t get clipped to 1,000,000.0 !)

    a=thisComp.layer("Audio Amplitude").effect("Left Channel")("Slider");
    p=effect("Power")("Slider");
    if (p<0) p=0;
    [Math.pow(a,p),0]

    A last point control that calculates the running sum of the audio amplitudes, using the posterizeTime(0) trick so it only needs to calculate once, not every frame:

    posterizeTime(0);
    total=0
    for (t=0; t<thiscomp.duration; t+="thisComp.frameDuration)" {<br=""> total+=effect("Power value")("Point").valueAtTime(t)[0]
    }
    [total,0]</thiscomp.duration;>

    Finally, the actual expression for timeremapping stays the same as before (once you change the references to the new positions of the data, don’t forget we only need [0] of the point controls values)

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