How to Make Your Animation React to Music in After Effects


Lifewire / Johnny Chew

So you want a piece of animation to react to your thumpin' beats of the latest techno dance drop? Who doesn't! Let's take a look at how to make that happen using Adobe After Effects, so pop that open or download your free trial and let's dive right in!

So first let's spend a quick second talking about what kind of animation works with this effect. Generally speaking, it's gonna be more abstract, trippy styles that will respond well to this technique. This won't be a great method to get a character to dance around the screen to the music, but if you want a pulsating light or cool techno ring this is the place to be.

Find Music to Work With

Now once we've started up After Effects let's find a piece of music to work off of. We're going to be using Welcome Home (Sanitarium) by Metallica, but you can use whatever you'd like. Free Music Archive is a good resource as well if you're looking for a piece of music to use in a video you're going to end up publishing to Youtube if you want to avoid it being taken down. Also, music that has big hits and bass is usually a better way to go for this effect than something more mellow, so keep that in mind, as well as songs without lyrics tend to work better as well. After Effects loses a lot of the variation in the song when dealing with lyrics, but for our example, we're going to be using the great intro to Metallica, so it'll work fine.

Importing Music Into After Effects

Once we've imported our piece of music into After Effects, let's drag it down to the New Composition icon at the bottom of our Project Window to create a composition that is the length of our song.

Next, let's make a simple square solid to work with. We know it's not a cool techno ring, but we'll apply our effect to it's scaling so that it grows and shrinks with the music. The effect we're going to do can be applied to anything, so we'll just keep it simple with the scaling here for sake of example, you can apply it to your cool techno style later on your own once we've understood how it works.

How to Exaggerate the Song

Now that we have that setup, let's add an effect to our audio so that we can exaggerate the song, even more, to try to get better results from the effect. We'll apply the Bass & Treble effect to it, and depending on which we'd like our animation to respond more to we'll crank it up and the other down. So if we want our animation to respond more to the bass beats, we can crank it up to 100 and treble down to -100, and vice versa if we want it to respond to the treble of the song. For our example, we'll amplify the treble.

Next, we'll want to turn our audio into keyframes and that is super easy. Just right-click on our audio track down in our Timeline and select Keyframe Assistant and then choose Convert Audio To Keyframes. You'll see a new null object appear named Audio Amplitude, and this is where all of the keyframes that were adapted from our audio live. If you select our new null object in our timeline and hit U you'll bring up all the attributes and their keyframes.

3 Attributes

You'll see we have 3 attributes, Left Channel, Right Channel, and Both Channels. As we're sure you've guessed these are what plays out of the left speaker, the right speaker, and both speakers. We're going to go off of both channels to keep things simple and to keep organized, we'll select Left and Right Channels and delete them from our null object.

The channels have a slider within them, and if we scrub through our timeline you should see the numbers of the slider change throughout the song but our null object doesn't change at all. That's because sliders are a lot like a null object, they have values but don't affect whatever they are directly attached to usually. We can use that to attach another attribute to that slider and have it respond to what the slider is doing.

Now you'll see that the slider is only changing a little bit, ours is hovering around 10 to 20. If we use that our effect will be very subtle, almost too subtle to make it worth it. So let's go in and magnify this value so that our effect is more dramatic and exaggerated for our animation.

We're going to do that using an After Effects expression. An expression is a little equation that acts as a piece of code telling After Effects to do something specific. In this case, we're going to tell it to magnify the values of this slider. So first here's the expression you'll need to type in:


What that means is that it will change the values of our slider so that if the value is A, it will become X, and if the value is B, it will become Y. So for example, if our expression looks like this: linear(value,0,50,10,100) that is saying that when the value is 0, it will be changed to 10 and when the value is 50 it will be changed to 100.

So now we want to find out what the values for our individual piece of music will be for our expressions. Select your slider and open up the Graph Editor by clicking the graph button on your timeline. This brings up a crazy looking line graph, and we'll want to find out what some of our average values are.

First, let's find out our low average by looking at where the lowest dots on our graph are. Ours is around 7. That means we'll want to change our A value to be 7, and the X value to be whatever we would like our new lowest value to be. We'll make it 50.

Now we need our average high value, so look at where the most dots at the peak of the line graph appear and guesstimate the value. Ours is at around 35 we'll say, we don't have to be super exact and we can always go in and tweak things later.

We'll put 35 in for B and we'll make our Y into 200. So we're saying that our average high value of 35 will become a value of 200 instead.

Now if we scroll through our timeline you should see a much more dramatic shift in the values on our slider. That's exactly what we want to have happen.

So now let's make our solid pulse to the music with these new exaggerated values. We'll click our solid on my timeline and hit S to bring up its scale, and then we'll Option or Alt-click the stopwatch to bring up the expression control. Here we'll use the Pick Whip, which is the icon that is a little spiral line, to click and drag from the Scale expression onto the Slider in our Audio Amplitude layer.

This will add a new long-expression into our solid's size expression window, you could type this all out but it's much easier to use the Pick Whip. What this expression is saying is that you want After Effects to match the scale of our solid to the value of the slider in our Audio Amplitude layer.

Now if we play our animation, you should see your solid changing size in relation to your music.

Odds are it's not reacting exactly how you want it to, this is where you'll probably have to go in and refine the values in your expression so that it makes the animation react a little bit more of how you'd want it to react.

Now that is the same way we can apply music affecting any other element within After Effects. It can control glow, lens flare brightness, position, rotation, blur, you name it, all by doing the same process and simply pick whipping whatever effect you'd like to react to the Audio Amplitude channel slider. So have fun and go crazy!