Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Blinking Effect for Audio Avatars

  • Blinking Effect for Audio Avatars

    Posted by Lewis Snook on February 19, 2016 at 11:37 am

    Hi,

    So I’ve been using Adobe After Effects to create Audio Avatars for videos.

    They are just small round smiley faces that use this code:

    temp = thisComp.layer(“Audio Amplitude”).effect(“Both Channels”)(“Slider”);
    [100, thisComp.layer(“Audio Amplitude”).effect(“Both Channels”)(“Slider”) * 7]

    This code is attached to the size function of a black semi-circle which acts as the mouth and talks when the linked audio picks up sound. So when there is audio, the black semi-circle gets bigger, and when all is quiet, it shrinks to the size of a flat line.

    What I am trying to achieve now is the exact reverse to create a blinking effect for the eyes. So for the eyes which are black circles I want them to shrink when audio is picked up as opposed to grow. This saves me from actively creating hundreds of keyframes where I am manually having to shrink the eyes every so often to create this effect; it will instead be opperated automatically by the code.

    Any ideas on how I can achieve this?

    temp = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider");
    [100, thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider") * 7]

    Dan Ebberts replied 10 years, 5 months ago 2 Members · 6 Replies
  • 6 Replies
  • Dan Ebberts

    February 19, 2016 at 5:10 pm

    Play with this (it should get you close):

    minAudio = 0;
    maxAudio = 20;
    minSize = 10;
    maxSize = 100;
    a = thisComp.layer(“Audio Amplitude”).effect(“Both Channels”)(“Slider”);
    s = linear(a,minAudio,maxAudio,maxSize,minSize);
    [value[0],s]

    Dan

  • Lewis Snook

    February 19, 2016 at 11:42 pm

    You sir are a legend, this code works great. I may need to fiddle with the numbers to try and make it a little less extreme, but no, this can work!

  • Lewis Snook

    March 4, 2016 at 9:11 pm

    Since you very helpfully gave me the starting point to mastering my blinking effect, I was wondering if you could help with the final touches to perfecting it.

    The code you gave me was an excellent starting point, but I have since thought of a better way, but I don’t know how (since at the moment the face looks like it is sneezing when it talks)

    So here’s what I have done.

    Instead of having one layer with your code attached, there are two layers (two black circles – the eyballs)

    The top layer has it’s opacity synced with the Audio with this expression:

    minAudio = 0;
    maxAudio = 20;
    minValue = 0;
    maxValue = 100;
    a = thisComp.layer(“Audio Amplitude”).effect(“Both Channels”)(“Slider”);
    s = linear(a,minAudio,maxAudio,maxValue,minValue);

    And the bottom layer has this code linked with the size and the audio:

    minAudio = 0;
    maxAudio = 20;
    minSize = 10;
    maxSize = 100;
    a = thisComp.layer(“Audio Amplitude”).effect(“Both Channels”)(“Slider”);
    s = linear(a,minAudio,maxAudio,maxSize,minSize);
    [value[0],s]

    So here’s how I hope you can help. Currently what happens is the opacity of the top black circle fades in line with the audio (more volume = more fade); and the lower black circle does the ordinary blinking that your code was designed for ( shrinking the size in line with the audio). There is one more addition I wish to make.

    For the top layer

    I want to add a randomiser. So that the top layer’s expression is opperated by chance. E.g. When the volume is louder, the expression has a X% chance of executing. This is to stop the reaction everytime audio is detected, else as I said, it looks like the face is sneezing when it talks. I am aware of the basic code for randomisers (e.g. the “Seed” function, but I do not know how to apply it to the existing expression. I hope all this makes sense since it’s the final piece of this puzzle, and then I will be happy with my effect.

    Thanks, and if you need any more clarity I will try and offer it.

  • Dan Ebberts

    March 4, 2016 at 10:11 pm

    It’s tricky. I’m assuming the louder audio lasts for more than one frame, so the expression needs to know if the current peak is being ignored or processed, but there’s no way to pass data from frame to frame. If it were me, I’d probably implement a beat counter (https://motionscript.com/design-guide/audio-count.html) and use the count as the random seed to determine if the current beat is being processed or ignored. A bit of work, but do-able.

    Dan

  • Lewis Snook

    March 4, 2016 at 10:21 pm

    I just tried implementing the expression and nothing that I can see happened.

    That said; this expression found on the same site seems to have the right basis, it’s just lacking the “random” element as it’s executed every few seconds in segments. Is there a way I can set the segment to be random?

    Here is the code:

    segMin = .3; //minimum segment duration
    segMax = .7; //maximum segment duration
    minVal = [0.1*thisComp.width, 0.1*thisComp.height];
    maxVal = [0.9*thisComp.width, 0.9*thisComp.height];

    end = 0;
    j = 0;
    while ( time >= end){
    j += 1;
    seedRandom(j,true);
    start = end;
    end += random(segMin,segMax);
    }
    endVal = random(minVal,maxVal);
    seedRandom(j-1,true);
    dummy=random(); //this is a throw-away value
    startVal = random(minVal,maxVal);
    ease(time,start,end,startVal,endVal)

  • Dan Ebberts

    March 4, 2016 at 10:56 pm

    This expressions is set up to ramp to random values across random durations. It changes things if you’re willing to disconnect the animation from the audio.

    Dan

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