Using MIDI to Control Animation in After Effects | Part 2

In this video we build on the fundamentals we learned in Part 1 (watch this first if you haven’t already) and learn how to actually TRIGGER animations that begin playing when After Effects detects a MIDI keyframe. The only way to do this is to write an expression that does some fancy tomfoolery. Joey is going to walk you step-by-dorky-step through the process.

Make sure you check out the resources tab for everything you'll need to complete this lesson.

If you have any questions, click over to the Q&A tab to post them. Other students can answer you, and we'll put our team on the case to try and get you a solution ASAP. 

Download Project File

You'll need this free Omino AE Script to complete this lesson.

Some free MIDI files can be found here.

EXPRESSIONS

Watch the tutorial for instructions on how to use these!

This one is for the Particles Per Second control on a Particular layer. It won’t work without:

• A Slider Expression Control on the layer which chooses the MIDI channel

• A “SONG-CONTROL” Null which controls which layer holds the MIDI info.

• A Slider to control the “Burst Amount.”

startValue=0;

endValue=1;

channel=effect("CHANNEL")("Slider").value;

refProperty=thisComp.layer("SONG-CONTROL").effect("MIDI Layer")("Layer").effect("ch_"+channel+"_dur")("Slider");

n=refProperty.nearestKey(time).index;

nTime=refProperty.nearestKey(time).time;

nearKeyTime = refProperty.key(n).time;

d=time-nearKeyTime;

if (Math.abs(d)<(1/24)) {

effect("BurstAmount")("Slider");

} else {

0;

}

This one goes on the “Time Remap” of any animations you want to trigger. It won’t work without:

• A Slider Expression Control on the layer which chooses the MIDI channel

• A “SONG-CONTROL” Null which controls which layer holds the MIDI info.

startValue=0;

endValue=1;

channel=effect("CHANNEL")("Slider").value;

refProperty=thisComp.layer("SONG-CONTROL").effect("MIDI Layer")("Layer").effect("ch_"+channel+"_dur")("Slider");

n=refProperty.nearestKey(time).index;

nTime=refProperty.nearestKey(time).time;

if (time <= nTime) {

if (n>1) {

n--;

}

}

nearKeyTime = refProperty.key(n).time;

d=time-nearKeyTime;

linear(d, startValue, endValue, startValue, endValue);

    00:00:00,346("Toto" by Africa)
    00:00:04,441♫ I hear the drums echoing tonight
    00:00:07,979♫ But she hears only whispers of some quiet conversation
    00:00:15,628♫ She's coming in
    00:00:20,937(upbeat electronic music)
    00:00:28,725- What's up?
    00:00:29,558Joey here at School of Motion, and welcome to day six
    00:00:31,886of 30 Days of After Effects.
    00:00:33,808This is part two of the tutorial series
    00:00:35,685where we take MIDI information
    00:00:37,546and we bring it into After Effects
    00:00:38,975and then we use it to trigger animations.
    00:00:41,655Now I have to warn you that this might be
    00:00:43,188the geekiest tutorial I've ever made in my entire life.
    00:00:45,581It's expression city.
    00:00:47,321We're really gonna get our hands dirty
    00:00:48,786and at the end we're all just gonna feel really filthy.
    00:00:51,273But, if you can hang with it, if you can just bear with me,
    00:00:53,652let your brain absorb it, by the end of this
    00:00:56,211hopefully you'll have a pretty good understanding
    00:00:57,720of how this thing is actually set up,
    00:00:59,540and that'll give you some really cool ideas
    00:01:01,348about what you can do with this knowledge later.
    00:01:03,816Now don't forget to sign up for a free student account,
    00:01:06,434so you can grab the project files and expressions
    00:01:08,960from this lesson as well as assets
    00:01:10,731from any other lesson on the site.
    00:01:12,971All right, let's hop into After Effects and check it out.
    00:01:16,320All right, here we go, down the rabbit hole.
    00:01:19,168So, we are in Logic, and this the track
    00:01:24,283that I recorded for the demo for this video,
    00:01:26,790so I'll just play a little bit of it.
    00:01:28,433(drum music)
    00:01:29,697You can see the MIDI information down here.
    00:01:35,962And then I did find a drumless backing track
    00:01:43,008for this song, which is pretty useful.
    00:01:48,174You know, one of the things I hope this tutorial does is,
    00:01:51,349I wanted to give you guys ideas, and kind of create,
    00:01:55,773this is kind of something that hasn't been done a whole lot
    00:01:58,675and it would be really sweet to see, you know,
    00:02:01,566what some really, really creative, amazing designer person
    00:02:04,566could do with this technique.
    00:02:08,734Programming MIDI that goes along with a cool song
    00:02:11,160and then using that to trigger animation.
    00:02:14,428I'm really excited that it's working, so.
    00:02:17,357Anyway, so we've got the MIDI information here,
    00:02:19,553and obviously this is a lot more complicated
    00:02:22,576than what we had in the first example okay.
    00:02:25,049I mean, A, I recorded the first third of the song.
    00:02:29,991There's just a ton of data here, and on top of that
    00:02:34,109there's a whole lot of different instruments, right.
    00:02:36,639There's high-hats, kick, snare, there's different cymbals,
    00:02:41,505there's toms, there's probably eight or 10
    00:02:44,215different instruments actually being played in here.
    00:02:47,611If we go to something like this.
    00:02:49,408("Toto" by Africa)
    00:02:50,609Right, there's a little drum fill in there.
    00:02:53,877Let's see what else we got.
    00:02:55,664Like sort of over here in the chorus.
    00:02:57,216("Toto" by Africa)
    00:02:58,170♫ Hurry boy, it's waiting there for you
    00:03:05,153All right so if you want to be able to have each instrument
    00:03:08,476sort of trigger a different thing, you kind of need
    00:03:11,492access to that instrument independently okay.
    00:03:14,333By default, you're not really getting that
    00:03:17,083out of your MIDI file, so let me show you what happens
    00:03:20,706if I just select this MIDI and I say
    00:03:23,642export selection as MIDI file.
    00:03:27,101There, I'm getting that error again,
    00:03:29,062so let me first come down here and say
    00:03:34,537delete MIDI events outside locators.
    00:03:38,681All right and then I'm gonna make sure I don't have any,
    00:03:42,371any drum hits happening too early, that all looks good,
    00:03:45,911and now we'll export that MIDI file.
    00:03:50,131All right cool, and let me just make a new folder here,
    00:03:52,821we'll call it demo two and this is called Africa raw.
    00:03:59,918So the first thing I'm gonna do is I'm gonna grab
    00:04:02,559the audio file, just the bounced audio.
    00:04:05,272("Toto" by Africa)
    00:04:07,403Okay and then I'm gonna grab that MIDI file
    00:04:09,546that we just made,
    00:04:10,525so let's grab Africa raw MIDI file.
    00:04:14,329Make sure I have something selected in here,
    00:04:15,905and I'm just going to rename, so this is the old,
    00:04:18,999this is the actual MIDI file from the demo,
    00:04:22,389so I'm just gonna rename that old for a minute
    00:04:24,235and let's import this one we just made.
    00:04:27,417It takes a little longer than in the last tutorial,
    00:04:30,276because there's a lot more going on,
    00:04:32,244and if I hit U you can see, wow,
    00:04:34,021there's a ton of data in there.
    00:04:35,632Now here is the problem.
    00:04:38,642Let's look at channel zero velocity, and let's go into
    00:04:42,033the graph editor and let's kinda jump in there okay.
    00:04:45,248And you can see there's peaks and there's hard hits
    00:04:47,501and then weaker hits, and let's play the audio
    00:04:49,317and see how it syncs up.
    00:04:50,964(drum music)
    00:04:56,949Okay so listen to just the kick drum.
    00:04:59,739(kick drum music)
    00:05:03,415The kick drum doesn't exactly line up with this,
    00:05:06,688okay it's like it lines up with some hits but not other hits
    00:05:09,270and then listen to the snare drums.
    00:05:10,651(snare drum music)
    00:05:15,028Right so it lines up with some hits but not other ones.
    00:05:17,973So what happens is, by default, all of these MIDI notes,
    00:05:22,194they get placed kind of willy-nilly onto some channels okay.
    00:05:26,835And what you really want is you want
    00:05:28,356is you want the kick on its own channel,
    00:05:30,348the snare on its own channel,
    00:05:31,870the high-hat on its own channel.
    00:05:33,850You want all of these things separated out.
    00:05:36,265That way, you'll be able to more easily trigger
    00:05:42,084a certain animation on the kick,
    00:05:43,333a certain animation on the snare.
    00:05:44,650With this, it's gonna be a lot harder
    00:05:46,348'cause you're gonna have to manually tell it
    00:05:48,984which of these hits goes with which instrument okay.
    00:05:52,715If everything's happening on the piano,
    00:05:54,834it doesn't really matter, but this is a drum set
    00:05:57,556and so you've got multiple instruments
    00:05:59,162happening at the same time.
    00:06:00,601So this MIDI information we brought in
    00:06:02,626isn't gonna be too useful.
    00:06:03,785Let's delete it and let's hop back into Logic
    00:06:05,697and I'll show you how to fix this.
    00:06:07,887Okay, so we are back in Logic, and let's take a look
    00:06:10,661at the MIDI information one more time.
    00:06:12,079So here are our drums.
    00:06:14,502(drum music)
    00:06:17,089All right now let me show that each of these notes
    00:06:19,484is placed into a MIDI channel, and the way you find out
    00:06:22,301which channel is you can open up your event list.
    00:06:25,917All right so in Logic you have this
    00:06:27,847kind of manager window over here
    00:06:30,471and this has a few different modes, but in event mode
    00:06:33,326it's showing you every single MIDI event in your song.
    00:06:36,128Each of these notes is considered a MIDI event,
    00:06:39,149and if I select one of them, it will highlight that event
    00:06:42,512over here in the list, and it will show me in this column
    00:06:45,590which channel it's in, okay.
    00:06:47,132So this note is in channel three, okay.
    00:06:50,011(drum banging)
    00:06:50,844This snare hit is in channel two, okay.
    00:06:53,409(snare drum banging)
    00:06:54,919This snare hit is in channel one.
    00:06:56,899Now that's obviously gonna screw us up okay,
    00:06:59,958and what we want is we want every
    00:07:02,294instrument in its own channel. (kick drum banging)
    00:07:04,210Okay this kick drum is in channel three.
    00:07:06,389(kick drum banging)
    00:07:07,222This kick drum is in channel two.
    00:07:09,261(drum banging)
    00:07:10,144Right, and that snare hit's in channel two.
    00:07:12,747(drum music)
    00:07:13,718So that's why in After Effects, when we were looking
    00:07:15,757at the data, it looked like the kick was lining up with
    00:07:19,164some of those hits but not others, and then the snare
    00:07:21,172would like up with some of those hits but not others
    00:07:22,895because the kick and the snare sometimes were
    00:07:25,203in the same channel, sometimes were in different channels,
    00:07:27,546and that's not very useful.
    00:07:29,958So what we want to do is put every
    00:07:31,650instrument in its own channel.
    00:07:33,616If I select, for example, a high-hat note, okay,
    00:07:37,723it'll show me over here all right
    00:07:40,500which key on the software keyboard
    00:07:43,840is actually corresponding to that note.
    00:07:47,615I'm playing on sort of a drum-shaped MIDI controller
    00:07:51,202but all it's doing is it's sending notes to the computer
    00:07:54,716and it's interpreting this note
    00:07:57,452(kick drum banging)
    00:07:58,307as a kick right, and this note
    00:07:59,958(snare drum banging)
    00:08:01,014as a snare.
    00:08:02,263So this the note for high-hat, and when I select it,
    00:08:06,232it highlights every single high-hat hit,
    00:08:08,996and you can see that they kind of all look like,
    00:08:12,104they all look like they're on channel one,
    00:08:14,350so the high-hats actually look like
    00:08:15,647they might be set up right, but just to make sure,
    00:08:18,387once you've highlighted everything, you can come over here
    00:08:20,735and you can actually sort of batch-adjust all of them okay,
    00:08:25,302and make sure they're on the same channel.
    00:08:27,099So now they are all on channel one, that's great.
    00:08:30,123So now we just have to do that
    00:08:31,332for the rest of the instruments.
    00:08:32,721All right so I'm not gonna do all of them,
    00:08:34,144but I'll do a couple more,
    00:08:35,894'cause there's a couple of things that kind of tripped me up
    00:08:37,961and maybe I can save some people some hassle.
    00:08:40,689So here's the kicks, right, I'll select all of them
    00:08:42,997by clicking that little key, and I can look in the list
    00:08:45,403and I see that you've got some are on channel three,
    00:08:48,864some are on channel two,
    00:08:49,700and you want them all on the same channel.
    00:08:51,692So let's try to put them all on channel two.
    00:08:53,520And if I click over here, at first
    00:08:55,759it doesn't let me change it at all.
    00:08:57,675If I hold Shift, it does let me change it okay.
    00:09:01,345And I'm honestly not sure why,
    00:09:03,605but just know if you're using Logic, it does.
    00:09:05,459Now here's the problem, if I move it up like this right,
    00:09:08,285so now it's channel eight, this one's on channel seven.
    00:09:11,549And the problem is it's incrementing them all the same
    00:09:14,485and I want to change them all
    00:09:16,033so they're all on the same channel.
    00:09:18,100So this is a trick I figured out,
    00:09:19,636you select all the notes, you come over to your edit menu,
    00:09:24,031sorry your functions menu, and you wanna say
    00:09:27,147set MIDI channel to voice number.
    00:09:30,959What that will do is it will set
    00:09:32,448every note to the same channel.
    00:09:35,664Now if I hold Shift I can move these up to channel two okay.
    00:09:40,975So now I've got high-hats, all on channel one,
    00:09:44,341kick all on channel two.
    00:09:45,343Let's set the snare.
    00:09:47,164(snare drum banging)
    00:09:48,551Okay, and you can see some are on channel two,
    00:09:50,326some are on channel one, and I want them
    00:09:52,090all to go to channel three.
    00:09:54,809So I'm gonna do the same thing,
    00:09:56,392set MIDI channel to voice number
    00:09:58,022so it sets all of them to the same channel,
    00:10:00,547and then hold Shift and move this up to channel three.
    00:10:03,824(drum banging)
    00:10:07,015There we go, cool.
    00:10:08,921You just do that for every instrument that's in here okay,
    00:10:11,781and it doesn't even take that long.
    00:10:13,668Here's my cowbell.
    00:10:14,917(bell clinking)
    00:10:15,911Right and even the cowbell, this makes no sense to me,
    00:10:19,175some were on three, some were on two.
    00:10:21,240So yeah, you just do the same thing,
    00:10:23,201set MIDI channel to voice number, and then hold Shift
    00:10:26,864and move that up to four.
    00:10:30,204There you go.
    00:10:31,518All right so once that's done, then you can export that MIDI
    00:10:35,489and when it comes into After Effects,
    00:10:37,127it's gonna be much more useful, so let's hop back in there.
    00:10:40,228All right, so let's import that MIDI.
    00:10:43,100And I had already imported this previously.
    00:10:47,620All right so let me make sure that I've got
    00:10:52,009something in this sequence selected, hit apply
    00:10:55,694and it's gonna take a little while, but this time
    00:10:57,724you're gonna see a whole lot more channels
    00:11:00,415come through okay.
    00:11:02,724What's strange to me is that it seems as though
    00:11:06,292the channels that you assign things to in Logic
    00:11:09,075don't always match what comes through here,
    00:11:12,563but that's not such a big deal right because what you can do
    00:11:17,291is let's hit U
    00:11:18,708and you can see a whole bunch of keyframes here
    00:11:20,928but they're a lot more spread out,
    00:11:23,792because we've separated instruments onto their own channels,
    00:11:26,629if I just hit audio preview here,
    00:11:29,338(drum music)
    00:11:32,464right, watch this column right here.
    00:11:35,278(drum music)
    00:11:39,118Obviously, that's the kick drum.
    00:11:40,648Channel eleven is the kick drum okay,
    00:11:42,772so it's easy to figure out.
    00:11:43,712You want to figure out high-hat, it looks to me
    00:11:48,286like this is the high-hat up here
    00:11:50,322(drum music)
    00:11:51,780One two three, one two three, all right,
    00:11:53,469so it's a lot easier to figure out
    00:11:55,873when they're separated into their own channels like that.
    00:11:58,892So first thing I'm gonna do is clean this up a little bit
    00:12:02,544and what I decided to do, as opposed to trying to work
    00:12:07,305with the velocities of these right,
    00:12:09,563I mean there is some change in the velocity,
    00:12:12,336this is the high-hat track, remember, and so,
    00:12:16,031I've kind of got varying hardness of my high-hat hits here.
    00:12:20,474But I wanted to just actually make this simpler,
    00:12:23,136and every time I hit a drum or a high-hat or a cymbal,
    00:12:26,080I want it to trigger something.
    00:12:28,577So that's what we're gonna do, and to do that,
    00:12:31,422all we need is this duration property here okay.
    00:12:35,392You can see there's one keyframe for each hit
    00:12:38,807and I've simplified the playing so that I could make sure
    00:12:43,407that all of my hits end up triggering and registering,
    00:12:51,508so we have a keyframe for every single drum hit.
    00:12:53,914And all I'm gonna need are these duration rows,
    00:12:57,418I don't need the velocity, I don't need the pitch.
    00:13:00,383So I'm just gonna quickly go through
    00:13:02,186and I'm gonna delete everything,
    00:13:04,221let me just do select all here,
    00:13:05,699and all I want to keep are the durations okay.
    00:13:09,720I'm just gonna deselect, I'm holding Command,
    00:13:11,787I'm just gonna deselect all of the durations here
    00:13:15,450for all of the channels.
    00:13:19,227And then I'm gonna delete everything else okay.
    00:13:21,588So now we literally just have keyframes
    00:13:23,497where every single hit is, and this is gonna be
    00:13:26,372a lot easier to deal with okay.
    00:13:28,396And if you zoom out, this isn't even the whole song.
    00:13:30,894The song is actually,
    00:13:32,090the part I recorded it's like a minute and a half long,
    00:13:34,039but let's just deal with this part okay.
    00:13:36,541(drum music)
    00:13:39,923Cool.
    00:13:40,981So here's where it gets crazy, frankly,
    00:13:45,601and I want to just level with you guys that this
    00:13:49,031is some pretty dense expression stuff here
    00:13:52,464and I'm gonna walk you through it as best I can.
    00:13:57,535What I suggest is if you really want to understand this,
    00:14:00,506don't just watch this tutorial, actually apply it.
    00:14:03,766I'll have the expressions that you can copy and paste
    00:14:06,268right off of this tutorial's page,
    00:14:09,141and I'm gonna walk you through them,
    00:14:10,171but until you actually get in there
    00:14:12,068and you type these things in, and you literally,
    00:14:14,874I want you to type in the code yourself, because your brain
    00:14:18,259needs to sort of internalize it and wrap itself around okay.
    00:14:22,019So how do we trigger something with a keyframe all right?
    00:14:25,952This is just kind of a fundamental problem
    00:14:28,647with After Effects, is how can I make an animation
    00:14:32,491and then have it triggered really simply based on keyframes?
    00:14:37,304So the main idea behind this actually comes from
    00:14:40,707Dan Ebberts' page, MotionScript.
    00:14:43,319If you get on there, he has a great tutorial.
    00:14:46,194Now the way he does it
    00:14:47,461is he basically uses layer markers right,
    00:14:50,304these little guys, to trigger animations.
    00:14:53,354It's the exact same principle though okay.
    00:14:55,686You're using an expression to figure out,
    00:14:58,864based on the current time all right,
    00:15:00,697so let's here, let me close this down
    00:15:01,956and we'll just focus on,
    00:15:05,009let's not use the high-hat,
    00:15:05,861let's figure out which one is the kick?
    00:15:07,581This is the kick right here, at channel one.
    00:15:12,613(drum music)
    00:15:14,886Actually, this is the snare.
    00:15:16,153But good enough, we'll use the snare.
    00:15:18,431Okay if we want something to happen every time, boom,
    00:15:21,958we hit one of these keyframes, we need to know
    00:15:25,081the current time of our comp right, and we need to know
    00:15:29,661where the closest keyframe is to the current time okay.
    00:15:33,923And basically we're doing a little bit of checking
    00:15:36,561on each frame, we're saying, "hey, am I on a keyframe?
    00:15:39,113"Am I on s keyframe, am I on a keyframe, am I on a,
    00:15:41,407"hey, I'm on a keyframe."
    00:15:43,622On that frame that we're on a keyframe,
    00:15:46,059we're gonna set the value of something to its initial value
    00:15:50,373all right and then, "I'm not on a keyframe anymore,
    00:15:52,788"I'm still not on a keyframe, I'm still not on a keyframe."
    00:15:54,777Every time it's not on a keyframe,
    00:15:56,727it's gonna figure out what should my current value be,
    00:16:00,606based on where the last keyframe was okay.
    00:16:04,447So for example, if I wanted,
    00:16:08,605here, we'll just use a circle.
    00:16:10,757We'll start simple.
    00:16:13,120Oh boy, people, here we go.
    00:16:15,444Here we go.
    00:16:17,608All right so let's say here's a circle right.
    00:16:20,838On every snare hit, I want it to jump, like grow really fast
    00:16:26,502and then slowly shrink down okay,
    00:16:28,373so let's just animate that real quick.
    00:16:30,655So you have to start your animations
    00:16:34,488with kind of the idle pose okay.
    00:16:37,158So this is the idle pose, just so you know.
    00:16:40,024Put a keyframe there.
    00:16:41,229As soon as it gets triggered right,
    00:16:44,063I want it to be much bigger
    00:16:46,506and then over 12 frames I want it to end up
    00:16:50,470back at its initial value
    00:16:52,357and let's just easy ease that okay.
    00:16:54,464(drum music)
    00:16:55,380Alright so that's what a snare hit's gonna look like, boom.
    00:16:58,397Okay, and I want that animation to be triggered
    00:17:02,732every single time we see a snare hit okay.
    00:17:07,717So here's what we're gonna do.
    00:17:09,782We're gonna write an expression to trigger this animation
    00:17:12,607every time we hit the snare.
    00:17:15,196Now the easiest way to do this is
    00:17:17,118to sort of create your animation like this right,
    00:17:20,961and then pre-comp the whole thing.
    00:17:24,705All right we'll just call this snare circle.
    00:17:27,642Now why are we pre-comping it?
    00:17:29,118Well here's why.
    00:17:30,554What we're gonna be doing is we're gonna have to
    00:17:32,726sort of manually be controlling some property right.
    00:17:36,973And if it was scale, that wouldn't be that hard
    00:17:41,466if we only had a couple of keyframes,
    00:17:44,067but we have three keyframes here,
    00:17:45,948and it's gonna just get a lot more complicated
    00:17:48,458if we try to, have to decide,
    00:17:52,068should the circle be at this value,
    00:17:54,839at this value or this value?
    00:17:56,303It's trickier with more than two values,
    00:17:58,538so the great thing is once you've pre-comped something,
    00:18:02,742you can just time remap it,
    00:18:04,234so I'm gonna enable time remapping.
    00:18:06,632And I'm gonna go forward and figure out like okay,
    00:18:09,023how much of this animation do I need?
    00:18:11,466I really only need half a second right.
    00:18:15,358Let's see, this is a 24 frames per second comp,
    00:18:19,160the thing is done by frame 13,
    00:18:22,310all right so let's just call it a second.
    00:18:24,577All we want is for the first second of this animation
    00:18:27,737to be triggered every time there's a snare hit.
    00:18:30,747So we basically need to write an expression for this
    00:18:33,523that's gonna figure out what frame should we be showing
    00:18:37,645of this animation based on where these keyframes are.
    00:18:43,508All right so let's jump right in.
    00:18:45,798So first we need to know the beginning and ending value
    00:18:49,871of that time remap that we want
    00:18:52,486to sort of interpolate between okay,
    00:18:53,917so why don't we say start value equals zero,
    00:18:57,755'cause we're gonna start at the first frame,
    00:18:59,699which is frame zero,
    00:19:00,817and then the end value is going to be one.
    00:19:05,652All right now why is it one, why isn't it 24 frames?
    00:19:08,557Well, even though this time remap property
    00:19:11,027is showing you frames, internally it's working in seconds.
    00:19:15,168It's just one of those confusing gotchas
    00:19:16,799that you need to know.
    00:19:17,731When you're writing expressions on things that need a time,
    00:19:20,032you're gonna actually work in seconds, not frames.
    00:19:23,336And if you wanna work in frames you need to convert,
    00:19:25,489and maybe divide the result by
    00:19:27,31324 or 30 based on the frame rate.
    00:19:29,847All right so now we know that, we also need to know
    00:19:33,994what the current comp time is, so wherever our play head is,
    00:19:36,976we need to know where that is.
    00:19:38,147We don't need to do anything, because After Effects
    00:19:40,591has a built in variable called time,
    00:19:44,074and so all you do is type in time and it will return
    00:19:46,727whatever the current time is, but we do need to know
    00:19:50,224where the nearest keyframe is.
    00:19:52,412After Effects has a,
    00:19:55,718has a function built in that will let you
    00:19:58,522figure out where the closest keyframe is to anything.
    00:20:01,091Okay so the way it works is this.
    00:20:03,478I first need to tell After Effects
    00:20:05,640which property I'm looking at
    00:20:07,276to figure out where the closest keyframe is.
    00:20:09,573That property in this case is this slider,
    00:20:12,613so I'm gonna make a variable.
    00:20:15,104So our reference property equals,
    00:20:17,473and then I'm just gonna pick-whip that slider, cool.
    00:20:22,149Next, I want to figure out
    00:20:25,794where the closest keyframe is okay.
    00:20:29,546And so what I'm gonna do, I'm gonna make a variable
    00:20:31,229and I'm gonna call it N right, for nearest,
    00:20:33,930and this is how it works.
    00:20:36,230To find the nearest keyframe, you first type in
    00:20:38,481the name of the property that you want
    00:20:41,239to find the nearest keyframe for, then you add a period
    00:20:44,325and you're gonna add the function nearestKey.
    00:20:48,872In parentheses, you then have to give After Effects the time
    00:20:52,904and the reason you can do that
    00:20:54,808is 'cause what if I wanted to know
    00:20:56,648where the nearest keyframe is
    00:20:59,666to the beginning of my layer right?
    00:21:02,957And not necessarily the nearest keyframe to my play head,
    00:21:05,791but the nearest keyframe to something else.
    00:21:08,388So because I want the nearest keyframe to my play head,
    00:21:11,720I'm just gonna type in time and close that off okay.
    00:21:15,570Now this doesn't do anything yet,
    00:21:16,741but I wanna stop for a minute
    00:21:17,904to show you a little trick I use sometimes
    00:21:19,828when I'm doing expressions to help me figure stuff out.
    00:21:23,059I'm just gonna make a type layer here.
    00:21:26,002And I'm gonna come up here, I'm gonna open up the type layer
    00:21:29,224and reveal the source text property.
    00:21:31,833Source text lets you actually change
    00:21:34,300what the type layer says,
    00:21:36,121and you can put expressions on that.
    00:21:38,004So if I copy this expression and I hold Option,
    00:21:40,588click the stopwatch and paste it in there.
    00:21:44,647There we go.
    00:21:46,900What I want to do is I actually want this type layer
    00:21:49,512to show me the current, sorry, not the current time.
    00:21:53,570I want it to show me the time of the closest keyframe.
    00:21:57,228Like where in time is the closest keyframe?
    00:22:01,017So I've got this variable here, N right,
    00:22:04,544and N, you might think what it's gonna return,
    00:22:09,457like with the value of N, is going to be a time,
    00:22:13,326but it's not.
    00:22:14,159What it's actually going to be is, and this may be weird
    00:22:17,338if you have no programming experience
    00:22:18,838but N actually becomes a keyframe okay.
    00:22:23,927This nearestKey function, it doesn't give you the time
    00:22:27,333of the nearest keyframe, it gives you a keyframe.
    00:22:30,347Once you have the keyframe, you can ask the keyframe,
    00:22:33,824"Hey, what time are you at?" Right
    00:22:36,392or "what index number do you have?" Right.
    00:22:39,265And the way you do that, you take the variable N
    00:22:42,505and you put a dot, and then you can ask it a question.
    00:22:45,212My question to you, N, is what time are you at?
    00:22:49,531Okay and so now, this type layer is gonna show me the value
    00:22:55,478of the nearest keyframe, or sorry, not the value,
    00:22:58,481the time of the nearest keyframe.
    00:22:59,981So the nearest keyframe, you can see this hasn't changed
    00:23:02,525because if I'm at the beginning,
    00:23:04,269this is the nearest keyframe.
    00:23:05,612If I'm here, it's the nearest keyframe.
    00:23:07,232And as I go forward, it changes right there
    00:23:12,250because now the nearest keyframe is here
    00:23:14,321and this is where we run into a little bit of a curveball,
    00:23:20,269the value of the nearest keyframe is gonna change
    00:23:22,374when we get to the middle.
    00:23:24,345There's not a simple way to just say,
    00:23:25,823"okay, I want to know where the next keyframe is."
    00:23:29,724Right, it only can give you the nearest one.
    00:23:33,026Another thing you can ask the keyframe
    00:23:34,369is what index are you right?
    00:23:37,340And the index is, literally, what number are you?
    00:23:40,379You're the first keyframe, you're the second,
    00:23:42,718third, fourth, fifth, right?
    00:23:45,239So that's gonna be very useful too.
    00:23:47,214All right so let's just keep that up,
    00:23:48,940it's just kinda nice to know
    00:23:49,927like when you're writing expressions and sometimes
    00:23:52,055you're having trouble figuring out what they're doing,
    00:23:55,892you can just make a type layer and just use it
    00:23:58,968almost like a little debugging thing, so let's lock that.
    00:24:02,340All right so let's hop back into our time remap expression.
    00:24:05,472So, N is actually the keyframe.
    00:24:10,798What I actually want N to be though,
    00:24:12,988is the index of the nearest keyframe,
    00:24:16,273and you'll see why in a minute okay.
    00:24:19,759So what we need to do is...
    00:24:25,159So let me try to talk you through this,
    00:24:26,625this is gonna be very hard to explain
    00:24:28,008but what I want this expression to do
    00:24:30,875is check to see, "hey, are we on a keyframe>"
    00:24:35,150if we're on a keyframe, I want time remap to be zero.
    00:24:39,382And then, as we get further
    00:24:40,987and further away from the keyframe,
    00:24:43,751I want the time remap to increase right,
    00:24:47,458to play the animation that we've created in this pre-comp.
    00:24:51,275And so if we're one second in front of this keyframe,
    00:24:54,744I want that animation to stop, and then we'll just wait
    00:24:59,065until the next keyframe, boom, here's another keyframe,
    00:25:01,201go back to zero and then as we get further and further away
    00:25:03,979play and play and play, oh, another keyframe.
    00:25:06,168So what we need to know in order to make that happen
    00:25:09,484is we need to know what the difference is between
    00:25:12,805the current time and the time of the last keyframe.
    00:25:17,372Okay so if the last keyframe was a second ago right,
    00:25:24,649then I know that a second has passed,
    00:25:27,181so this time remap should be one second right.
    00:25:30,650If it's a half-second, this time remap should be one second.
    00:25:33,001So what I'm gonna do is I'm gonna subtract the current time,
    00:25:36,262or sorry, I'm gonna subtract the time of the last keyframe
    00:25:38,969from the current time, and that'll basically
    00:25:41,308give me the value of the time remap okay.
    00:25:46,062Then we have a wrinkle here, because the only variable
    00:25:51,118I have so far is the index of the nearest keyframe,
    00:25:55,229not the previous keyframe, so in order to make sure
    00:25:57,761we're always looking at the previous keyframe,
    00:26:00,311we need to check to see where we are in time.
    00:26:03,405And think of it this way, if we are,
    00:26:06,371if the current time right,
    00:26:09,776is greater than the time of the nearest keyframe,
    00:26:14,460then that means we are in front
    00:26:15,979of the keyframe that we're focusing on right.
    00:26:18,857Once we get to here,
    00:26:21,090well now the time of the nearest keyframe
    00:26:23,213is actually greater than the current time,
    00:26:25,852and in that case, we want to look back one keyframe
    00:26:29,723and make sure we're still focused on the right one.
    00:26:32,389So that's why this variable N is now the index
    00:26:36,396of the keyframe because what that's gonna let me do
    00:26:38,526is make a little condition okay.
    00:26:41,056If this play head is on or in front of the nearest keyframe,
    00:26:49,233then I want to use, I want to find out,
    00:26:51,893okay look, right now the nearest keyframe's index is one
    00:26:54,792and we know that our time is in front of this okay.
    00:27:00,446Then what I need to make sure
    00:27:01,498is that I'm asking the keyframe with the index of one,
    00:27:04,891"what time are you at?"
    00:27:06,193but as soon as we get closer to this keyframe,
    00:27:08,721well now my index is switching.
    00:27:11,514And so now, the condition's being that now,
    00:27:16,316the time of the keyframe with index two
    00:27:19,130is actually later than the current time.
    00:27:21,331Well in that case, I don't care about keyframe index two,
    00:27:24,784I still want keyframe index one.
    00:27:27,630So here's what we're gonna do.
    00:27:29,290This N is the index of the nearest keyframe,
    00:27:33,093and what I'm gonna do is type in an if statement okay
    00:27:36,923and this is how it works, if, parentheses,
    00:27:39,411and then in parentheses, what condition are we checking?
    00:27:42,048Is the current time,
    00:27:44,710and I wanna know, is it greater than
    00:27:48,162or equal to the nearest keyframe time?
    00:27:53,422Okay, so is it greater than or equal to,
    00:27:58,151and this is how you type that in,
    00:27:59,258greater than or equal to, that's what that means.
    00:28:02,574The time of the nearest keyframe okay.
    00:28:07,198And so what I'm gonna do actually,
    00:28:08,511let me quickly come up here
    00:28:11,872and copy this and paste it.
    00:28:15,067And I'm just gonna make another variable called nTime,
    00:28:17,541to make this easier to check.
    00:28:20,723And all I'm doing is instead of getting the index,
    00:28:23,179I'm getting the time of the nearest keyframe okay.
    00:28:26,062So if the time is greater than or equal to nTime right,
    00:28:31,795then what needs to happen?
    00:28:35,023Well in that case,
    00:28:37,377actually, you know what, I'm doing this backwards.
    00:28:39,340Ah, I screwed up, I'm gonna let you see it.
    00:28:41,356I'm gonna let you see me squirm.
    00:28:42,847Here's what we're gonna do.
    00:28:44,440We are going to check if the time
    00:28:46,710is less than or equal to the nearest keyframe time.
    00:28:50,482Now why are we doing that okay?
    00:28:53,407Okay, here's why.
    00:28:55,656If the time is equal to or greater than
    00:29:01,382one of these keyframes,
    00:29:02,215then we don't have to worry about it okay.
    00:29:05,046Because all we need to do is ask the nearest keyframe,
    00:29:07,643"hey, what time are you at?"
    00:29:09,143And then subtract that time from the current time
    00:29:10,716and we'll get our answer.
    00:29:12,648The problem happens when we are, when the current time
    00:29:16,392is less than the nearest keyframe, and when that happens
    00:29:20,761we do need to deal with it, we do need something to happen,
    00:29:23,015so that's why I'm gonna deal with that condition first.
    00:29:26,855If that's the condition, the current time
    00:29:29,173is less than or equal to the nearest keyframe's time.
    00:29:31,889If that is the case, you'll notice I just tabbed over.
    00:29:36,995you don't have to do that, it just makes your code
    00:29:38,997a little bit easier to read.
    00:29:40,582But if that happens, then I wanna make sure that
    00:29:43,994I am no longer looking at the keyframe with index of two.
    00:29:48,165I wanna look at the keyframe with index of one.
    00:29:51,691So what I wanna do is basically take this variable N right,
    00:29:55,546which is the index of the nearest keyframe,
    00:29:57,922and I wanna subtract one from it.
    00:29:59,946So you could just say N equals N minus one.
    00:30:04,161There's a shorter way to do it.
    00:30:05,999The short cut is just N minus, minus,
    00:30:09,028that just increments N by one.
    00:30:11,469And you can also do N plus plus right.
    00:30:13,868But N minus minus, and then go to the next line,
    00:30:19,191and I close the little curly brackets okay.
    00:30:23,699So what that has done is we have a variable N,
    00:30:27,664N is the index of the nearest keyframe, one or two.
    00:30:32,229In this case, it's two.
    00:30:33,807But, because the time of keyframe two
    00:30:37,308is actually ahead of our play head,
    00:30:39,202we're gonna increment N down by one,
    00:30:42,714so now we're looking at this keyframe again.
    00:30:44,886What this ensures is that we are
    00:30:46,233always looking at the keyframe behind us.
    00:30:49,091Okay, cool.
    00:30:50,111So now that we've done that, what we need to do
    00:30:52,329is figure out what is the difference in time
    00:30:54,714between our current time and this keyframe's time.
    00:30:58,373So what we need to do is now figure out
    00:31:00,750the exact time of this keyframe.
    00:31:02,829Okay so if we are here or we are here,
    00:31:07,017what we want to use is this N variable okay.
    00:31:10,465So what I'm gonna do is, let's just put the play head here
    00:31:13,198and let's say that the near key time equals N,
    00:31:21,984okay, sorry, that's not what we want to do.
    00:31:24,652N is the index of,
    00:31:29,054N is the index of this keyframe.
    00:31:31,292It is not actually the keyframe so what we're gonna do
    00:31:33,146is we have to type a slightly different expression here.
    00:31:36,629We are going to start with this refProperty variable,
    00:31:39,830so remember that refProperty
    00:31:42,791is referring to this slider here.
    00:31:45,435Then we're gonna put a period,
    00:31:46,916and we're gonna use the term key.
    00:31:49,397What this allows us to do is actually
    00:31:51,649access all the keyframes on that layer,
    00:31:54,368and if you type in key and then in parentheses
    00:31:56,517put a number, like that,
    00:31:58,476it will actually refer to the first keyframe right,
    00:32:01,612or the second keyframe.
    00:32:03,408If we put a variable in there, N,
    00:32:05,691it's referring to the Nth keyframe right,
    00:32:09,107whatever this number is right, whatever the value of N is,
    00:32:13,530that's the keyframe it's looking at.
    00:32:15,432So because we have this little if in there,
    00:32:18,001it's always gonna be referring to the keyframe
    00:32:20,900just behind the play head.
    00:32:23,361Okay and now that we've figured out what keyframe we want,
    00:32:26,170we can also ask that keyframe, so dot time, hey.
    00:32:30,403So let me try to put this in English for you,
    00:32:32,705we are saying the near key time variable equals
    00:32:36,118this property right here,
    00:32:38,156and then we're asking that property,
    00:32:39,790"hey, I want to know about the keyframe with the index n."
    00:32:44,682N right now is one, so I'm asking it about this keyframe
    00:32:47,170and then we're asking that keyframe,
    00:32:49,334"hey, what time are you at?"
    00:32:50,321And that's the result,
    00:32:51,441that's what this variable's gonna get okay.
    00:32:55,259And so then what we wanna do is we want to,
    00:33:00,854why don't we just say D.
    00:33:03,812I always use D when I'm doing subtraction
    00:33:06,435'cause D is for delta,
    00:33:07,620delta's another word for change right.
    00:33:09,778So the change, D, is the current time
    00:33:14,077minus the near key time, cool.
    00:33:19,619So if we are here at one second, the time is one,
    00:33:25,383and the keyframe here is at a little after half a second,
    00:33:32,303okay so it's like 0.6.
    00:33:34,000So D is gonna equal 0.4.
    00:33:36,700If the play head was right on this keyframe,
    00:33:39,440D would equal zero, okay because if we're sitting here
    00:33:43,701at 0.6 seconds, and this is at 0.6 seconds, this keyframe,
    00:33:46,837then it's zero, and as we get further away
    00:33:48,788that value will increase.
    00:33:50,720So we have an increasing value, and we want to interpolate
    00:33:55,746that value between zero and one seconds
    00:34:00,213to play this animation okay.
    00:34:03,258Hopefully it's starting to click,
    00:34:04,837I know this is pretty, pretty wacky.
    00:34:06,869So I'm gonna use the linear expression like we did
    00:34:08,982in part one of this tutorial, so I'm gonna say linear,
    00:34:11,605we are looking at the variable D, we know it's gonna go
    00:34:17,251between zero and we actually don't know what value,
    00:34:25,701like what the maximum value of it's going to be
    00:34:27,445but it really doesn't matter.
    00:34:28,902The way the linear expression works
    00:34:30,155is if I give this a value of zero and one
    00:34:32,648and at some point the value of D ends up being two,
    00:34:36,416right, greater than this range,
    00:34:38,468what it does is it caps it right.
    00:34:40,485So this kind of clamps your values.
    00:34:43,288So since my start value is zero and my end value is one
    00:34:46,478I want to make sure
    00:34:47,311that I'm looking for zero and one all right.
    00:34:51,014And an easier way to do this would just be,
    00:34:54,330just use those variables, the start value,
    00:34:56,188and the end value okay.
    00:34:58,567So we're looking at variable D,
    00:35:01,195looking for numbers between zero and one
    00:35:03,686and then we just want to return values between zero and one
    00:35:09,424so in this case this is actually kind of a unique case
    00:35:12,527for this linear expression.
    00:35:16,476You know we're using the same two variable here
    00:35:19,462and actually I gotta make sure,
    00:35:21,679these are case sensitives,
    00:35:22,595so make sure that you use the same case when you do this.
    00:35:27,279We're basically interpolating values of this variable
    00:35:31,340from zero to one to zero to one
    00:35:33,708so that's why these are the same okay.
    00:35:36,499It won't always be like that but for using,
    00:35:41,134for using linear to trigger animations
    00:35:43,127a lot of times you are using the same variables.
    00:35:45,247All right so let's see what happens all right,
    00:35:47,346let's see if this thing actually works, okay.
    00:35:50,836So let's turn on our layer here.
    00:35:55,270All right, now here is the problem okay.
    00:36:00,765We're getting an error.
    00:36:02,174And this is where I had to look this up for help
    00:36:05,488because I wouldn't have known how to do this either.
    00:36:08,594So there's a problem.
    00:36:10,846The first problem is if we open up,
    00:36:13,903I keep closing this which I shouldn't,
    00:36:14,960I should just leave it open,
    00:36:15,915but if you look at this you're gonna have a problem
    00:36:21,424at the beginning of the animation right
    00:36:23,221because there is no keyframe back here
    00:36:26,017and the nearest keyframe is in front of us
    00:36:29,027which means that we're actually gonna take this N variable
    00:36:32,593and subtract one from it.
    00:36:34,763The problem is this is the first keyframe
    00:36:36,612so if we do that we're gonna have a problem
    00:36:38,592so what you can do is you can have another if statement
    00:36:42,004saying, "hey if the nearest keyframe to me is in front of me
    00:36:47,230"and it's the first keyframe
    00:36:49,187"then don't do anything yet," okay.
    00:36:52,501So why don't we try that?
    00:36:53,987Let me just try that and see if that does it
    00:36:56,120but I believe I'm still gonna have a problem
    00:36:58,295so here's what we need to do.
    00:37:01,607Okay we're gonna change
    00:37:03,025this if then statement just a little bit.
    00:37:05,275If the current time is less than
    00:37:08,688or equal to the time of the next keyframe
    00:37:10,921well that's the case right now.
    00:37:13,918The next thing we need to do is add one more if okay
    00:37:17,271so if that's the case we'll then also check for this.
    00:37:19,763Is N greater than one?
    00:37:28,259Okay.
    00:37:29,722Now the reason we're asking if N is greater than one
    00:37:34,077is because there's this one case
    00:37:36,257at the beginning of the animation
    00:37:37,726where the nearest keyframe is in front of us
    00:37:40,301and normally what we want to do
    00:37:41,648is make sure we subtract one from N
    00:37:43,981so that we're looking at the previous keyframe.
    00:37:45,711Well in this one case at the beginning
    00:37:48,218there is no keyframe
    00:37:49,714so we don't want to do anything yet okay.
    00:37:53,043So if N is greater than one right, if we're already,
    00:37:57,047if we're looking past this, cool, right.
    00:38:01,841But if not don't do anything, okay.
    00:38:05,197And let's see here.
    00:38:06,943So let's see, hey look at that.
    00:38:09,040All right so let's do RAM preview,
    00:38:10,278let's see what we got.
    00:38:11,790(drum music)
    00:38:17,946Well holy bajeez look at that we have a working expression.
    00:38:22,476Now it's interesting, this is actually slightly different
    00:38:25,514than the expression that I used to actually make the demo.
    00:38:29,118If we look at that expression.
    00:38:32,199Is it here?
    00:38:38,163I've actually had to include some other stuff
    00:38:40,794because I was getting errors
    00:38:42,061and there's actually ways in After Effects expressions
    00:38:44,765to check is there an error
    00:38:46,705and if there's an error do this and if not do this.
    00:38:49,779But it looks like right now everything's working
    00:38:51,844so I'm not gonna look a gift horse in the mouth.
    00:38:53,748All right so hopefully you understand what's happening okay.
    00:38:59,027We're doing, we're kind of doing a couple things,
    00:39:01,429we're checking to see where the nearest keyframe is.
    00:39:04,936If it's in front of us look back one keyframe.
    00:39:08,927So let's figure out how far we are
    00:39:10,678from the previous keyframe
    00:39:11,702and let's use a linear expression to trigger this animation.
    00:39:19,649Now here's, now this is great right
    00:39:21,507and for a kick drum or something like that
    00:39:25,241or something that's just kind of repeating
    00:39:28,887and you're not playing too many notes
    00:39:30,356too close together this is great, okay,
    00:39:33,347but let's go to here,
    00:39:34,969this part where we have four snare hits in a row okay.
    00:39:41,427Okay.
    00:39:44,113Okay, you see how it gets a little funky in there?
    00:39:47,037It gets a little funky in there, okay.
    00:39:52,333And the reason it's getting funky
    00:39:54,068is because these are so close together
    00:39:56,665and the animation starts to play.
    00:40:01,060Boom, but then it has to then start over again.
    00:40:04,240And it would be really nice
    00:40:07,483if you could sort of have overlapping animations.
    00:40:11,144And not just have something that just basically,
    00:40:14,849it starts playing at the first frame
    00:40:16,718and it plays until it hits another keyframe
    00:40:18,674and then it jumps back to the first frame.
    00:40:20,371You want it to be a little smoother
    00:40:21,844and maybe have some overlapping notes and stuff.
    00:40:27,121And just to show you though how cool this is,
    00:40:28,746so that's the snare circle right.
    00:40:31,126If I, let me scale this down a little bit,
    00:40:34,759and then let's duplicate it.
    00:40:36,090And let's make this the kick circle, okay.
    00:40:39,727Make this 100% and then let's just fill this
    00:40:42,166with a different color right.
    00:40:46,048So one will be a little darker.
    00:40:49,527So one is gonna be the kick, one is gonna be the snare.
    00:40:53,335And actually this is a good time to talk about
    00:40:55,446sort of the other things I did with these expressions
    00:40:58,174to make this a little bit easier to deal with right
    00:41:00,173because what I want to do now
    00:41:02,347is I want to use this exact same expression
    00:41:05,730except I want to reference a different property okay.
    00:41:09,321And if I have eight instruments or 10 instruments
    00:41:13,079and I want to keep coming in here
    00:41:16,355and changing this every single time
    00:41:19,507it gets a little bit annoying
    00:41:22,332and it also could be a problem
    00:41:23,871if I decided to tweak the MIDI a little bit
    00:41:28,078and re-export a new one
    00:41:30,653and I just want to like bring in a new MIDI file
    00:41:33,130but have all this stuff line right up to it
    00:41:36,067so what I did is I did a couple of things right.
    00:41:38,358So actually, let me turn this off for a minute.
    00:41:42,243Let me actually delete this.
    00:41:43,135And we're gonna do a quick tweak to this snare expression.
    00:41:47,384I'm gonna add a new null
    00:41:50,272and I'm gonna call this song control
    00:41:54,917and I'm just gonna use this null
    00:41:57,461to tell every single layer in my comp that needs to know
    00:42:01,360which layer has the MIDI information okay.
    00:42:04,351And so I'm gonna use an expression control
    00:42:06,054called layer control
    00:42:08,047and this is gonna be renamed to a MIDI layer
    00:42:10,720and this expression control,
    00:42:12,733it let's you pick any layer in your comp
    00:42:15,379and then other layers can pick-whip to that right
    00:42:18,716so my MIDI layer is layer four okay.
    00:42:25,186So first thing I could do
    00:42:27,047is open up my expressions here
    00:42:29,453and I can change the first part of this,
    00:42:31,276reference property equals
    00:42:32,845and instead of doing this right,
    00:42:37,935this comp, the layer called MIDI,
    00:42:40,798I can pick-whip if I open this up.
    00:42:46,852I can pick-whip to this, okay.
    00:42:50,654So now it's saying this comp, the layer song control,
    00:42:55,658the effect MIDI layer okay
    00:42:57,614and what that's actually doing
    00:42:58,780is it's gonna pick the layer,
    00:43:00,640it's gonna pick your After Effects layer from this okay.
    00:43:04,880So that didn't mess anything up okay,
    00:43:06,982it didn't change anything, but now if I ever needed to
    00:43:11,093I could pick a different MIDI
    00:43:12,734and this would automatically update okay.
    00:43:15,060The next thing I want to make easier on myself
    00:43:17,196is I know that each of these,
    00:43:23,369each of the instruments is on a different channel.
    00:43:26,540Okay and I want to easily pick channel zero,
    00:43:28,722channel eight, channel 11, channel 10.
    00:43:30,480I want make this easy on myself.
    00:43:31,893So on the actual snare circle layer
    00:43:34,400I'm gonna add an expression control that's a slider control.
    00:43:38,500And I'm gonna call that channel okay.
    00:43:41,690And what I'm gonna do here, so first off let's see,
    00:43:45,853so we are currently using channel one okay
    00:43:51,224so let me make sure this is set to channel one
    00:43:53,451and what I'm gonna do
    00:43:54,920is I'm gonna make a new variable in this expression
    00:43:56,790and I'm just gonna call it channel
    00:43:59,660and I'm gonna set it to this, okay.
    00:44:04,547And what I'm gonna do is I'm gonna change this part
    00:44:10,237of the expression a little bit.
    00:44:11,461Okay so right now the reference property variable
    00:44:14,810is being set to whatever layer is being picked here
    00:44:18,614and then on that layer it's looking for an effect
    00:44:21,941called channel one duration
    00:44:25,237and I don't want it to always look for that,
    00:44:28,088I want it to look for channel whatever this is set to,
    00:44:32,269duration, okay.
    00:44:33,228So what I'm gonna do
    00:44:34,584is I'm actually gonna close my quotes here, all right,
    00:44:39,962and I'm gonna close my quotes here.
    00:44:44,230I'm gonna delete this one that's hard coded in there okay.
    00:44:49,221And so what I'm gonna do,
    00:44:50,054you see how I've separated these two parts of this string,
    00:44:53,721C, H, underscore and underscore D, U, R,
    00:44:56,229and what you can do is you can just add another part
    00:45:00,833to this string and it will sort of create
    00:45:03,648the new type for you right.
    00:45:05,764So C, H, underscore and then I'm gonna add
    00:45:08,229whatever number that is, all right,
    00:45:09,866so that number is whatever this channel variable is
    00:45:14,409and then I'm gonna add the last part of that and hit Enter.
    00:45:19,285And we are getting an error.
    00:45:23,575And what it's, let's see error, line four.
    00:45:25,435Okay so something here with the syntax isn't working.
    00:45:29,458I think what it might be is I need to make sure
    00:45:35,126that this variable right now,
    00:45:39,036it's giving me a number,
    00:45:40,479but I need to make sure
    00:45:42,255that it's actually giving me the value of that number
    00:45:46,721and not like some representation of that number
    00:45:50,041so I'm actually just gonna add a dot value
    00:45:52,895to the end of the channel.
    00:45:53,920All right so that fixed it,
    00:45:55,151so channel equals that slider dot value
    00:45:59,559and then that variable basically just gets plugged in there.
    00:46:03,273And what's cool is if I duplicate this now.
    00:46:05,903So that's my snare circle.
    00:46:07,133So now let's make my kick circle all right
    00:46:10,683and let's generate a fill and make it some kind of color.
    00:46:18,154And let's scale it back up to 100.
    00:46:20,528Okay so now what we have,
    00:46:21,943we have two layers reacting to the snare
    00:46:27,330but I want this one to react to the kick
    00:46:29,058so let's figure out what channel the kick's on.
    00:46:31,139Go into MIDI and let's just play it.
    00:46:36,980All right so it's this, it's channel 11, okay.
    00:46:40,308So now if I just go here and I type in 11.
    00:46:42,689(drum music)
    00:46:54,795Awesome.
    00:46:56,031Isn't that cool and now you could really easily
    00:47:00,301if you wanted to do the high-hat, just like,
    00:47:04,551maybe scoot it over here.
    00:47:05,384Let's figure out what channel's the high-hat,
    00:47:06,909it's this one, channel zero.
    00:47:09,024So if you just set this to channel zero, all right.
    00:47:14,931And make this one much smaller, let's make this 20%.
    00:47:17,752(drum music)
    00:47:24,655Greatness, okay, so now let's talk about
    00:47:28,081another way that you can use this MIDI information okay,
    00:47:30,178because this is cool and sometimes this is what you want
    00:47:32,361but sometimes you want things that can overlap,
    00:47:35,930and the best way to do that is with particles okay.
    00:47:39,321So let's do this.
    00:47:42,407Let's turn all this stuff off,
    00:47:44,783and let's,
    00:47:47,615here let me find out where is this,
    00:47:50,666where is this pre-comp?
    00:47:52,771It's here right here, snare circle.
    00:47:54,327Let's duplicate this and let's call this snare particle.
    00:47:59,044If this was gonna be a particle then what I would want
    00:48:03,311is for eventually that to disappear okay.
    00:48:10,122So why don't we say, let's do it this way okay.
    00:48:14,237Let's have it start at scale zero
    00:48:17,993and then really quickly grow fast, okay.
    00:48:23,231And then fade back over maybe a second.
    00:48:27,741Fade back to zero.
    00:48:30,874All right so that's the particle
    00:48:32,662that I want to be spawned
    00:48:34,267every time there's a snare hit, okay.
    00:48:37,667And what I'm gonna do, I'm gonna trim the comp like this.
    00:48:43,157When you're making a particle for any particle effect to use
    00:48:50,132you want to crop your comp
    00:48:51,854so that it's only as big as it needs to be
    00:48:54,016so I'm gonna click my region of interest button
    00:48:56,605and I'm just gonna try and crop this
    00:48:59,862so only as big as it has to be.
    00:49:07,899Cool and then you go composition, crop,
    00:49:11,198comp to region of interest.
    00:49:13,293There you go, so there's our particle.
    00:49:14,936Boom, okay.
    00:49:16,332And it's actually,
    00:49:17,698this is probably much bigger than we need it to be too.
    00:49:21,621So why don't we actually shrink this down a little bit?
    00:49:23,429I'm just gonna shrink it maybe 400.
    00:49:28,105All right and then I can just grab all these keyframes,
    00:49:31,096scale them down a little bit.
    00:49:33,548Make sure this starts at zero and ends at zero, cool.
    00:49:39,696So there's our particle.
    00:49:41,861I'm gonna bring this in here and I'm gonna hide it.
    00:49:44,295I'm gonna make a new solid
    00:49:47,141and I'm gonna put Particular on it
    00:49:49,474which is one of the best plugins out there.
    00:49:53,938All right so Particular, look at that.
    00:49:58,207So Particular, this is kind of the default thing it does.
    00:50:02,627And so what I'm gonna do
    00:50:03,639is first tell it to emit this as its particle,
    00:50:07,164so let's come here.
    00:50:08,702We'll go to the particle settings
    00:50:10,188and I mean Particular I could do 10 tutorials on,
    00:50:13,702there's a ton of settings
    00:50:15,024and I'm just gonna show you the ones you need
    00:50:17,585to get this effect to work.
    00:50:18,725So the particle, I'm gonna change that to a sprite,
    00:50:23,217all right, and sprite just means it's gonna let you
    00:50:25,390use another layer as its particle.
    00:50:27,591And I'm gonna go into texture
    00:50:28,938and I'm gonna say the layer I want you to use
    00:50:31,148is this snare particle layer, okay.
    00:50:34,559And time sampling I want it to start at birth
    00:50:37,098and play once, so what that means
    00:50:38,751is when the particle is born
    00:50:42,924I want it to play this animation one time
    00:50:46,783and then the particle's dead and that's it okay.
    00:50:51,373There's other cases where maybe you want it
    00:50:53,307to loop the animation over and over again,
    00:50:54,983but not in this case.
    00:50:56,384All right so then I'm gonna come up here.
    00:50:57,846Let me name this layer, let's see, new snare particle.
    00:51:06,108Okay, and, I'm just realizing that actually,
    00:51:10,222I actually made all those changes on this particle
    00:51:12,998which is not what I wanted to do
    00:51:14,142so let me fix that real quick.
    00:51:17,033So this is gonna be a sprite
    00:51:19,681and the texture is going to be snare particle, okay.
    00:51:25,154Then I need to make the size bigger.
    00:51:30,625So I can actually see, okay so cool.
    00:51:33,635So you can see what's happening, boom.
    00:51:36,436Right it makes those particles and then that's it right.
    00:51:43,336Pretty cool and what I want is to,
    00:51:47,234let me turn this off too 'cause we won't need that anymore,
    00:51:49,797what I want to happen is I want these particles to be born
    00:51:55,710every single time there's a keyframe
    00:51:57,985one thing I need to change real quick,
    00:51:59,504the time sampling on here
    00:52:00,665is supposed to be start at birth, play once.
    00:52:03,235There we go, okay.
    00:52:04,154So what it's doing right now
    00:52:05,327is it's generating these particles constantly okay
    00:52:08,240because that's what the plugin does.
    00:52:09,774And so what I want to do is I basically want to have a burst
    00:52:13,737of particles and the way you have a burst
    00:52:16,397is you change the emitter settings
    00:52:18,720so the particles per second right now is 100.
    00:52:22,405And so what I can do is I can put a keyframe here right.
    00:52:26,449Make that a whole keyframe and then go forward one frame
    00:52:29,280and make this zero, okay.
    00:52:32,367And so what that will do
    00:52:33,260is it will just make a bunch of particles and then stop
    00:52:36,948and then if I want I can do the same thing.
    00:52:41,663Go to zero now okay.
    00:52:43,571So it makes particles, it stops,
    00:52:44,967and then it makes more particles and then stops.
    00:52:46,374Now you see the flickering that's happening there?
    00:52:49,379This is one of the annoying things about Particular,
    00:52:53,036it actually, it kind of has a bug,
    00:52:55,974it's a known thing where if you're changing values
    00:52:58,594sometimes it doesn't delete the old frames it rendered
    00:53:00,987and it keeps showing you old frames.
    00:53:02,754An easy trick is you just go into the random seed here
    00:53:05,280and you change it right.
    00:53:06,687So now we'll kind of force it to re-render.
    00:53:09,481So there's one burst, and there's another burst, cool.
    00:53:13,874So if we can get this particles per second
    00:53:16,870to basically flip on for a frame and then flip off
    00:53:21,021we can create bursts of particles right.
    00:53:24,036So what I'm gonna do, let me grab the expression
    00:53:27,265that we wrote for our, here's our kick and our snare okay.
    00:53:34,732So let's grab it from this, copy it,
    00:53:38,551and let's bring it in here okay.
    00:53:40,810So I'm gonna put an expression on particles per second.
    00:53:42,825I'm gonna paste that in there
    00:53:45,238and here's what we're gonna change.
    00:53:46,785Instead of the result that we're sort of returning
    00:53:52,579being this linear property here.
    00:53:57,303What we need to do is we actually need to see, okay,
    00:54:00,598if our play head is on a keyframe.
    00:54:04,806Then I want a burst of particles.
    00:54:08,162If we are not on a keyframe I want no particles,
    00:54:11,064so the behavior's a little bit different,
    00:54:12,713we're not interpolating between values,
    00:54:14,490we're saying, "I want to be on for a frame and then off,
    00:54:18,017"on for a frame and then off," okay.
    00:54:20,476So really all we need to check is are we touching a keyframe
    00:54:25,326so we actually don't need to mess with all of this stuff,
    00:54:30,280all we need to know is where's the nearest keyframe,
    00:54:34,033are we touching it?
    00:54:35,383That's it okay, so near key time,
    00:54:38,195we're still concerned with that,
    00:54:39,511we're still concerned with the difference
    00:54:43,961between the current time and the near key time.
    00:54:49,045But what we actually really want to know is,
    00:54:53,750sometimes like if I'm having trouble
    00:54:55,429kind of articulating to myself what I need to do.
    00:54:58,950I'll just sort of walk through it
    00:55:00,669and kind of talk myself through it
    00:55:01,996so think about it where's the nearest keyframe?
    00:55:04,344It's here, okay are we touching it?
    00:55:06,723No, so we get here, okay we're touching it,
    00:55:09,450now okay so here's the tricky thing right,
    00:55:13,022the nearest keyframe is gonna be sometimes,
    00:55:19,716all right look right there,
    00:55:21,041the play head is here,
    00:55:21,997the keyframe is slightly in front of it.
    00:55:25,591The play head's here, the keyframe's slightly behind it.
    00:55:28,185The problem with MIDI information is sometimes
    00:55:30,294things do not come in on an exact frame, okay.
    00:55:34,769So what i actually need to do
    00:55:36,887is check to see if we're very close to the keyframe,
    00:55:41,998so if I just tried to do something like this right.
    00:55:48,556Let me come up here, oh boy, there we go.
    00:55:52,328If I tried to do something like this right.
    00:55:56,292If time equals, and if you're checking if something's equal
    00:56:02,954in After Effects you have to have two equal signs.
    00:56:04,967It's just something to keep in mind.
    00:56:06,472If time equals near key time,
    00:56:11,034then I want the value of the particles per second to be 100.
    00:56:18,503Otherwise, this is how the else thing works,
    00:56:22,898I close one set of curly cues, I say else,
    00:56:25,420I open up another set and then I can say zero, okay.
    00:56:32,978Oh right, and I forgot, so the error it just gave me
    00:56:37,115is it's looking for an expression slider called channel
    00:56:42,134on this layer which doesn't exist.
    00:56:45,337So what I'm gonna do
    00:56:46,170is I'm just gonna copy this channel slider
    00:56:50,512and paste it on here so now that should work, okay.
    00:56:55,466All right cool.
    00:56:57,391So...
    00:57:01,700So we are getting some particles
    00:57:03,464so let's listen to this and see what happens.
    00:57:09,107(drum music)
    00:57:13,818All right that's not really working that well, is it, right?
    00:57:16,240And we're getting like some random stuff here
    00:57:19,092and it's just, it's just not happening for us
    00:57:23,235and the reason it is right because if we look here
    00:57:27,148we're never actually hitting that keyframe,
    00:57:30,368we're getting really close,
    00:57:31,559but we're never actually hitting it
    00:57:33,598and so what we need to do
    00:57:35,051is actually check if D,
    00:57:37,851if the difference between the current time
    00:57:39,794and the nearest key time
    00:57:41,006is less than the duration of one frame, okay.
    00:57:47,128So here's the problem with that,
    00:57:48,495sometimes D's gonna be positive
    00:57:50,599and sometimes it's going to be negative
    00:57:52,741so if you think back to algebra
    00:57:57,312or, I don't remember when you learned this stuff now,
    00:58:00,669but the concept of absolute value right,
    00:58:03,810so if something is negative one or something is one,
    00:58:07,265the absolute value of both of those numbers is one
    00:58:09,927so that's what you need.
    00:58:11,342So what we're gonna do is we're actually gonna,
    00:58:14,392we're gonna check if the absolute value of D right,
    00:58:20,285so the way you get the absolute value of D
    00:58:22,444is you use a function called math.
    00:58:26,040So if and then in parentheses math
    00:58:30,174and then math has a bunch of things it can do
    00:58:32,296and one of them is get the absolute value.
    00:58:35,311If you can't remember this stuff
    00:58:38,133you can always click on this arrow
    00:58:40,172and look through all of these little groups right
    00:58:43,978and here's JavaScript math
    00:58:46,180and you can see there's absolute value
    00:58:48,155but you can also find out the square root and the cosine
    00:58:50,395and all this kind of stuff.
    00:58:51,756This is a great little reference for expressions
    00:58:53,511but if math absolute value of D
    00:58:58,624is less than, okay,
    00:59:00,298so basically whether D is positive or negative
    00:59:03,770we're gonna make it positive okay
    00:59:06,007and we are gonna see if the difference
    00:59:07,742between the current time
    00:59:08,825and the nearest key time is less than one frame
    00:59:12,087and one frame is one second divided by 24 frames, okay.
    00:59:19,488So if that's the case what do we do?
    00:59:24,028That means we are very close to a keyframe
    00:59:26,160so I want the value to be 100, okay.
    00:59:30,642Otherwise I want the value to be zero, there you go, okay.
    00:59:37,198Now let's RAM preview this.
    00:59:38,993(drum music)
    00:59:42,117All right, you see all that flickering?
    00:59:43,949That is that awesome problem that Particular has
    00:59:47,069where we need to change the random seed,
    00:59:49,714get rid of our old frames.
    00:59:56,846(drum music)
    01:00:02,292And there it is, beautiful.
    01:00:04,108Bursts of particles created by MIDI notes all right
    01:00:08,714and so what I wanted to do
    01:00:11,120was actually not have it create a whole bunch of particles
    01:00:13,311but just create one particle
    01:00:15,991and so to do that I kind of had to mess around.
    01:00:20,355Right now what it's doing is every time it hits a snare,
    01:00:25,510for one frame it's turning the particles per second to 100
    01:00:28,807and that's too high.
    01:00:30,085Now if I turn it to one
    01:00:33,191the problem is one particle and of course
    01:00:36,342now we have to change the random seed again
    01:00:39,086so it can, right.
    01:00:43,363A value of one particle per second, it can work.
    01:00:47,426The problem is sometimes it doesn't trigger right.
    01:00:53,119It triggers there but then it misses one
    01:00:55,817so one isn't enough and I kind of played with the values
    01:00:59,298and eight seemed to work pretty well.
    01:01:02,844(drum music)
    01:01:05,066And of course we need to change the random seed
    01:01:06,848so it resets.
    01:01:12,373There we go.
    01:01:13,693(drum music)
    01:01:19,209Cool.
    01:01:20,210And these particles are moving
    01:01:22,432and if I don't want them to move
    01:01:23,869I just set the velocity to zero
    01:01:25,255and the velocity random to zero
    01:01:27,209and then just let me turn the,
    01:01:29,709let me turn the size of these particles up too.
    01:01:34,424All right and there you go, okay.
    01:01:37,932And now we have our snare particle
    01:01:40,276and it's pretty close to the animation that we had before
    01:01:43,962except now they can overlap. (drum music)
    01:01:48,137All right.
    01:01:48,970Let's do the same thing with a kick.
    01:01:51,256Now that we've got this set up it should be pretty easy
    01:01:53,285so let's just duplicate this, call this new kick particle
    01:01:58,502and all I need to do all right.
    01:02:00,738So the kick is on channel 11
    01:02:02,586so let me just set this to 11
    01:02:06,228and then let's put, let's generate a fill effect for that
    01:02:10,682and make it, let's make it green this time.
    01:02:14,307All right and let's kind of scrub through,
    01:02:15,977so there's my kick.
    01:02:18,175And for this we can make this one a little bit bigger
    01:02:21,045or actually maybe what we'll do
    01:02:21,994is we'll make the snare particles a little smaller.
    01:02:25,701All right and we'll do,
    01:02:27,898let's go particle size a little smaller.
    01:02:32,810So there's some differentiation
    01:02:34,779between the kick and the snare
    01:02:36,034and let's see what that looks like.
    01:02:40,687(drum music)
    01:02:45,252So it appears to be working.
    01:02:47,690Now I know that right now this whole process
    01:02:51,542must seem really finicky and what a pain in the butt
    01:02:55,679and here's the thing right,
    01:02:59,832eventually I'm sure someone is going to create a script
    01:03:05,731or a plugin that makes this much much easier.
    01:03:10,772MIDI is far from the cutting edge
    01:03:13,226but using MIDI with After Effects,
    01:03:15,194it hasn't really taken off,
    01:03:17,542it hasn't been that popular
    01:03:18,700and that's why it was not easy
    01:03:20,426to find information about how to even try to do it.
    01:03:25,590And you know unfortunately right now
    01:03:27,105it's just sort of this clunky process.
    01:03:29,863I guarantee you if enough people start doing this
    01:03:32,686someone out there with a gigantic brain
    01:03:34,784is gonna make this much much easier,
    01:03:36,983but I'm actually pretty happy with the way this is working
    01:03:39,793and what I really hope is that it's,
    01:03:42,714we've really gotten into some deep expressions here
    01:03:44,353but it's also just kind of interesting
    01:03:46,774to look at After Effects as this tool
    01:03:48,987that you can plug in with other tools
    01:03:50,322and do other neat little things with.
    01:03:53,491Let's do one more little experiment here right
    01:03:55,710so I mean the beauty of this
    01:03:57,869is now we've kinda got two ways
    01:04:00,050of triggering animations right
    01:04:01,500like we've got, we have our high-hats over here
    01:04:06,032which is just an animation right, that's being triggered,
    01:04:09,854and why don't we make it a little bit more interesting too,
    01:04:12,218why don't we sort of,
    01:04:14,033why don't we make another little ellipse here,
    01:04:17,591but kind of make it do something like this right
    01:04:19,432and it can start like this and rotate.
    01:04:26,037It can just sort of like jump 90 degrees
    01:04:29,222and then rotate back to zero.
    01:04:32,026All right and you could just play with it
    01:04:36,270and just see what you can come up with,
    01:04:39,865but this technique here right, of time remapping a layer
    01:04:44,051based on the MIDI information.
    01:04:46,076That works great for stuff
    01:04:48,232that you want to be a little bit more complex
    01:04:50,476in the way it moves.
    01:04:54,240But you can trigger simple things with particles.
    01:04:57,389(drum music)
    01:05:02,676Right, so that's the high-hat
    01:05:03,861and you can see it feels jerky
    01:05:05,234'cause of how quick those high-hat hits are coming,
    01:05:08,626but you can use particles to trigger kind of simpler things
    01:05:15,385and then the last thing I'll show you guys
    01:05:18,390is you can just use Particular
    01:05:19,894as a sort of, as a particle system
    01:05:21,955and not even as a way to trigger animations.
    01:05:26,442We know that channel 11 is,
    01:05:28,639(drum music)
    01:05:29,656let's see channel 11 is the kick.
    01:05:33,619(drum music) Okay,
    01:05:36,420and we know that channel eight is the cow bell.
    01:05:40,302All right 'cause it's just a constant quarter note pulse.
    01:05:42,102So what that means is channel 10 must be that symbol.
    01:05:46,200So why don't we have that symbol
    01:05:47,216trigger a big burst of particles
    01:05:48,888okay so I'm gonna duplicate this
    01:05:51,732and I'm gonna call this new symbol zero one particle.
    01:05:56,303I'm gonna change the channel to be channel,
    01:06:01,548I believe it was 10, I've already forgotten.
    01:06:03,862This has been a long tutorial, let's just double check.
    01:06:05,762Yep channel 10 is that cymbal
    01:06:07,890and I'm just gonna change the settings on this.
    01:06:09,935Okay so instead of having the particles be a sprite
    01:06:14,620I'm just gonna have them be spheres
    01:06:17,125and they can be much smaller all right,
    01:06:19,645maybe five or something like that,
    01:06:22,199and so when I play this,
    01:06:25,117how can I know?
    01:06:26,135I'm just gonna do it preemptively,
    01:06:27,664I'm gonna have to change the random seed
    01:06:30,895so it sort of forces a re-render there.
    01:06:36,840Okay.
    01:06:37,980Now we're not seeing anything.
    01:06:40,163Oh there's zero velocity
    01:06:42,065so let's put some velocity on those particles,
    01:06:44,179so we can actually get some movement.
    01:06:46,142All right so you see
    01:06:46,975there's one particle floating away there.
    01:06:48,856If you actually want particles
    01:06:50,720like a big kind of fireworks looking thing
    01:06:52,736then going to 100 particles,
    01:06:55,487sorry eight particles per second isn't gonna do it.
    01:06:58,253We need that number to be much higher.
    01:07:00,678And I knew this, and being that I don't like
    01:07:05,435to have to keep diving in and diving into the code
    01:07:09,117and finding where that number is,
    01:07:12,031okay it's hidden down here, eight.
    01:07:14,918What I'd rather do is give myself a slider control
    01:07:19,331and say okay these little bursts,
    01:07:23,556bursts of particles, how many particles should there be?
    01:07:26,151And I'm just gonna use that slider to drive this value
    01:07:29,975so instead of eight
    01:07:31,257it's gonna use whatever I have this set to.
    01:07:33,492So if I set this to 100, right,
    01:07:37,552and then of course, oh Particular.
    01:07:41,288To make this easier on myself
    01:07:42,392I'm actually gonna duplicate this slider
    01:07:43,946and I'm gonna call this random seed
    01:07:46,301and I'm going to write and make a quick expression
    01:07:50,510linking the random seed to,
    01:07:53,661let me see if I can actually get to it way down here,
    01:07:55,873this slider.
    01:07:57,505There we go.
    01:07:58,540So now I can just change the random seed
    01:08:00,307just by messing with that.
    01:08:01,417That's a lot quicker right.
    01:08:02,283So now if we look at this.
    01:08:07,748Right, and you'll see it'll start taking a little longer
    01:08:10,437to preview okay.
    01:08:11,845Still not enough, let's up that,
    01:08:13,984let's make that burst amount 2,000, there we go.
    01:08:21,600Great.
    01:08:24,346That's better, okay,
    01:08:26,370and these particles are kind of boring right now.
    01:08:30,147I mean it works but it's kind of boring
    01:08:32,041and so let me solo these for a minute.
    01:08:34,024Oh what I did in the demo
    01:08:35,334was I really cranked up the velocity,
    01:08:38,214like really really high
    01:08:40,521so they really like explode when they come out.
    01:08:44,055But then at the same time I went into the physics tab,
    01:08:46,875into the air tab
    01:08:48,388and I turned up the air resistance a little bit,
    01:08:51,262right, so what it does is it makes them
    01:08:53,507shoot out really fast but then they slow down.
    01:08:58,358Right, and boom, right about there I'd like them to dissolve
    01:09:02,964so I'm also gonna go into the particle settings here
    01:09:06,891and I'm gonna set the life to just one second.
    01:09:11,127Give that a little bit of randomness,
    01:09:14,377but then I'm gonna go to opacity over life
    01:09:18,742and I'm just gonna have it kind of fade out
    01:09:21,054over the lifespan okay.
    01:09:22,483So now that burst is gonna look like this, cool.
    01:09:27,516(drum music) All right.
    01:09:30,845And so there you go.
    01:09:31,778Here let's duplicate that high-hat,
    01:09:34,152stick that over there,
    01:09:37,290and let that render out and oh man this is a long dense,
    01:09:42,389just geek fest of a tutorial people.
    01:09:46,271Thank you.
    01:09:47,104If you made it all the way through this
    01:09:49,067and you ever meet me in person I'll buy you a beer
    01:09:51,716because god bless you, I mean woo,
    01:09:54,254this must've been tough.
    01:09:56,655But hopefully you learned something here
    01:09:59,448and if nothing else you now have a little bit
    01:10:03,958of an understanding
    01:10:04,791of how frickin powerful expressions are okay.
    01:10:08,600I mean you gotta understand that like
    01:10:11,920if you came up with some setup of particles
    01:10:16,028and animations and things you're triggering with MIDI
    01:10:20,077and you love it and it looks awesome,
    01:10:22,465and some band wants to hire you
    01:10:24,563to do that for their entire concert set
    01:10:27,969all you have to do is update the MIDI
    01:10:30,689and this will all be done for you.
    01:10:33,919It's an amazing time saver for doing stuff like this
    01:10:38,033and this is just the tip of the iceberg.
    01:10:40,287This is kind of an obvious way
    01:10:42,973of using the MIDI information,
    01:10:45,008there's probably a lot of other really cool things
    01:10:47,554you could do, I mean using, if you had a MIDI keyboard
    01:10:52,726and I mean you could, there's ways you could map this
    01:10:55,999to actually literally be able to play an animation
    01:10:59,650and then have After Effects create it for you.
    01:11:02,704So anyway I'm gonna copy and paste these expressions
    01:11:06,116onto the site so you guys can just grab them
    01:11:08,489and paste them right on and use them okay
    01:11:11,585and I'll put some links to some free MIDI resources
    01:11:14,263in case you don't have the ability to actually use,
    01:11:17,798to create your own MIDI files,
    01:11:19,496but if you do, if you're a musician
    01:11:21,300or if you don't mind sort of getting your hands dirty
    01:11:24,407and programming some stuff
    01:11:26,372oh my goodness what a cool trick this is
    01:11:28,995and think of all the amazing things you could do with it.
    01:11:31,731So thank you guys,
    01:11:33,085I really appreciate all the troopers
    01:11:34,627who made it through this entire tutorial.
    01:11:36,636Promise this next one will not be like this
    01:11:38,265but every once in a while I gotta go off the deep end.
    01:11:41,168Thank you guys, I'll see you on the next episode
    01:11:43,021of 30 Days of After Effects.
    01:11:47,563That was a lot, thanks so much for hanging in there.
    01:11:49,716I really hope that this lesson showed you the power
    01:11:52,398of After Effects expressions
    01:11:53,792and what you can do with them
    01:11:55,428if you understand a little bit
    01:11:56,549and if you're willing to tinker
    01:11:57,973and kind of be like a mad scientist.
    01:11:59,503You can pretty much make the program do whatever you want
    01:12:01,902which is awesome.
    01:12:03,172If you have any questions let us know
    01:12:04,740and we'd love to hear from you
    01:12:06,552if you use this technique on anything.
    01:12:08,898So please give us a shout on twitter, @SchoolOfMotion.
    01:12:12,523Thank you so much, I'll see you on the next one.
    01:12:18,736(electronic music)