Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

If Statement controlling Scale field. Not working.

New Here ,
Jul 30, 2021 Jul 30, 2021

I'm trying to control the scale through an if statement expression. Innitially I tried to only control the Y Axis but that wasn't working

 

Here was the first expression i tried:

x = if(thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider") < 4){102}else{100};
[value[0],x]

 

Then I tried to not control the individual dimensions incase I had written something wrong there.

 

This was the next expression which isn't giving me an error, but is ignoring the if statement completely.

 

temp = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider");
if(temp < 4){102}else{100};
[temp, temp].

 

What I'd like to do, is control the Y property by looking to a continuously changing slider so whenever the value is greater the 4 that the scale changes from 100 to 102.

 

Please help, thanks 🙂

TOPICS
Expressions
307
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 30, 2021 Jul 30, 2021

You need to assign the values to a variable:

if(thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider") < 4){
    x = 102 //' same for 'temp'
}else{
    x = 100 // Same for 'temp'
};
[value[0],x]
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 30, 2021 Jul 30, 2021
LATEST

I think you have more problems than just the formatting issue. Audio levels typically run from 0 to 30. Four is a very low threshold for most audio and the change from 100 to 104 isn't much so you are not going to get much of a reaction.

Ifexpression.png

Another problem is that a simple if statement is on or off. Your scale would either be 100% or 104%, which is hardly enough of a change to give you much of a change in size unless you just want a small vibration that rattles only when the sound level dips below a very low background noise level.

 

I would consider using an interpolation method. The first step is to open the Audio Levels Both Channels Slider in the Graph editor set to display a value graph, then look at the range and figure where you want the switch to take place. Then you build your interpolation method.

 

This tutorial I just released explains it all pretty well.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines