Using sound to drive animations is a lot of fun in After Effects. If you don't have the resources to buy a dedicated plug-in like Trapcode Sound Keys don't worry. Extracting and converting the amplitude data of a sound file and turning it into Keyframe data is really easy. You can then use this data to drive any parameter in After Effects with Expressions.
In this tutorial I'm going to show you the basics of how this is done. You'll find the resources used in a project file.
I've created a New Composition (Command-N) and called it "Sound Animation". It's 500px x 300px, with a duration of 8 seconds at 30 fps.
I'm going to import a sound file I made of a simple drum beat. I do this by going to File > Import > File or hitting Command-i.
Important: Before you do this make sure your Project sample rate is set to the same one as your audio. In my case 44.1khz. This is found in File > Project Settings. After Effects defaults to 48khz.
Drag the audio file into the Sound Animation tab from the Project window. If you select the audio file and hit (LL) you will see the waveform.
In the Comp, Control-click (or right-click) on the audio file and select Keyframe Assistant > Convert Audio to Keyframes.
When this is done you'll have a new '˜Null Object' layer called '˜Audio Amplitude'. Select it and press "E" to show Effects. Click the disclosure triangle beside '˜Both Channels' and then click on '˜Slider'. Hit the Graph Editor button (see orange arrow in the figure below) to see the generated keyframes.
You can delete the '˜Left Channel' and '˜Right Channel' effects as we don't need them for now. If you look in the Effects Controls panel, you should see your Slider. This is what's holding the '˜Audio Amplitude' Keyframe values. Now we want to connect this up to something.
Create a new Solid (Command-Y), make it white, 100px x 100px. Call it '˜Box'.
With the '˜Box' layer selected press T to reveal the '˜Opacity' controls.
Now Option-click the stopwatch icon by Opacity to show its Expressions controls. You should see some text appear:
Drag from the Pick Whip icon (the swirly shell-shaped one) onto the '˜Slider' on the Audio Amplitude layer.
You should now see that AE has written an expression in the text field which has linked the Opacity value to the current value of the '˜Slider' on the Audio Amplitude layer.
Looking at the screenshot below, you can see the value for Both Channels is 23.30 and that the Opacity percentage is rounded down to 23%. The Audio Amplitude '˜Slider' is now controlling the '˜Box' opacity value.
Let's break the expression down quickly so you can see what it's doing:
thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider")
When pick whipping you'll see this kind of expression format a lot. Once you're more familiar with them it becomes easier to edit and manipulate them. Speaking of which...
...we have a bit of a problem in the fact that the values generated by the Audio Amplitude Keyframes are a bit low. The peak value is about 23.30 and we need a value closer to 100 for our Opacity percentage.
We can easily remedy this by adding some simple math to the expression, say multiplying the value of Audio Amplitude '˜Slider' by 4!
So all I need to do is add "*4" to the end of the Expression:
thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider")*4
You can see that adding this equation to the Expression gives us a much healthier Opacity value.
This is the result of the audio keyframes driving the opacity value of '˜Box'.
So let's try another basic example. This time we're going to use the audio data to drive a parameter of one of After Effects built-in plug-ins on an image. Hide the '˜Box' layer.
I've imported an image of a speaker I made in Cinema 4D, and dragged it into my Comp.
Go to the effects panel and select Distort > Bulge. Drag the effect onto the layer.
I've set up the Bulge effect with these values:
Now Option-click the stopwatch icon to the left of the Bulge Height parameter to reveal the Expression settings.
Drag from the pick whip icon onto the '˜Slider' on the Audio Amplitude layer (see screenshot).
We now have a problem in that the Bulge Height value only goes up to 4. Our Audio Amplitude '˜Slider' values are maxing out the effect to the extreme. The maximum Bulge height value I need is 1.
To keep these values within an acceptable range, you can divide the value of the Audio Amplitude '˜Slider' by its maximum value, which is 23. This means that at the maximum peak level of 23, we will get a Bulge Height value of 1 (23/23 = 1). Slider values below 23 will result in a decimal lower than 1, which is good!
Here you can see the equation at the end of the Expression:
And here's the final result of the effect:
So there you have it: a couple of simple examples showing you how you can drive parameters with sound. Next time I'll show you how you go about dealing with parameters that are Arrays and how you use Variables to simplify the process with Expressions.
We'll set up some controls to fine tune a more complex animation using sound.
To learn more about Motion Tracks and Stabilization in After Effects.