Help with expression controlling opacity
Hi all,
I'm working on a visualizer for a podcast. I want to set it so that each speaker's picture only appears when they're speaking. This is the expression I'm using on the opacity of the picture, which references the audio keyframes:
speaker1 = thisComp.layer("speaker1").effect("Both Channels")("Slider");
if ( speaker1 >= 1 ) {
100;
}
else {
0;
}
This is working as it should, but the issue is the image flickers on and off for things like pauses between words, and breaks in laughs. In addition I feel like the animation would be more visually smooth if the picture lingered for a moment instead of turning off immediately when the speaking stops.
Is there a way I can add some kind of condition instead of the else statement here? Something like, if speaker1 < 1 and has been so for at least 20 frames, then the opacity = 0. I'm fairly new to expressions so I don't quite know where to start.
Thank you.
