FORUMS: list search recent posts

Turning on a layer dependant on waveform.

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Scott Williams
Turning on a layer dependant on waveform.
on Jul 15, 2015 at 12:13:03 pm

Hello all.

First off I use these forums regularly to help me out with day to day problems and I've finally signed up today and this will be my first post. As much as expressions intrigue me it's all still a bunch of jumbled code to my brain which I find myself copy and pasting without understanding so if when you're answering my question could you please do your best to add an explanation in so that I can begin to understand.

I'm trying to create an overlay for my radio comms in my videos. When the comms are active I want it to turn on a layer so to indicate that's where the audio is coming from. I've converted the waveform to keyframes and made an if/else expression to turn it on and off however if there is a slight pause between words the layer will flicker on and off because of the drop in the audio levels. Is there a way to create a time buffer so that the audio has to be below or above the level for a certain period of time.

if(thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider")>0.5)100 else 0;

Return to posts index

Xavier Gomez
Re: Turning on a layer dependant on waveform.
on Jul 19, 2015 at 5:00:57 pm

Expressions must be self-contained and cant use buffers.
At each frame, the expression code must look forward and backwards to see if there are enugh frames above threshold or not.
I didnt try but the following should work:

threshold = 0.5; // minimum amplitude
fMin = 15; // minimum number of frames above threshold
L = thisComp.layer("Audio Amplitude");
ampSlider = L.effect("Both Channels")("Slider");
if (ampSlider.value<=threshold){
f = 1;
dt = thisComp.frameDuration;
// search backwards
t = time;
while( f<fMin && L.inPoint<=(t-=dt) && ampSlider.valueAtTime(t)>threshold && ++f);
// search forwards
t = time;
while( f<fMin && ((t+=dt)<=L.outPoint) && ampSlider.valueAtTime(t)>threshold && ++f);

f<fMin ? 0 : 100;


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 All Rights Reserved