Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Volume relative to distance from camera expression

  • Volume relative to distance from camera expression

    Posted by Jesse Stormer on June 10, 2012 at 9:24 pm

    I have videos passing by my camera with sound on them, and I’d like the audio to get louder/quieter relative to their distance to the camera. I tried modifying an ‘opacity relative to camera distance’ expression to fit audio levels, but to no avail. Can anyone help me out with this one?

    Dan Ebberts replied 13 years, 10 months ago 2 Members · 1 Reply
  • 1 Reply
  • Dan Ebberts

    June 11, 2012 at 4:02 pm

    To get this to work, you need to pick a nominal distance from the camera where the audio will be at normal (0 db) volume. When the layer is twice as far from the camera the audio will be 6 db down, 12 db for 4 times as far, etc. I have it set up for a nominal distance of 500 pixels:

    C = thisComp.layer(“Camera 1”);
    nominal = 500; // distance where sound level normal
    d = length(C.toWorld([0,0,0]),toWorld(anchorPoint));
    offset = -20*Math.log(d/nominal)/Math.LN10;
    value + [offset,offset]

    Dan

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy