Edit: See note at end of article for warnings about this script AE CS 5.5 on Mac
Hello, pixel pushers and vert herders! Ah, it’s great to be back in After Effects land. Alas in this last year, the day job (got hired by Skype, acquired by Microsoft) and life in general (after throwing elaborate theme-parties for decades, planning a wedding wasn’t actually that hard, but still) got a little busy, but thankfully again have a little bit of time for my favorite things. That is, pixels.
Omino Python Since I released it this year, it’s been downloaded several thousand times, and about a dozen enthusiastic folks have licensed it. Alas, I don’t really have the time to either properly promote or properly support this as a paid product… so I’ll make it completely free soon.
Ok! So, MIDI!
What is MIDI
MIDI is a control protocol and file format invented 20-odd years ago for music playback on synthesizers. It records all the notes. A .mid file is typically quite small, since it has no sound data in it.
Into After Effects?
Yes! The attached script lets you read a MIDI file into After Effects, and provides keyframes with all the notes.
Install:
1. Download this file.
2. Put the file in /Applications/Adobe After Effects CS5/Scripts/ScriptUI Panels/
3. Run AE, and under window, choose om_midi.jsx, and dock the panel where you like.
Recipe
Here’s one way you could use this script. In the om_midi panel, click the little dot button, and choose a MIDI file. I used one from Wikipedia, BWV 772, one of JS Bach’s 2-part inventions.
Then, with a Comp selected, click Apply.
This creates a Null layer named “midi” with several Slider effects full of keyframes.
This particular MIDI file kept the left and right hands in separate channels, which is nice! The “pitch” effect has keyframes at the beginning of each note with a value of 60 for middle C, 61 for C-sharp, and so on. Here we can see the left and right hands’ keyframes.
A fun way to use these keyframes is to drive the Position property of another layer. I took a photo of my hand, and set the Position expression and Opacity expressions:
Position:
transform.position + 5*(0,thisComp.layer("midi").effect("ch_0_pitch")("Slider")-60)
Opacity:
transform.opacity * thisComp.layer("midi").effect("ch_0_vel")("Slider")
So the hand will move 5 pixels for each semitone, centered on Middle-C (60).
Then I rendered the audio as AIFF and added it to the comp. (I used Propellerheads Reason. Yeah… if you’re using MIDI you need yet another set of software to manipulate it.)
And here is the result animation:
More Notes
This is just the simplest usage. A more elaborate deployment might be to export just 1 part of a complex sound-track work as MIDI, to get some of the cues into your AE timeline. With more complex scripts or expressions, you could to much more than just move the hands around.
The script will put multiple keyframes with the same time-value! In the example above, you can see the hands flicker slightly as the final chord begins. Most of the the part invention has just 1 note per hand, which was nice for the demo.
Also, inside the script is a general-purpose MIDI file reader, which you could use for other purposes. I’ve generated Illustrator pictures from scores, for example, full of circles and triangles. Drop me an email or comment if you want help using it! It’s pretty fun.
Update 2012.01.08 Warning about AE CS 5.5 on Mac
Under Mac OS X AE CS 5.5, when you choose the file, it deletes it! This is a CS5.5 bug. (Works fine in CS5.)
Best workaround is to use AE CS 5 or AE CS 4.
Another workaround is:
- make a copy of the file, like myfile_copy.mid
- Select it in the script UI
- recopy the file (selecting it deleted it)
- click apply and all is well.
Hi, I was wondering if there’s a way of processing an Image (in a layer) in after effects.
reading pixel by pixel color value. can u’r python script provide answer? thanks