Create a simple UI in After Effects

alt text
fig capture

In our previous tutorial, we learned how to extract keyframes audio files. In this short tutorial we will learn how to move the slider controls  to the main composition.

1. Start by creating a null object in the main composition and rename it to controllers.
2. Add a slider control to the null object controllers and rename it to Bass drum.
3. Press the little locker in the panels title to lock it even if we change to another comp window.

4. Make/select a comp for the object you want to control. (In this example we will only scale it, but you could move it, change opacity, tint color or change other effects based on the audio keyframes). In this example I created a simple triangle that I want to scale to the bass drum.

5. Open your new comp, click on your graphic and press s for scale, enable expressions by shift-click the stopwatch and paste the following code from our previous tutorial:

x = thisComp.layer("Audio Amplitude").effect("Left Channel")("Slider"); //Get the left channel
y = thisComp.layer("Audio Amplitude").effect("Right Channel")("Slider"); //Get the right channel
x = x * effect("Bass drum")("Slider"); //Multiply the value with a slider control
y= y * effect("Bass drum")("Slider"); //Multiply the value with a slider control
[value[0]+x, value[1]+y] //Apply them to the X and Y scale axis.
6. Now you will see an error that the layer “Audio Amplitude” is missing, because it refers to thisComp, the current composition we’re in right now. And in this comp, we don’t have a layer called Audio Amplitude.
x = thisComp.layer("Audio Amplitude").effect("Left Channel")("Slider"); //Get the left channel

To fix this we have to connect the expression with our previous comp kick where we have our audio keyframes in a layer called Audio Amplitude.

6. To do this we will remove all thisComp text in the code and use the pickwip and drag it to the kick comp in our Project panel.

Now we will instead of thisComp have comp(“kick”). This is the way to find a specific composition in our project. Make shure the name is unique so we don’t get some wierd name conflicts. One cool thing with After Effect is that if you later change the name of the composition, it will also update the name in all expression used in the project.

But we will still have some errors. Now the error says that the effect Bass drum is missing. Here is where we want to reference our slide controller in the main comp. So lets do that:

7. Place your cursor before effect and pickwip the main scene, and write .layer(“controllers”). wish will reference to our null object controllers in the main scene. The complete code will now be:
x = comp("kick").layer("Audio Amplitude").effect("Left Channel")("Slider"); //Get the left channel
y = comp("kick").layer("Audio Amplitude").effect("Right Channel")("Slider"); //Get the right channel
x = x * comp("_Scene").layer("controllers").effect("Bass drum")("Slider"); //Multiply the value with a slider control
y= y * comp("_Scene").layer("controllers").effect("Bass drum")("Slider"); //Multiply the value with a slider control
[value[0]+x, value[1]+y] //Apply them to the X and Y scale axis.
Now we can control the amount of the scale effect on the triangle using our slide controller in the main comp. Next we could add multiple sliders for different sounds, effects etc.

I hope you learned something from this tutorial, and please don’t hesitate to write a comment if you wonder something, or send me a tweet @jonassandstedt.

Leave a comment

Your email address will not be published. Required fields are marked *