ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Random Seed with varying "Hold Time"

FAQ   •   VIEW ALL
 Random Seed with varying "Hold Time" on Mar 22, 2018 at 6:35:53 pm

Hey guys, could somebody help me with this?

Basically, I have these inputs:

maxHoldTime = 1.0 [sec];
randomness = 0.5 [0 - 1.0];

minHoldTime = (1 - randomness)*maxHoldTime;

and I need to change a Random Seed value every 'minHoldTime' to 'maxHoldTime' seconds.
Ideally in increments of 1 so the pattern doesn't repeat. Any ideas?

I would be grateful for anything, so thanks in advance,

 Re: Random Seed with varying "Hold Time"on Mar 22, 2018 at 7:21:21 pm

Play around with this and see if it helps:

``` maxHoldTime = 1; minHoldTime = .5; seedRandom(index,true); totalTime = 0; while(totalTime <= time){ holdTime = random(minHoldTime,maxHoldTime); totalTime += holdTime; } holdTime ```

Dan

 Re: Random Seed with varying "Hold Time"on Mar 22, 2018 at 7:56:57 pm

I'm not sure, I tried adding this:

seed = Math.floor(time/holdTime);
seedRandom(seed, true)

but I'm probably doing something wrong...

 Re: Random Seed with varying "Hold Time"on Mar 22, 2018 at 7:59:07 pm

Depending on what you're planning on doing next, you could just change the last line of my expression to:

seedRandom(holdTime,true);

Dan

 Re: Random Seed with varying "Hold Time"on Mar 22, 2018 at 8:10:18 pm

I've got some effect with Random Seed and I want the seed to increment by 1 in the random holdTime intervals. I've got no idea how to do that. Also sorry for my English, it's not my mother tongue.

 Re: Random Seed with varying "Hold Time"on Mar 22, 2018 at 8:41:07 pm

Try it this way then:

``` maxHoldTime = 1; minHoldTime = .5; seedRandom(index,true); totalTime = 0; seed = 1; while(totalTime <= time){ holdTime = random(minHoldTime,maxHoldTime); totalTime += holdTime; seed++; } seed; ```

Dan

 Re: Random Seed with varying "Hold Time"on Mar 22, 2018 at 8:50:11 pm

Brilliant, it works exactly how I imagined. You're just awesome!

Thanks,

 Re: Random Seed with varying "Hold Time"on May 18, 2019 at 3:02:16 pm

Thank you for this expression, Dan. I wonder if you might help me take it a step further. I've been struggling to get it to work for my purposes because I'm using the result to seed a random point in time. The problem is since Time is a continually increasing value, my random point in time is continually changing - even though the seed is not changing (at least not until the HoldTime renews).
As you can see, I added a couple lines to the code. I have a Point Control that is moving/changing value. I need to retrieve random positions along the path that the Point Control has traveled, and I need those positions to remain still for the duration of the HoldTime. With this expression, I can get random positions along the path of the Point Control, but those positions won't stay still - they keep traveling forward along the path. Any ideas? Thanks so much for your time.

``` maxHoldTime = 1; minHoldTime = .5; seedRandom(index,true); totalTime = 0; seed = 1; while(totalTime <= time){ holdTime = random(minHoldTime,maxHoldTime); totalTime += holdTime; seed++; } seedRandom(seed,true); t = random(time); effect("targetPosition")("Point").valueAtTime(t); ```

After Effects Templates - digital glitch effects, 80s VHS effects, old film effects, art effects, and more: http://CreationEffects.com

 Re: Random Seed with varying "Hold Time"on May 18, 2019 at 6:11:23 pm

I'm not sure if this is what you're after, but how about:

t = random(totalTime);

Dan