Tutorial: Animate your spectrogram!

May 19, 2014 — 1 Comment

A couple of people have expressed interest, so here are a little tutorial describing how I created the spectrogram animation that you can find here: http://www.michw.com/2014/02/spectrogram-animation/

You should know a few things:

1) I’m not an AE expert, you guys!

2) There are a lot of ways to accomplish what I’m about to explain; this is just one way, and it may not even be the best way.

3) If anything isn’t clear, then please let me know so I can try to fix it!

4) Many thanks to Christian Petropolis, who showed me how to do this in the first place!

What you’ll need

First, let’s start with ingredients, the things you’re going to need right from the get-go to be able to start this tutorial:

- A spectrogram! Here’s mine. Nothing special – just a standard Matlab-generated spectrogram in png format. Probably a jpeg or tif or even a Photoshop file would be just fine as well. Any image that you can import to After Effects.
FinCalls-and-earthquake-NC89

- Your audio file! Again, mine has is just a wav file generated by Matlab. Make sure it’s the audio that matches your spectrogram!

- Adobe After Effects (sorry – I know it’s expensive – I managed to get a good deal on it the Adobe Creative Cloud through my University bookstore, if you’re a student or teacher you can probably find a way to get it relatively inexpensively)

Let’s get down to business

1) Open After Effects! Select File -> New -> New Project.

2) Select File -> Import -> File…

Then select the both the spectrogram image file and the accompanying audio file

3) Select both files from the Project tab and drag them onto the “Composition” icon:

startComposition

 

4) A window will open; select “Single Composition”, and set the duration at approximately the length of your audio file (don’t worry, you can change this later if it’s not right)

newComp

 

5) In the Composition tab, right-click and rename the layers if you like:

layernames

 

6) Select the image layer (in my case, it’s called “Spectro”). Use Shortcut keys (cmd-C/ctrl-C and cmd-V/ctrl-V) or the Edit pull-down menu to make two duplicates.

7) Rename the two new layers to “GlowLayer” and “DarkLayer” (or whatever you like, that’s what I’m going to call them). Make sure “GlowLayer” is on top.

newlayers

8) Click on the “GlowLayer” to make it active, select the “rectangle tool” icon, then draw a thin rectangle on the spectrogram. This will be the glowing bar that slides across as you play the sound.

threesteps

 

9) With the “GlowLayer” still selected, Click the pulldown menu Effect -> Stylize -> Glow. The Glow effect controls should pop up in their own tab. Here’s how I set it up, but do whatever works for your image. The only things I changed were Glow Threshold (22%) and Glow Intensity (1.8).

GlowSettings

10) Select Layer (pulldown) -> New -> Shape Layer, and drag that new layer to just below “DarkLayer”. I renamed my new Shape layer “darkRectangle”.

darkRectangle

11) With “darkRectangle” layer selected, click the “Rectangle tool” button. Draw a Rectangle on your spectrogram like this (see image). Click the “Fill Options” and choose “solid color” and ~60% opacity, then click  “Fill color”, and choose a medium gray.

RectProperties

12) Select “DarkLayer”, choose the “Rectangle tool”, and draw another rectangle the same way as in step 11. The difference is that this time, because of the layer type, it’s going to make a mask, not a rectangle.

13) Click the check box to “Invert mask”. You should see the dark colored rectangle show through at this point.

DarkMask

14) Now for the fun part. Make sure the “scrubber” is at time = zero. The scrubber is the little yellow triangle on the timeline that lets you move forward and backward in time.

15) Click the triangle icon beside the Mask layer under “DarkLayer” to see more options.

16) Click the little clock icon beside “Mask Path”, and you should see your first “keyframe” show up (yellow diamond). If you’re unfamiliar with After Effects, you should know that it’s *all about keyframes*. Seriously.

firstkeyframe

 

17)  Drag your keyframe scrubber to the end of your audio segment.  The audio segment is shown by a green bar on my timeline.

18) Click on the mask layer to activate it, if it’s not already active (my mask layer is called “Mask 1″ in the image above). Click the right arrow on your keyboard until the left side of the mask rectangle is lined up with the right edge of the spectrogram image. (hint: use shift+arrow to move in larger increments). Now if you move your scrubber back and forth you should see the “shadow” move across your spectrogram.

MoveMask

19) Now we’re going to animate our “GlowLayer” in much the same way. Select the GlowLayer, and again open up “Mask 1″ options.

20) Move the scrubber to zero time again. Add a Mask Path keyframe.

21) Move the scrubber to the end of the audio segment.

22) Make sure “Mask 1″ under the “GlowLayer” is selected, and move the glow bar over using the right arrow key. Stop when the right side of the rectangle mask is lined up with the right edge of the spectrogram.

23) Congratulations! You’ve animated your spectrogram. Now if you’d like to preview it, you can use the RAM preview. Just hit the little triangle on the far right of the preview panel, and there you go. It’ll run through it quickly once to render the video and audio, then you can behold your masterpiece. A little warning: if you’re computer is a bit slow, this preview can be jumpy. But once you export it, it should be just fine.

RamPreview

24) Exporting! File -> Export -> add to Render queue. Choose render settings and output location and click “Render” button. (Defaults are probably a decent place to start if you’re not sure).

One response to Tutorial: Animate your spectrogram!

  1. Christian Petropolis May 19, 2014 at 9:34 pm

    Great work sharing the knowledge!

Leave a Reply

*

Text formatting is available via select HTML. <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>