[PD] To divide a number in random parts

Matt Barber brbrofsvl at gmail.com
Sat Mar 5 02:09:56 CET 2011

Sorry for the lack of comments. It's kind of a brute-force method;
maybe I'll go through and document it at some point, but I just threw
it together today to show the concept. A couple of things: if your max
and min durations are restrictive you get an awful lot of values at
the max and min (whereas you might want to randomize the corrected
outliers within a certain range so that you get values that hover a
certain random amount above the min or below the max).

Also, the total number of beats should be quantized to the nearest
subdivision but I didn't worry about that. I guess it's the user's

Not sure about the go button, seems to work here. At some point you
might wish to add a seed for the random if you don't want things to
repeat from the last time you opened the patch.


On Fri, Mar 4, 2011 at 6:57 PM, Caio Barros <caio.barros at gmail.com> wrote:
> Whoa! Nice! It worked very well here.
> Although sometimes I have to press the "Go" button more than once to get
> different results, even when I change the paramethers.
> Will do some more testing.
> I need some time to understand this patch but it looks awesome.
> 2011/3/4 Matt Barber <brbrofsvl at gmail.com>
>> I attached an example that will do something like what you want, using
>> list abs.
>> Without much trouble you could make this into an abstraction.
>> It follows the first solution someone posted -- pick a bunch of random
>> numbers and then scale them so the total equals the target. I added a
>> few things, though -- it also rounds the numbers to the nearest
>> subdivision that you specify, and it goes through the list and moves
>> anything lower than the min or higher than the max duration to the min
>> or max, compensating elsewhere, until all the durations are in range.
>> I capped the number of searches for outliers to 1000, but you could
>> change that or get rid of it as need be.
>> I haven't tested this thoroughly, so let me know.
>> MB
>> >> Note that if you sum 1+2+3+4+5+6+7+8+9+10, that's already 55. How many
>> >> time
>> >> units do you have per 48 seconds ? (do you have a base tempo at all ?)
>> >>
>> >> And then what do you want the distribution to be like ? Is there any
>> >> maximum duration of a chord, minimum duration of a chord, etc ?
>> >>
>> >>
>> > It's funny that you said that. I slept over this problem and yes, I want
>> > the
>> > chords to have a minimun and maximun duration. They don't need to bee
>> > all of
>> > different durations, the important is this section of the piece to sound
>> > like random/chaotic durations, and as we know random numbers (or
>> > durations?)
>> > sometimes don't look random. I will even make this again for the attacks
>> > of
>> > individual notes of the chords so the section will have a truly chaotic
>> > feeling.
>> > And by the way the tempo of this section is quarter = 60 so it's very
>> > easy
>> > to do this. (thank you Mathieu for making me think about it more deeply)
>> >
>> > Thank you guys for the other answers. This really helps.
>> >
>> > Caio Barros

More information about the Pd-list mailing list