Answers.Body: <p>When expressions are evaluated the <strong>first term that returns a result</strong> 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.</p>
  <p>What you need to do is test what the value is and then execute the right function accordingly.</p>
  <pre><code>if (value &lt;=15){linear(value,0,15,0,0)}; 
  if (value &lt;= 20){linear(value,15,20,30,80)};
  if(value &gt; 20){linear(value,20,30,80,100)};
  </code></pre>
  <p>note that the <code>linear()</code> functions on the second and third line have minimum values of 15 and 20, not 16 and 21—consider what would happen if the <code>value</code> was 15.5 or 20.5.</p>
  <p>What the expression does is only evaluate the first <code>linear()</code> function if <code>value</code> 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.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-16T01:10:01.987Z
Answers.LastActivityDate: 2020-12-16T01:10:01.987Z
Answers.UserDisplayName: stib
Body: <p>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:</p>
  <pre><code> linear(value,0,15,0,0);
   linear(value,16,20,30,80);
   linear(value,21,30,80,100);    
  </code></pre>
  <p>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</p>
  <p>How could I achieve this?</p>
  
Tags: <after-effects><after-effects-expressions>
Title: After effect using multiple linear expression based on its value
UserDisplayName: codeProtect
ThreadText: # After effect using multiple linear expression based on its value
  
  (Asked by: username_0 on 2020-12-13)
  
  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?
  
  **Tags:** after-effects, after-effects-expressions
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-12-16. Score: 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.
  
  
  ---
  
  