Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Using soundkeys to control 2 different comps….

  • Claudio Dolce

    January 24, 2012 at 5:59 pm

    Hi, I have read the topic (when there is Dan everything it is very interesting) and…

    Aza Allen say: …and if I do that, it counts up 1 for every frame the beat is present inside the box (instead of 1 for every beat, and the beat lasts 3-5 frames)

    Is there a way to get it to just use one frame while the beat is present and reject the rest, so that every time the beat hits it only counts one frame?

    Dan Ebberts replay: Try changing your Sound Keys settings back to the default: Type = Average of Range, Falloff = Instant, Output Min/Max = 0..100. Then just change the second line of my expression to point audioLev at Sound Keys Output 1. The expression should count the beats.

    Ok, i followed the indications of Dan, and it works beautifully (I didn’t have doubts, you are a legend).
    Your expressions are universal! They are easily adaptable! They are also very complex: Or) for this I ask a small help… “upgrade”

    However some beats are very near (or “incorrectly” calculated) and I would be curious if a method exists for ignoring or to modify or to eliminate the followings 3-5 kayframeses… I have also tried to modify the value of the threshold. (in vain) From little I have begun to study this world, and if it is possible to add two lines to your stupendous expression I would be happy of it. It would be interesting to add a variable for the numbers of keyframes that he intends to jump, so that can be varied to liking (if it is possible, I already know that she would do so :O))

    Thanks in advance and sorry for my bad school-english 🙂
    Clakky.

  • Dan Ebberts

    January 24, 2012 at 10:19 pm

    Here’s a version of the beat-counting expression that will let you define how many frames to skip when a beat is detected. I haven’t given it a thorough testing, but it seems to work:


    threshold = 10.0;
    skipFrames = 5;

    audioLev = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider");
    below = true;
    frame = timeToFrames(inPoint);
    n = 0;
    while (frame <= timeToFrames(time)){
    t = framesToTime(frame);
    if (below){
    if (audioLev.valueAtTime(t) >= threshold){
    below = false;
    n++;
    frame += Math.max(0,skipFrames-1);
    }
    }else if (audioLev.valueAtTime(t) < threshold){
    below = true;
    }
    frame++
    }

    n

    This version starts at the in point and moves forward in time.

    Dan

  • Claudio Dolce

    January 25, 2012 at 4:10 pm

    You are too much kind! It works that it is a wonder.
    Not only it is the best but also fast.
    Thanks thanks thanks.

    PS I don’t know why, but this version seems me realized with an inverse reasoning 😀
    I thought they were only two lines … Instead he had to rewrite almost everything. Thank you so much!
    Claudio.

  • Anthony Jestin

    January 30, 2013 at 3:14 am

    Hi Dan, thanks for all the posts you have made on here, they have been very helpful to me. My situation is this:

    I have used your beat counting code as above, and am using with a pre comp of a series of images all set to be 1 frame long and sequenced back to back. When i use your expression, it increments the seconds and not the frames in my time remap, so it skips most of my images. Any thoughts?

    Thanks in advance.

  • Dan Ebberts

    January 30, 2013 at 3:50 am

    I think all you have to do is change the last line to this:

    framesToTime(n)

    Dan

  • Anthony Jestin

    January 30, 2013 at 4:16 am

    I’ll try that and let you know, thanks 🙂

  • Anthony Jestin

    January 30, 2013 at 7:45 pm

    Hi Dan, that worked like a charm. Thanks so much for the help.

Page 2 of 2

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