Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions How to Modify the “Triggering expression with audio”

  • How to Modify the “Triggering expression with audio”

    Posted by Darren Caruana on January 29, 2015 at 11:39 am

    Hello I am new to expressions , the motionscript.com site is very helpful , but whenever I try to modify an expression , I get stuck.
    For example I looked for an expression to trigger animations with audio and got this

    threshold = 10.0;

    audioLev = thisComp.layer(“Audio Amplitude”).effect(“Both Channels”)(“Slider”);

    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;
    }

    amp = 25;
    freq = 5;
    decay = 4.0;

    angle = freq * 2 * Math.PI * t;
    wobble = 1 + amp * Math.sin(angle) / Math.exp(decay * t) / 100;
    [value[0] * wobble, value[1] / wobble]

    But how about if I want to change the wobble expression with something else like a random scale or position ? Meaning that a layer is displayed in a random position triggered with specified audio threshold.
    Sorry If this is a stupid question , I am new and thanks Dan Ebberts for helping people like me.

    For random scale found that this worked perfectly for me ;

    frame = Math.round(time/thisComp.frameDuration);
    seed = Math.floor(frame/15);
    seedRandom(seed,true);
    s = random(50,100);
    [s,s]

    and another one for random position and found this ;

    holdTime = .5; //time to hold each position (seconds)
    minVal = [0.1*thisComp.width, 0.1*thisComp.height];
    maxVal = [0.9*thisComp.width, 0.9*thisComp.height];

    seed = Math.floor(time/holdTime);
    seedRandom(seed,true);
    random(minVal,maxVal)

    Darren Caruana replied 11 years, 6 months ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

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