Creative COW SIGN IN :: SPONSORS :: ADVERTISING :: ABOUT US :: CONTACT US :: FAQ
Creative COW's LinkedIn GroupCreative COW's Facebook PageCreative COW on TwitterCreative COW's Google+ PageCreative COW on YouTube
ADOBE AFTER EFFECTS:HomeForumBasicsExpressionsTutorialsPodcastsAE TechniquesCreative Cloud DebateFAQ

Time Remapping - Unique Random playback

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Share on Facebook
tyler jordanTime Remapping - Unique Random playback
by on May 4, 2012 at 4:32:57 am

Hi there,

I have a comp with time-remapping enabled, and a script to change the way the playhead scrubs, so that it will play one second from a random location in the comp and then move to another random location.

What I would like to do is make it play the random location only once, so that I essentially have a movie clip the same length as the comp, and all of the content from that comp, expcept mixed up into a random order.

Here is the random code I'm currently using as a starting point:
segDur = 1;// duration of each "segment" of random time
minVal = inPoint;
maxVal = outPoint - segDur;

seed = Math.floor(time/segDur);
segStart = seed*segDur;
seedRandom(seed,true);
startVal = random(minVal,maxVal);
endVal = startVal + segDur;
linear(time,segStart,segStart + segDur, startVal, endVal);


In other coding languages i've done similar things using an array and checking the scrubber against the times in the array, but i'm not sure how to do that in expressions, and also i think there is probably a more efficient way to do it.

Any help is greatly appreiated, cheers!
Tyler


Return to posts index
Reply   Like  

Dan EbbertsRe: Time Remapping - Unique Random playback
by on May 4, 2012 at 8:33:51 am

This should let you divide the clip into n equal-length segments and play each segment once, in random order.


n = 10; // divide clip into 10 segments
segDur = (outPoint - inPoint)/n;
segs = [];
for (i = 0; i < n; i++) segs[i] = i;
seedRandom(index,true);
for (i = 0; i < n; i++){
idx = i + Math.floor(random(segs.length - i));
temp = segs[i];
segs[i] = segs[idx];
segs[idx] = temp;
}
curSeg = Math.max(Math.min(Math.floor((time - inPoint)/segDur),n-1),0);
t = (time - inPoint)%segDur;
segs[curSeg]*segDur + t



Dan



Return to posts index
Reply   Like  

tyler jordanRe: Time Remapping - Unique Random playback
by on May 6, 2012 at 7:48:01 pm

Thanks Dan, that worked perfectly.

You probably recognised the original code, it's from your motionscript site - lots of great resources on that site!

Cheers,
Tyler


Return to posts index
Reply   Like  

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Share on Facebook


FORUMSTUTORIALSFEATURESVIDEOSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

Creative COW LinkedIn Group Creative COW Facebook Page Creative COW on Twitter
© 2014 CreativeCOW.net All rights are reserved. - Privacy Policy

[Top]