4 Replies Latest reply on Dec 31, 2014 9:20 PM by Rick Gerard

expression range

I am trying to make an audio meter. I have set up the music, and converted the audio to keyframes. But I would like to set a range for the expression to activate in. for example, if the audio value is between 10 and 40 I want to set the opacity to 100, and if it is out of that range I want the opacity to be 0. what would the expression be for something like this.

• 1. Re: expression range

This article by Dan Ebberts might guide you in the right direction:

Dan Ebberts's Expressioneering Design Guide

• 2. Re: expression range

there is no way to just set a if/else type of expression where it says. If the value of audio slider is 10 to 100, opacity to 100. else opacity to 0

• 3. Re: expression range

if (thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider") < 10){[100];}else{ [0] ; }

• 4. Re: Re: expression range

There are lots of ways to approach your problem. You have successfully created a switch. There is way too much punctuation. You don't need the brackets, the square brackets or the semicolon after the 100. You could have simply written:

L = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider");

if(L >10) t = 100  else t = 0

or even on one line, but I usually like to declare a variable so I can easily do more:

if(thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider")6) t = 100  else t = 0

I usually prefer to use a linear function so that the effect has a fade in. Something like this.

L = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider");

tVal = linear(L, 6, 10, 0, 100)

This expression will fade the opacity from 0 to 100 as the Audio Amplitude goes from 6 to 10 so it just doesn't pop on. Any value over 10 will be 100. This just goes to show you that there are many ways to do the same thing.