Copy link to clipboard
Copied
I know we usually use posterizeTime() to control the time duration between new value when using random(). But I want to generate a new value every 10 seconds? So, what number do I put inside the posterizeTime() to make the expression generate new value evey 10 seconds?
Looking forward to hearing from.
Thanks
You don't posterize time, you re-seed the randomness every few seconds:
seedRandom(Math.floor(time/10),true)
random(valueA,valueB)
Mylenium
Copy link to clipboard
Copied
You don't posterize time, you re-seed the randomness every few seconds:
seedRandom(Math.floor(time/10),true)
random(valueA,valueB)
Mylenium
Copy link to clipboard
Copied
Thank you so much! You're a genius
Copy link to clipboard
Copied
I hope you are trying to create a MOGRT or are planning to render a movie only with a changing number and an alpha channel that you can drop in an NLE as an overlay. Ten seconds between frames is going to make an awfully long Comp. I hope it's not complicated.
Try this: Create a new comp that is as long as you need it to be and set the frame rate you one of the standard frame rates for video. Add a new text layer and add this expression to the Source Text property.
Math.round(random(0, 9));
The expression will generate a random number between 0 and 9 for every frame. If you need more than one digit, create a new text layer for each digit and arrange them to line them up properly. A monospaced font will work best.
Pre-compose the text layer or layers, moving all attributes to the new comp. Open the new comp, open the Pre-comp's composition settings, change the frame rate to 1 fps, and then go to the advanced tab and select Preserve Frame rate when nested.
Go back to the main comp and check the numbers. They will now change every second.
Now go to the first frame and select Layer/Time/Freeze frame to turn on Time Remapping. Press U to reveal the single Time Remapping keyframe. Now move to the end of the composition and do a little math. If your comp is 5 minutes long, there are 300 seconds. If you want the time between number changes to be 10 seconds, set a new keyframe at the end of the timeline, double click it, and enter 30.
Because you have preserved the frame rate when nested, you will now have a number that changes every 10 seconds.
You could do it all with an expression, but the expression would have to make a calculation every frame, and it would slow down. The longer the comp is, the longer it takes to calculate the next frame. Time Remapping and Preserve Frame Rate will render faster and easier to control. All it takes is simple division.
I uploaded a comp.
Copy link to clipboard
Copied
Thank you so much
Copy link to clipboard
Copied
When I woke up this morning, I figured out an easier workflow. Instead of manually setting the pre-comp frame rate to 1, Preserving Frame Rate when nested, and manually doing the calculations for the second Time Remapping keyframe, all you have to do is pre-compose the text or text layers, add Time Remapping and add this expression to Time Remapping.
Math.Floor(time / 10); // for one Frame every 10 seconds
// or
Math.Floow(time / 2.5; // for one frame every two and a half seconds
Check out the position expression for the text layers in the nested comp.