Activity › Forums › Adobe After Effects › How to change volume according to brightness ?
-
How to change volume according to brightness ?
Posted by Walk Withme on November 2, 2012 at 12:25 amHey,
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 !
Walter Soyka replied 13 years, 10 months ago 4 Members · 6 Replies -
6 Replies
-
Walter Soyka
November 2, 2012 at 1:24 amAre 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 -
Erik Waluska
November 2, 2012 at 2:24 amHey Walter, That’s a really interesting expression with some great possibilities. I didn’t know about that one. Thanks for the link.
-
Walter Soyka
November 2, 2012 at 3:26 amI 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 -
Walk Withme
November 2, 2012 at 3:43 amGreat 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 2So how should I do with audio ?
Thanks.
-
Darby Edelen
November 2, 2012 at 5:46 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
-
Walter Soyka
November 2, 2012 at 7:28 pmI 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
Reply to this Discussion! Login or Sign Up