Ready to watch this entire course?
Become a member and get unlimited access to the entire skills library of over 4,987 courses, including more Video and personalized recommendations.Start Your Free Trial Now
- View Offline
One fun trick is to have sound appear to motivate, or move, your animations inside of a composition. Well, you can use expressions to help you do that. I'm going to go back to the Project panel and this time open up comp 08-Audio*starter where we have a speaker, we have a colorful background, and we have an audio track. I'm going to press 0 on the numeric keypad to queue up both the video and audio previews. (audio playing) Now expressions cannot directly access sound inside a layer.
I'll type LL to reveal the audio waveform for that layer. However, there is a very handy keyframe assistant that can take that sound and create the keyframes for you. I'll go to Keyframe Assistant > Convert Audio to Keyframes. This looks at all your audio layers inside of composition and creates one null object-- remember, we said nulls make great master controls--and by pressing U to reveal keyframes, creates a stream of keyframe values that represent the loudness of the audio.
Notice here where the audio is quieter, the values derived are relatively low. Just a couple frames later where the audio is louder, those values jump up higher. Same thing here, low audio amplitude, low keyframe values; a little bit later, louder, higher values. If you want to see this more graphically, again, don't be afraid to go into that Graph Editor. You can select each of these parameters and see the resulting value graph. And actually, I would recommend going around and seeing what your minimum values are, your lowest points there, is around 6.
What your highest points are, here a little over 50. Look at the Right Channel, highest value looks to be about 50 again, lowest value in the order of 5, and Both Channels kind of like the stereo mix. Don't select just the effect like I just did; select the actual parameter. There is a slider. Maximum value 50, minimum values around 5 again. Okay, keep those in mind, because now we know what is the value range of our loudness. I'm going to turn off the video switch for this controller. Just get rid of that little red box.
Okay, let's turn our attention to the speaker. We want that woofer to bounce along in time with the music. Turn off our Graph Editor and then twirl up the Left and Right Channels, because I think I'm going to use Both Channels since I only have one mono speaker here. For the speaker, we've already applied an effect for you. I'll press F3. We've applied the Bulge effect to this speaker. We've gone ahead and set the center of the bulge to be right at the center of that speaker cone. That way as you control the Bulge Height, you can make the speaker push out and pull in.
Again, scrub this value a little bit while watching the speaker and get a feel for what value range seems to make sense. I think at my loudest excursions I might want to go to probably no more than 1, to be honest. Yeah, -1 looks like it's pulled in quite a bit as well. So +1 or -1 looks like a good range for my Bulge Height. I'm going to twirl up Levels and Drop Shadow just to reduce confusion in this display. Okay, I want to create an expression to have the Bulge Height follow my Audio Amplitude.
Remember, earlier in this lesson, we said there was a great expression that made your life easier for doing things like that, the Interpolation expression, such a linear. I want to enable expressions for the Bulge Height. Again, hold Option or Alt, click on stopwatch. The parameter will automatically be opened up down here in the Timeline panel for me. Now, for the Interpolation expression, I can either take advantage of the Expression Language menu and open up Interpolation and select one of the linear expressions and start replacing its values, or eventually, you'll find you remember this--it's faster to type it in yourself.
So I'm going to type in "linear," open parentheses, and then remember the following mantra: as a parameter goes from A to B, I want to go from Y to Z. Those are the numbers you need to enter to make linear work. Okay, what's the parameter I want to follow? I use the pick whip and select Audio Amplitude's slider value. After Effects has already typed in the necessary code for me. Type a comma. You'll always need a comma to separate parameters. The spaces are optional, but you need the commas.
Okay, as that parameter goes from its minimum to maximum, what do we say were the minimum and maximum values? About 5 and about 50. Okay, now where do I want to go from? I want to go from, say, -1 to 1. This is not going to be an exactly accurate representation of a speaker because unfortunately Audio Amplitude only goes in the plus direction. It doesn't go plus and minus like a speaker should. But this will still give us an animation that's in time with the music, and it will be good enough to fool the viewer.
Now let's go ahead and close parentheses to close off the parameters for linear and click anywhere to accept the expression. I'm going to scroll down a little bit here, so that you can see the audio waveform better. And let's go ahead and RAM Preview, watching the audio waveform and the resulting action of the speaker cone. Press 0 to RAM Preview. (audio playing) That was pretty easy.
That's a pretty cool animation-- a lot easier than trying to do it by hand, too. Now for your challenge, why don't you make this animation work in stereo? Why don't you create two of these speakers and hook one of them up to the Left Channel and the other one to the Right Channel and see if they animate differently. Now, truth be told, the Convert Audio to Keyframes command inside After Effects isn't all that powerful. There are better third-party alternatives available. Trapcode's Sound Keys is great and Boris Continuum Complete also contains a really nice audio-to-keyframe converter.
So if you like this sort of trick, I would suggest buying one of those third-party effects so you have even more control.
The After Effects Apprentice videos on lynda.com were created by Trish and Chris Meyer and are designed to be used on their own and as a companion to their book After Effects Apprentice. We are honored to host these tutorials in the lynda.com Online Training Library®.
- Creating and managing expressions
- Linking together different parameters
- Randomizing a layer's movement
- Looping an animation
- Controlling multiple layers from a single source