ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

How to change volume according to brightness ?

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Walk withme
How to change volume according to brightness ?
on Nov 2, 2012 at 12:25:45 am

Hey,

Is there anyway to make audio track volume go louder or more quiet according (syncing) to the brightness of video track ?

I have a torch approaching the camera on an unsteady speed, and I'd like a sine wave audio relate to that: when the torch goes back, the sound gets quiet, and when the torch comes closer, the sound gets louder.

Thanks !


Return to posts index


Walter Soyka
Re: How to change volume according to brightness ?
on Nov 2, 2012 at 1:24:05 am

Are you familiar with expressions? You could use sampleImage() to drive the Audio Levels property.

See Dan Ebberts's Obscuration example [link] for some inspiration.

Walter Soyka
Principal & Designer at Keen Live
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
RenderBreak Blog - What I'm thinking when my workstation's thinking
Creative Cow Forum Host: Live & Stage Events


Return to posts index

Erik Waluska
Re: How to change volume according to brightness ?
on Nov 2, 2012 at 2:24:57 am

Hey Walter, That's a really interesting expression with some great possibilities. I didn't know about that one. Thanks for the link.


Return to posts index


Walter Soyka
Re: How to change volume according to brightness ?
on Nov 2, 2012 at 3:26:11 am

I use sampleImage() quite a bit. It's very powerful, but also slow to evaluate, so I only recommend it in cases like this where more traditional procedural animation/compositing methods don't apply.

Walter Soyka
Principal & Designer at Keen Live
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
RenderBreak Blog - What I'm thinking when my workstation's thinking
Creative Cow Forum Host: Live & Stage Events


Return to posts index

Walk withme
Re: How to change volume according to brightness ?
on Nov 2, 2012 at 3:43:12 am

Great info, thanks !

I did the lens flare tryout and got it working nicely, used this:

target = thisComp.layer("alphalayer");
alpha = target.sampleImage(effect("Lens Flare")("Flare Center"),[3.5, 3.5])[3];
linear(alpha, 0, 0.36, 80, 0)

BUT now I'm doing it to audio track using this:

target = thisComp.layer("alphalayer");
alpha = target.sampleImage(effect("Stereo Mixer")("Left Level"),[3.5, 3.5])[3];
linear(alpha, 0, 0.36, 100, 0)

And it says:

Bad argument: argument 1 to sampleImage() must be 2 numbers
Error occured at line 2

So how should I do with audio ?

Thanks.


Return to posts index


Darby Edelen
Re: How to change volume according to brightness ?
on Nov 2, 2012 at 5:46:42 am

[Walk withme] "target = thisComp.layer("alphalayer");
alpha = target.sampleImage(effect("Stereo Mixer")("Left Level"),[3.5, 3.5])[3];
linear(alpha, 0, 0.36, 100, 0)"


The first argument to sampleImage() should be the position you want to sample on your "target" layer. Also in your case you won't want just the alpha value but instead the brightness or lightness value, this can be determined this way:

lightness = rgbToHsl(target.sampleImage([x,y], [3.5,3.5]))[3];

Where [x,y] is the location in the target layer you want to sample to determine the lightness.

In your case you might be more interested in the average brightness of the video rather than the brightness at a specific point.

If that's the case then you can apply the Blur & Sharpen > Fast Blur effect to a copy of your torch layer with Repeat Edge Pixels enabled and a very large Blurriness value (5000 is a good starting place). Then you'll need to point sampleImage() at this copy.

You can then sample the center of the layer since the layer will be mostly the same color. Instead of [x,y] above you can use [target.width/2, target.height/2] which will give you the center of the layer. You can also probably reduce the sample size (the part that reads [3.5,3.5] in the above code) to save some on the sampleImage() processing, try [1,1] instead.

Also, you're definitely going to want to change the linear() code since that was defined for a specific range of input values as well as for an opacity output. Something like this will probably be better for you:

linear(lightness, 0, 1, [-48,-48], [0,0]);

The above would change your audio's levels from -48dB when the layer is pure black to 0dB when the layer is white. In all likelihood your layer will be ranging in grays for the most part so you may want to tweak the 0 and 1 values in the above. If you enter a value higher than 0 in the 2nd parameter then it's more likely that your torch audio will be cut almost completely off (-48dB, very soft) if you lower the third parameter from 1 then you're making it more likely that your torch audio will play at 0dB (louder).

Lastly, your expression will of course be applied to the audio layer's audio levels property.

Darby Edelen


Return to posts index


Walter Soyka
Re: How to change volume according to brightness ?
on Nov 2, 2012 at 7:28:21 pm

I was remiss in not pointing to the great grand-daddy of all AE automated mixing expressions: Filip Vandueren's Doppler test [link].

He places a couple "mics" in 3D space; audio output is automatically panned according to a layer's proximity to the mics. Doppler effect (via time-remapping) is also included.

With this ingenious setup, you can correctly and automatically position sound effects in 3D aural space according to their positions in Ae's 3D visual space.

Walter Soyka
Principal & Designer at Keen Live
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
RenderBreak Blog - What I'm thinking when my workstation's thinking
Creative Cow Forum Host: Live & Stage Events


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]