1

I am new to After Effects. I want to write a linear expression on [Audio Amplitude] that is converted from an audio file based on its value as the below:

 linear(value,0,15,0,0);
 linear(value,16,20,30,80);
 linear(value,21,30,80,100);    

So basically I expect when value is between 0 to 15 it becomes 0 when it reach between 16,20 it becomes 30 to 80 ,.... However, it looks it only executes the first linear(0,15) and anything is map to 0,0

How could I achieve this?

0

When expressions are evaluated the first term that returns a result will set the value of the property. If you look at your expression line 1 will always return a result - 0. None of the other lines will be executed.

What you need to do is test what the value is and then execute the right function accordingly.

if (value <=15){linear(value,0,15,0,0)}; 
if (value <= 20){linear(value,15,20,30,80)};
if(value > 20){linear(value,20,30,80,100)};

note that the linear() functions on the second and third line have minimum values of 15 and 20, not 16 and 21—consider what would happen if the value was 15.5 or 20.5.

What the expression does is only evaluate the first linear() function if value is in the 0-15 range. If it is that result is returned and the expression stops being evaluated, if not it goes on to the next line, and so on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.