Random selection of time values that always equal x bars

mooter's icon

Does anyone have any idea or know any abstractions that will choose a selection of time values that will always add up to 2 bars? I thought I came close by adding different tick values between 32nd to whole notes, but it's rarely exact most of the time; a crap shoot.

To simplify the idea, let's say you can randomly choose between 1/16th,1/8th, and 1/4th notes, but they have to add up exactly to 2 bars every time.
I'd like to go through a 2 bar sequence and randomize the speed of the playhead.

Max Patch
Copy patch and select New From Clipboard in Max.

double_UG's icon

Max Patch
Copy patch and select New From Clipboard in Max.

mooter's icon

!
Thanks!
Never would've thought of thresh. I'm in a bit of a burn-out period so even though all the ways the cat can be skinned my mind is in a small box and I've never used thresh anyway. Excellent!
So it turns out the remainder is not always a timevalue but alas! I have a workaround:

Max Patch
Copy patch and select New From Clipboard in Max.

when the remainder goes in to translate ticks to timevalues, if it isn't a time value it gives a 0.

Can I send you some beer or something? I really appreciate it.

double_UG's icon

you are welcome,
https://www.youtube.com/watch?v=8b9PH55EtJI&list=RD8b9PH55EtJI&spfreload=10#t=13
Prost