Skip to main content
brandonb96942845
Inspiring
August 3, 2022
Question

Another IF/ELSE Loop Question

  • August 3, 2022
  • 1 reply
  • 119 views

Hi all,

 

Got one more and then I think I'll be set for this project of mine. You know how when you use most videoconferencing programs, when someone is speaking they'll have an illuminated border around their window? I'm trying to add something like that to my AfterEffects project. First, this is the code that I've got:

var temp1 = effect("This Source Amplitude")("Slider");
var temp2 = thisComp.layer("Sound Dynamics").effect("Visibility Threshold")("Slider");
var temp3 = thisComp.layer("Sound Dynamics").effect("Max Value")("Slider");

if ( temp1 >= temp2 ) {
100;

} else if ( temp1 === temp2 ) {
100;

} else
0;

 

On each person's source composition, I've used the Keyframe Assistant to turn the audio amplitude into keyframes, so I can measure how loud each one is. I've parented all of those to sliders, including one on a master layer that figures out the maximum value (i.e. the loudest one), and another (also on the master layer) that sets a threshold. And I'm applying the above expression to the Opacity property of each layer.

 

So this is what I'm trying to get it to do: first, I want it to look and see if the value of the layer's amplitude slider is above the threshold; if so, I want it to turn the Opacity to 100% (and become visible). If it is, great; then it's visible. But off the chance someone soft-spoken is the only one talking--meaning the amplitude doesn't pass the threshold--I also want it to look and see if the layer's amplitude equals the maximum value on as determined on the master layer.

 

So far, I've been able to make this work with just the first condition, but when I try to add the second condition, it returns a zero value no matter what I do.

 

Any idea what I'm doing wrong?

This topic has been closed for replies.

1 reply

brandonb96942845
Inspiring
August 3, 2022

Strike this whole post...the second this posted I saw my mistake: a simple typing error, I forgot to tell it to compare with temp3 the second time instead of temp2. Mods, feel free to delete.