Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Triggering Animation with SoundKeys

  • Triggering Animation with SoundKeys

    Posted by Anders Hattne on November 4, 2021 at 5:27 pm

    There’s probably info out there on this, but I’m too stressed to find it!!

    The idea is to trigger timeRemap when a certain threshold is passed.

    I figure I could use Dan Ebberts “Triggering Expression With Audio” or Beat Counter; Say that layer 5 plays once the Threshold has been passed the 5th time…

    Tried that but the layer gets animated every time the threshold is passed..
    I just want it to be played once and then animate on various layers..
    See if I can get my head around the beatcounter and mix the two ideas together!!
    But this.. is above my current skillset ..

    Thankful for any replies!!

    threshold = 20.0;

    audioLev = thisComp.layer(“soundKeys Average”).effect(“Sound Keys”)(“Output 1”);

    above = false;
    frame = Math.round(time / thisComp.frameDuration);
    while (true){
    t = frame * thisComp.frameDuration;
    if (above){
    if (audioLev.valueAtTime(t) < threshold){
    frame++;
    break;
    }
    }else if (audioLev.valueAtTime(t) >= threshold){
    above = true;
    }
    if (frame == 0){
    break;
    }
    frame–
    }
    if (! above){
    t = 0;
    }else{
    t = time – frame * thisComp.frameDuration;
    }

    value + t

    Anders Hattne replied 4 years, 9 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    November 4, 2021 at 7:09 pm

    Not fully tested, but maybe something like this:

    beat = 5; // which beat to trigger on

    threshold = 20.0;

    audioLev = thisComp.layer("soundKeys Average").effect("Sound Keys")("Output 1");

    above = false;

    fCur = timeToFrames(time);

    f = 0

    fSave = [];

    n = 0;

    while (f <= fCur){

    t = framesToTime(f);

    if (above){

    if (audioLev.valueAtTime(t) < threshold){

    above = false;

    }

    }else if (audioLev.valueAtTime(t) >= threshold){

    above = true;

    n++;

    fSave.push(f);

    }

    f++;

    }

    (n >= beat) ? time - framesToTime(fSave[beat-1]) : 0

  • Anders Hattne

    November 4, 2021 at 7:36 pm

    Works like a charm!!

    I was butchering together the two expressions like Frankenstein and got a “time out while waiting for engine” as a monstrous result.
    Your solution works perfectly. Thank you so much!!

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