picture home | art | events | music | rack extensions | downloads | pixel blog

omino pixel blog

pixels, motion, and scripting
david van brink // Wed 2011.12.28 19:16 // {after effects}

AE: Omino Python, All Free

The Mac OS X version of Omino Python has been updated. An installer for it — and all my other After Effects plug-ins are in the downloads section here.

For anyone just tuning in, Omino Python is an After Effects plug-in that lets you write scripts to draw into a layer of an After Effects composition. It’s a lot like writing BASIC on your old Apple ][.

Changes to the plug-in are primarily:

  • Fixed a sporadic crash that could happen during text rendering.
  • No longer install any files in /opt/local or /usr/local. All gone.
  • Completely unlocked (no license needed for full use). Enjoy!

Here’s a frame from one of the example animations. This is a couple of for-loops in action.

And here’s the animation it came from.

And here’s the python source code.

5 comments
ChrisG // Sun 2012.01.29 19:327:32 pm

Hi. Been a long time since I started messing around with this plugin (and then left it alone because I had other things to deal with). Well, now I’m back on it. And I have found some really interesting things. However, I’m wondering if you are ever going to be able to add the feature of getting something OUT of the plugin — a property that can be used in an expression but goes in the opposite direction of what exists now. In other words, something that changes by the py script, but is updated by the script as a property (as opposed to the other way around, which is how all the props work now). Is this possible? Just putting one “out” integer property would be AWESOME. Thanks in advance for any response (and thanks again for the cool plugin).

david van brink // Sun 2012.01.29 20:018:01 pm

Hi Chris —
There is a way! It’s a bit strange but will work. Render out a square of some color made of values R, G, B, say at (0,0,10,10). Then in an expression, use layer.sampleImage, to read it back. Something like sampleImage([5,5], radius = [.5, .5], postEffect=true, t=time).

You can use as many color-regions as desired to pass more value triplets out. (And probably want to clip your work so these “utility areas” aren’t on the final tape…)

ChrisG // Sun 2012.01.29 20:068:06 pm

Haha. I’ve already done that. I’d like less of a kludge.

ChrisG // Sun 2012.01.29 20:158:15 pm

Sorry. Should’ve made mention of that in my original comment. But is it possible to add that to the plugin?

ChrisG // Sun 2012.01.29 20:168:16 pm

Oh, and while I’m here … what is the correct syntax to set_hint_metrics?

oh, i dont know. what do you think?


david van brink // Mon 2011.12.26 13:56 // {after effects}

AE: Hello again, & MIDI

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.

Om midi panel

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.
11 comments
Mylenium's Blog » Saved! // Sat 2011.12.31 03:203:20 am

[…] 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 […]

hyp // Sun 2012.01.1 17:535:53 pm

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.

nathan // Tue 2012.01.3 15:133:13 pm

this is the coolest thing ever

arto // Wed 2012.01.4 14:352:35 pm

^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.. 🙂

david van brink // Sat 2012.01.7 13:501:50 pm

^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…

lotzio // Tue 2012.01.10 18:366:36 pm

GREAT STUFF MAN!!! THX FOR SHARING, IT’LL BE SUPER USEFUL FOR SOME OF MY PROPOSALS. REALLY APPRECIATE.

音のデータとAfter Effects その2 | AEP Project // Sat 2012.01.14 08:018:01 am

[…] 楽譜のデータから作る さて、少しだけ変わった方向から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を使用しています。 […]

cheerbot // Mon 2012.01.16 17:035:03 pm

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.

StoryBoy // Tue 2012.01.24 15:353:35 pm

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!

david van brink // Tue 2012.01.24 16:544:54 pm

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!

cheerbot // Tue 2012.01.24 22:4610:46 pm

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

oh, i dont know. what do you think?


david van brink // Wed 2011.02.16 09:19 // {after effects}

AE & Python

I was going to provide another example or two of Python scripting, today, but was sidetracked by a little bit of historical research on Python in After Effects. The examples will wait a little longer…

Useful Things

Yes, indeed, everything old is new again. Just about the time I started using After Effects, I had heard of “Useful Things”, but didn’t really know what it was. Turns out it was… Python Scripting for After Effects! It appears to have been quite well-regarded in the AE community, too. Alas, for whatever reasons, that product seems to have faded, been reabsorbed in the various business permutations that are a fact of life.

Omino Python for After Effects, by coincidence and parallel evolution, seems to resemble that fine product in some aspiring ways.

Grant Munsey

Going back even a tiny bit further, to 2001, we find that Adobe computer scientist Grant Munsey created open source Python bindings for Photoshop and After Effects, as well!

Reading about him, he was a great proponent of open source development, and was a driving force for establishing http://opensource.adobe.com/.

He passed away in 2005; I did not know him. But reading about his long illness, I was touched by this part of his wife’s account:

We’ve been using the mouth stick. It’s a 16-inch rod with a rubber tip on one end and on the other end a U-shaped plastic thing he bites on. He can then trace patterns and point to letters on the letter board — very slowly. I asked him what UNIX command you’d use for getting regular expressions from a text file, and he spelled “GREP”.

And forgive me if I find in this a dark justification for the oft-maligned brevity of UNIX commands.

1 comments
Rich Young // Sun 2011.02.27 17:395:39 pm

I think Grant also did an early plug-in set, Cognicon TILT. Later sold to Digieffects, TILT was an 3D system that did 3D displacement and imported 3D models using Quickdraw 3D from Apple.

oh, i dont know. what do you think?


david van brink // Sun 2011.02.6 09:22 // {after effects}

AE: Omino Python

For immediate download: Omino Python Plug-in for After Effects.

This plug-in lets you write a script in Python and then run it on every frame. The script can do drawing, access other layers, and so forth. Because sometimes, you just need to write code to get the job done. Omino Python gives you a straightforward way to provide drawing code directly in your After Effects work flow.

This isn’t for everyone; but if you have a little bit of scripting experience, Omino Python should be very easy for you to pick up.

Mac OS X on AECS5 only, for now…

Here’s a little demo.

Here’s another youtube demo, too.

The download includes plenty of documentation, or you can read it right now.

I’ll be posting some tips and examples — there are so many possibilities opened up! — but to break the ice, here’s a simple Omino Python script to do some drawing.

The script in Python. I didn’t know Python before starting the project, but it’s a nice easy little language, and quite popular, so there’s plenty of resources to learn it. It’s not so different from JavaScript or anything else. No semicolons and no curly braces, though! Here it is:

import math
import random

def ompy_main(c):
    ctx = c.layer_out_context

    w = int(c.width)
    h = int(c.height)

    # draw a red circle...
    ctx.set_source_rgb(1,0,0)
    ctx.arc(w/2,h/2,100,0,2 * math.pi)
    ctx.fill()

    # effect parameter controls size
    size = c.floats[0]
    ctx.set_font_size(size)

    # draw a grid of random numbers, spaced by 30
    random.seed(c.frame) # start the random sequence
    for x in range(0,w,30):
        for y in range(0,h,30):
            # random color
            ctx.set_source_rgb(random.random(),random.random(),random.random())
            # random number
            n = str(random.randint(0,9))
            # draw it.
            ctx.move_to(x,y)
            ctx.show_text(n)

And here’s a screen shot showing the output:

Op scrnshot 6

Your script can access a collection of parameters — some floats, some colors, &c — and use them as needed. In this case, I just used one float parameter to control the size of the random numbers printed.

This is just the beginning! Read the doc for the full story. Try out the plug-in.

More to come!

8 comments
GCoda // Mon 2011.02.14 02:582:58 am

This is great.
How about integrate this with http://code.google.com/p/pybox2d. Is it theoretically posible ?

Tutorialz | Copy. Share. Enjoy. » Omino Python: Python Plug-in for After effects // Mon 2011.02.14 05:495:49 am

[…] Van Brink (@polyomino) released Omino Python, a free After Effects CS5 plug-in for Mac OS X only (for now) that embeds a Python interpreter: […]

Jonas Hummelstrand // Tue 2011.02.15 03:593:59 am

Way cool, David!

Tweets that mention David Van Brink brings Python back to AE. Awesome! Useful Things was a favorite. -- Topsy.com // Tue 2011.02.15 04:314:31 am

[…] This post was mentioned on Twitter by Jonas Hummelstrand and kripats, Dale Bradshaw. Dale Bradshaw said: David Van Brink brings Python back to AE. Awesome! Useful Things was a favorite. http://t.co/Gui2CLA […]

Omino Python: Python Plug-in for After Effects | Wizpress.com // Tue 2011.02.15 09:359:35 am

[…] Van Brink (@polyomino) released Omino Python, a free After Effects CS5 plug-in for Mac OS X only (for now) that embeds a Python interpreter: […]

Mylenium’s Blog » The Snake comes back! // Tue 2011.02.15 11:4511:45 am

[…] How do you know that you are "old" in the After Effects world? When you can remember pretty much every cool plug-in that there once was and whose demise you regret. One of those was Useful Things, a custom framework for building your own effects using Python. I’ve long been a sucker for parametrical/ generative graphics – anything from L-Systems to statistical visualization – and have long wished we could have something like Processing would make its way to After Effects to fill that gap, but it hasn’t happened. Luckily, things are beginning to look a bit better, as we are getting a new Python plug-in thanks to David van Brink. […]

Michael Delaney // Thu 2011.06.2 22:4510:45 pm

Wanting to try out the plugin. Its throwing this though.

“Could’nt find main entry point for omino_python.plugin

48 :: 72”

I’m on OSX 10.6 with AE 10.0.0.458

david van brink // Wed 2011.12.28 19:467:46 pm

A little bit late, I reply: Try the newest version, fresh today. I rejiggered the installer significantly, hopefully addressing exactly this kind of problem. But please ping me here or poly@omino.com, I want to help!

oh, i dont know. what do you think?



Deprecated: Function the_block_template_skip_link is deprecated since version 6.4.0! Use wp_enqueue_block_template_skip_link() instead. in /home/polyomino/omino.com/pixelblog/wp-includes/functions.php on line 6121

0.0500s
(c) 2003-2023 omino.com / contact poly@omino.com