Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Oscillate value with some randomness

  • Oscillate value with some randomness

    Posted by Roger Maus on November 30, 2011 at 10:56 pm

    Hi there!

    What i am trying to achieve is an expression which makes a value oscillate in a given *range* of period between two given *ranges* of values. The result would be a clean wave with altering amplitude and frequency, such as:
    amplitude minimum = 0 to 20
    amplitude maximum = 80 to 20
    frequency = 2 to 3 seconds

    I wasn’t capable of motifying existing expressions (such as Dan’s expressions regarding randomness) successfully. I never achieved a clean wave.

    Any hints?

    Jacob Giacometti replied 9 years, 9 months ago 3 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    November 30, 2011 at 11:59 pm

    I’m not sure if this is what you’re asking for, but this is my best guess:

    seedRandom(index,true);
    ampMin = random(0,20);
    ampMax = random(20,80);
    freq = random(2,3);

    offset = (ampMax + ampMin)/2;
    mult = (ampMax – ampMin)/2;
    mult*Math.sin(freq*time*Math.PI*2) + offset

    Dan

  • Roger Maus

    December 1, 2011 at 12:42 am

    I am sorry that I forgot to mention that I need som ongoing randomness. I’d like the values to change every period.

    I hope this quick sketch makes it clear:

  • Roger Maus

    December 4, 2011 at 3:50 pm

    I still couldn’t find a solution, I still need your help. Could I make myself clear? Could anyone please point the way which I could give a try?

  • Dan Ebberts

    December 5, 2011 at 1:36 am

    This is as close as I could get:


    seedRandom(index,true);

    t = inPoint;
    while (t <= time){
    t0 = t;
    period = random(2,3);
    t += period;
    }
    if (time >= inPoint){
    seedRandom(t0,true);
    amp = random(40,50);
    50 + amp*Math.sin((time - t0)*Math.PI*2/period)
    }else
    value

    Dan

  • Jacob Giacometti

    July 28, 2016 at 1:14 pm

    Thank you Dan, I just found your expression after 20 minutes of google, and used it, it’s exactly what I needed! Nice dude

    BEST EXPRESSION I EVER SEEN IN MY LIFE

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