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.
[…] That has been true for the previously mentioned unwrapping cylinder thing and now it seems you can work with MIDI files in After Effects, after all. Not in the way that that person imagined (by tying them live to […]
any chance you can update this to work with CS 5.5? such an awesome script, but it doesnʻt work unfortunately. thanks for your hard work.
this is the coolest thing ever
^hyp: Did you make a new comp & load a real .mid file? It works fine in my 5.5.
Thank you for a great script I’ve been searching for a long time! Gotta start learning those expressions now.. 🙂
^arto I hope it’s useful for you.
^hyp — I tried AECS5.5 on Mac… and yes it’s broken. It deletes the file. This is a CS5.5 bug. Adding workarounds to the article…
GREAT STUFF MAN!!! THX FOR SHARING, IT’LL BE SUPER USEFUL FOR SOME OF MY PROPOSALS. REALLY APPRECIATE.
[…] 楽èœã®ãƒ‡ãƒ¼ã‚¿ã‹ã‚‰ä½œã‚‹ ã•ã¦ã€å°‘ã—ã ã‘変ã‚ã£ãŸæ–¹å‘ã‹ã‚‰AEã¨éŸ³ã®ãƒ‡ãƒ¼ã‚¿ã«ã¤ã„ã¦è€ƒãˆã¾ã™ã€‚å‹•ç”»ã ã‘ã§ãªãã€éŸ³æ¥½ã‚’制作ã•ã‚Œã‚‹æ–¹ãªã‚‰ã€ã‚ªãƒ¼ãƒ‡ã‚£ã‚ªã‚ˆã‚Šã‚‚楽èœã¨ã—ã¦ãƒ‡ãƒ¼ã‚¿ã‚’æŒã£ã¦è¡Œã‘ãŸã‚‰ã€å¬‰ã—ã„ã¨æ€ã„ã¾ã™ã€‚ MIDIã€ã¨ã„ã†ãƒ•ã‚¡ã‚¤ãƒ«å½¢å¼ãŒã‚ã‚Šã¾ã™ã€‚昔ã®HPã§æµã‚Œã¦ã‚‹éŸ³æ¥½ã«ã‚ˆã使ã‚ã‚ŒãŸã‚Šã€ã‚«ãƒ©ã‚ªã‚±ã§ã‚‚使ã‚ã‚Œã¦ã„ã‚‹å½¢å¼ã§ã™ã€‚ MIDIã¨ã¯ã€Œã‚る楽器をã“ã®å¼·ã•ã€ã“ã®éŸ³éšŽã§é³´ã‚‰ã™ã€ã¨ã„ã†æ¥½èœã®æƒ…å ±ã§ã™ã€‚ ã‚‚ã—ã€ã‚ªãƒ¼ãƒ‡ã‚£ã‚ªã®ãƒ‡ãƒ¼ã‚¿ã®ã»ã‹ã«ã€ã“ã®æ¥½èœã®ãƒ‡ãƒ¼ã‚¿ã‚’æŒã£ã¦ã„ãŸã‚‰ã€ã‚ˆã‚Šç¹Šç´°ãªæ˜ åƒã‚’作るã“ã¨ã‚‚å¯èƒ½ã§ã™ã€‚ ã“ã®MIDIã«ã¯ä¸€æ›²åˆ†ã®æƒ…å ±ã‚’æŒã¤ã“ã¨ãŒã§ãã‚‹ã®ã§ã€ä¾‹ãˆã°ãƒ”アノã¨ãƒœãƒ¼ã‚«ãƒ«ã®ãƒãƒ©ãƒ¼ãƒ‰æ›²ãŒã‚ã£ãŸå ´åˆã€ã‚ªãƒ¼ãƒ‡ã‚£ã‚ªãƒ‡ãƒ¼ã‚¿ã ã¨ä¸€ç·’ã®æ³¢å½¢ã«ãªã‚‹ã‹ã€å€‹åˆ¥ã«ç”¨æ„ã—ãªã„ã¨ã„ã‘ã¾ã›ã‚“ãŒã€MIDIã ã¨ãƒ”アノã¨ãƒœãƒ¼ã‚«ãƒ«ã€ãã‚Œãžã‚Œã®å€¤ã‚’1ã¤ã®ãƒ•ã‚¡ã‚¤ãƒ«ã§ãã¡ã‚“ã¨å–å¾—ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ ã“ã®om_midiã¯ã€MIDIã®ãƒ‡ãƒ¼ã‚¿ã‚’AEã«ã‚ーフレームã®æƒ…å ±ã¨ã—ã¦èªã¿ã“むスクリプトã§ã™ã€‚ http://omino.com/pixelblog/2011/12/26/ae-hello-again-midi/ヌルレイヤーã«ã‚¹ãƒ©ã‚¤ãƒ€ãƒ¼åˆ¶å¾¡ã‚¨ãƒ•ã‚§ã‚¯ãƒˆã¨ã—ã¦æƒ…å ±ãŒå…¥ã£ã¦ã„ã¾ã™ã€‚ ã“ã®ã‚¹ã‚¯ãƒªãƒ—トもã€ãã®1ã§ç´¹ä»‹ã—ãŸã€ŒAudioToMarkersã€ã¨åŒæ§˜ã«AEã®è¨€èªžã«åˆã‚ã›ã¦ä¸èº«ã‚’書ãæ›ãˆã‚‹å¿…è¦ãŒã‚ã‚‹ã®ã§æ³¨æ„ã—ã¦ãã ã•ã„。 ã¾ãŸã€æ³¨æ„ã™ã‚‹ç‚¹ã¨ã—ã¦ã€ä¿®æ£ã®å†…容ãŒãƒãƒ¼ã‚¸ãƒ§ãƒ³ã«ã‚ˆã£ã¦é•ã„ã¾ã™ã€‚CS5以上ã§ã¯ã€Œã‚¹ãƒ©ã‚¤ãƒ€ãƒ¼åˆ¶å¾¡ã€ã€CS4以å‰ã§ã¯ã€Œã‚¹ãƒ©ã‚¤ãƒ€åˆ¶å¾¡ã€ã§ã™ã®ã§æ³¨æ„ã—ã¦ãã ã•ã„。 ã¡ãªã¿ã«ã€ãã®1ã¨åŒæ§˜ã§ã‚¹ã‚¯ãƒªãƒ—トã®æ›¸ãæ›ãˆã§ã¯ExtendScript Toolkitを使用ã—ã¦ã„ã¾ã™ã€‚ […]
Hey, I was really happy to find this as I’m trying to sync sequences of frames to execute on specific keyframed values of imported midi notes.
Through asking some questions (I’m new to AE), I started a discussion at forums.adobe.com/message/4142986 to get insight.
You may want to take a look, one suggestion is utilizing markers instead of key frames. I would love to see an easier way to automate and include midi values for dynamics and so would like to see this script expanded a little bit, and I would love to get you included as this script seems the easiest way at the moment to get midi data in beyond simple rhythmic uses. Also, on 5.5, deleting original file but easy to work around with a copy of course.
Hi David,
Firstly, this works great!
Is there any chance of getting the JS Script to import CC midi values as well? I’ve got a MIDI file with a PITCHBEND envelope which would be awesome to have in after-effects.
Thanks again!
SB — Excellent Idea. I’ll add that to the next rev. (Though if you’re inspired and know the MIDI bytes a little, you might be able to add it yourself…)
But yes, PitchBend and Control tracks… Oh the fun!
Hey I just wanted to say thanks again, I’m going to be using this script a lot! I just finished this little thing which was pretty easy to make using the script and expressions your provided.
I’d also like to point out to others that if you’re going to be doing marker-based animation timemapping off of midi data, these two scripts are incredibly useful paired with David’s script:
Keyframes to Markers:
http://www.redefinery.com/ae/view.php?item=rd_KeyMarkers
Copy markers:
http://www.redefinery.com/ae/view.php?item=rd_CopyMarkers