Hey guys, long time since I posted here. I've been trying to think a way to divide a number into random parts. Let me explain myself better: I'm writing a piece where I want 10 chords played during 48 seconds but the duration of each chord should be different. So I'm trying to figure out a way to divide 48 into 10 unequal parts, I think using random numbers should be the best way but the difficulty is to get 10 random numbers wich summed give 48. Since I'm not expert at math maybe someone can help me. I want to do this operation with other numbers, therefore a pd patch would be great.
On Wed, 2 Mar 2011, Caio Barros wrote:
I'm writing a piece where I want 10 chords played during 48 seconds but the duration of each chord should be different. So I'm trying to figure out a way to divide 48 into 10 unequal parts, I think using random numbers should be the best way but the difficulty is to get 10 random numbers wich summed give 48. Since I'm not expert at math maybe someone can help me. I want to do this operation with other numbers, therefore a pd patch would be great.
Should those numbers be _all_ different ?
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 ?
| Mathieu Bouchard ---- tél: +1.514.383.3801 ---- Villeray, Montréal, QC
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
On Thu, 3 Mar 2011, Caio Barros wrote:
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.
Ok. Give every chord the minimum duration, then pick random amounts of extra time to add to each, between zero and the difference between the minimum and the maximum.
If you use Tim's solution, the minimum and maximum will be scaled randomly because the sum of all random numbers is itself a random number.
Thus you if you reserve minimum time separately and use Tim's solution on the time that hasn't been allocated yet, the minimum will be exactly respected, whereas the maximum won't.
Now, to make the maximum respected, it has to be another solution than that, and to control the likelihood of getting something close to a maximum duration, it's also something else (if you have several delays close to the maximum before scaling, they won't be close to the maximum after the scaling, if it's a downwards scaling).
The problem of having three delays from 0 to M so that the sum is equal to M is the problem of picking a random place in a right triangle. If the sum has to be N (another number bigger than M), then it's a bigger right triangle with cut corners.
When you have four delays, it's about picking a random place in a triangular pyramid.
When you have more delays, you'd need a space with more than three dimensions to think about it.
| Mathieu Bouchard ---- tél: +1.514.383.3801 ---- Villeray, Montréal, QC
2011/3/3 Caio Barros caio.barros@gmail.com
Hey guys, long time since I posted here. I've been trying to think a way to divide a number into random parts. Let me explain myself better: I'm writing a piece where I want 10 chords played during 48 seconds but the duration of each chord should be different. So I'm trying to figure out a way to divide 48 into 10 unequal parts, I think using random numbers should be the best way but the difficulty is to get 10 random numbers wich summed give 48.
take n random numbers and sum them (n1+n2+n3+...=sum) divide 48 by that sum (48/sum=x) multiply each of your n random numbers by x and sum that to get 48 (n1*x + n2*x + n3*x +...=48) gr, Tim
Since I'm not expert at math maybe someone can help me. I want to do this operation with other numbers, therefore a pd patch would be great.
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
You could try this approach(I also attached a patch with it):
48 = 4 * 10 + 1 * 8
so you use
n1=random(10) n2 = 10 - n1
n3 = random(10) n4 = 10-n3 . . n9 = random(8) n10 = 8 - n9
On 03.03.2011 02:20, Caio Barros wrote:
Hey guys, long time since I posted here. I've been trying to think a way to divide a number into random parts. Let me explain myself better: I'm writing a piece where I want 10 chords played during 48 seconds but the duration of each chord should be different. So I'm trying to figure out a way to divide 48 into 10 unequal parts, I think using random numbers should be the best way but the difficulty is to get 10 random numbers wich summed give 48. Since I'm not expert at math maybe someone can help me. I want to do this operation with other numbers, therefore a pd patch would be great.
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
On Thu, 3 Mar 2011, Markus Demmel wrote:
You could try this approach(I also attached a patch with it): 48 = 4 * 10 + 1 * 8 so you use n1=random(10) n2 = 10 - n1 n3 = random(10) n4 = 10-n3 . . n9 = random(8) n10 = 8 - n9
But this makes the odd-ordered chords to start at every 10 seconds. I believe that Caio wants something more random than that.
BTW I have another idea :
initialise all of them to equal or almost equal amounts, then modify the delays gradully : pick a donor randomly among delays that aren't already minimum ; pick a acceptor randomly among delays that aren't already maximum ; give one unit of delay from the donor to the acceptor.
| Mathieu Bouchard ---- tél: +1.514.383.3801 ---- Villeray, Montréal, QC
You could try this approach(I also attached a patch with it):
48 = 4 * 10 + 1 * 8 so you use n1=random(10) n2 = 10 - n1 n3 = random(10) n4 = 10-n3 . . n9 = random(8) n10 = 8 - n9
But this makes the odd-ordered chords to start at every 10 seconds. I believe that Caio wants something more random than that.
Yes that's right. And another problem is that all the durations are integers. I want something without the feeling of (regular) pulsations.
BTW I have another idea :
initialise all of them to equal or almost equal amounts, then modify the delays gradully : pick a donor randomly among delays that aren't already minimum ; pick a acceptor randomly among delays that aren't already maximum ; give one unit of delay from the donor to the acceptor.
I was trying to figure out something like that. Now that I think about it, is more important to have a minimum duration than a maximum because depending on the minimum I chose, the probability of a chord too long is low (and bottom line I can always change the result to fit in what I want to hear).
I'll need to experiment a bit. If I have the time to make a cool patch with general paramethers I'll share with the list. Unfortunately today I could not compose.
Caio Barros
On Fri, 4 Mar 2011, Caio Barros wrote:
Yes that's right. And another problem is that all the durations are integers. I want something without the feeling of (regular) pulsations.
I thought that you had said that the unit of time is the second. That's how I interpreted "quarter = 60". If you don't want this nor any other related basis such as 120 divisions or 240 divisions, why did you say "quarter = 60" at all ?
| Mathieu Bouchard ---- tél: +1.514.383.3801 ---- Villeray, Montréal, QC
I thought that you had said that the unit of time is the second. That's how I interpreted "quarter = 60". If you don't want this nor any other related basis such as 120 divisions or 240 divisions, why did you say "quarter = 60" at all ?
Yes the tempo is quarter = 60, but this doesn't mean that I want the chords with durations in rounded seconds. What I was thinking is to make a transposition from a duration (say 3,57s) into musical figures, thats why is easy for me to use quarter = 60. Another thing is that the interpreter will have a pulsation basis so (s)he can read the music more easily, but it will not sound like regular pulsations, Sorry if I wasn't clear enough, I think maybe 1/100 of a second is a good time basis, I can and will need to make some approximations of the musical figures, so the interpreter won't have to lose his/her hair studying a 48s section.
Caio Barros
So, then use [randomF], put the values into an list/array and shuffle that. It would still be not fully random, because the numbers won't be bigger than 10, but still it would be quite random :)
On 04.03.2011 04:01, Caio Barros wrote:
You could try this approach(I also attached a patch with it): 48 = 4 * 10 + 1 * 8 so you use n1=random(10) n2 = 10 - n1 n3 = random(10) n4 = 10-n3 . . n9 = random(8) n10 = 8 - n9 But this makes the odd-ordered chords to start at every 10 seconds. I believe that Caio wants something more random than that.
Yes that's right. And another problem is that all the durations are integers. I want something without the feeling of (regular) pulsations.
BTW I have another idea : initialise all of them to equal or almost equal amounts, then modify the delays gradully : pick a donor randomly among delays that aren't already minimum ; pick a acceptor randomly among delays that aren't already maximum ; give one unit of delay from the donor to the acceptor.
I was trying to figure out something like that. Now that I think about it, is more important to have a minimum duration than a maximum because depending on the minimum I chose, the probability of a chord too long is low (and bottom line I can always change the result to fit in what I want to hear).
I'll need to experiment a bit. If I have the time to make a cool patch with general paramethers I'll share with the list. Unfortunately today I could not compose.
Caio Barros
What about this method (actually only works for uneven number of chords, so maybe drop one, or increase to 11 and drop one later( randomly? ))
Just pick a random float between 0 and 48, we'll call that X1 Then pick a random float between 0 and X1 , and between X1 and 48, call those Y1 and Y2 Then do it another 8 times and you have 11 random positions within your range of 0 till 48 ;)
Not sure if it will actually work out, but I just had this brainfart after seeing this thread go on so long :)
-- buZz
On Fri, 4 Mar 2011, Bastiaan van den Berg wrote:
What about this method (actually only works for uneven number of chords, so maybe drop one, or increase to 11 and drop one later( randomly? ))
Just pick a random float between 0 and 48, we'll call that X1 Then pick a random float between 0 and X1 , and between X1 and 48, call those Y1 and Y2 Then do it another 8 times and you have 11 random positions within your range of 0 till 48 ;)
If you make this a uniform random pick, this will make it very likely that half of the chords are very short, and this will introduce intense correlations between chord durations, as the first half of the sequence will have a common random factor in selecting their duration, and in the same manner for all subpacks of chords in there (second half, 1st quarter, 2nd quarter, 3rd quarter, 4th quarter, 1st eighth, ...)
Not sure if it will actually work out, but I just had this brainfart after seeing this thread go on so long :)
The thread could go on much longer. It's a tricky topic, especially after one has found out the additional requirements that were not specified at first (how should the likelihood be spread over the possible outcomes).
| Mathieu Bouchard ---- tél: +1.514.383.3801 ---- Villeray, Montréal, QC
Until now tim's solution seems best for me, I'll try to build the patch these days. You know what would be really nice? If it were possible for the computer to translate the durations into musical rhythms (in lilypond or musicXML for instance). The user input the total duration, the number of divisions, the minimum and maximum duration of each sub-section and maybe a tempo and the computer outputs rhythmic figures. To make things even nicer but a lot harder, the user could for instance choose between different degrees of approximations in the rhythmic output so the result would be easier to read / less precise or harder to read / more precise. Here I go again trying to transform Pd into OpenMusic.
And by the way (a little off-topic now): Mathieu, I recently compilated GridFlow and tried the [note] object you did. Humm! What a nice object. I still would prefer that the output would be the midi note and the slide to go chromatically because at least for me is so much easier for the calculations, but kudos to you.
2011/3/4 Mathieu Bouchard matju@artengine.ca
On Fri, 4 Mar 2011, Bastiaan van den Berg wrote:
What about this method (actually only works for uneven number of chords,
so maybe drop one, or increase to 11 and drop one later( randomly? ))
Just pick a random float between 0 and 48, we'll call that X1 Then pick a random float between 0 and X1 , and between X1 and 48, call those Y1 and Y2 Then do it another 8 times and you have 11 random positions within your range of 0 till 48 ;)
If you make this a uniform random pick, this will make it very likely that half of the chords are very short, and this will introduce intense correlations between chord durations, as the first half of the sequence will have a common random factor in selecting their duration, and in the same manner for all subpacks of chords in there (second half, 1st quarter, 2nd quarter, 3rd quarter, 4th quarter, 1st eighth, ...)
Not sure if it will actually work out, but I just had this brainfart after
seeing this thread go on so long :)
The thread could go on much longer. It's a tricky topic, especially after one has found out the additional requirements that were not specified at first (how should the likelihood be spread over the possible outcomes).
| Mathieu Bouchard ---- tél: +1.514.383.3801 ---- Villeray, Montréal, QC
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
On Fri, 4 Mar 2011, Caio Barros wrote:
Until now tim's solution seems best for me, I'll try to build the patch these days.
I just thought about this, if you want a solution with a minimum, but without a maximum, where all possibilities are EQUALLY LIKELY :
for two chords, pick a number from 0 to 1 with equal probability ; it will be the fraction of the time given to the 1st chord. The 2nd chord takes the rest.
for three chords, pick a number from 0 to 1 with equal probability, then square it. Then for the two remaining chords, use the two-chord method on the rest of the available time.
for four chords, pick a number from 0 to 1 with equal probability, then cube it. Then apply the three-chord method on the rest.
for N chords, pick a number from 0 to 1 with equal probability, then raise it to the power N-1. Then apply the method for N-1 chords on the rest.
I'm basing this on the formula for the right-isoceles triangle area, n²/2, and the formula for the right-pyramid volume, n³/6, and I extrapolated.
I hope I didn't make any mistake in there... but it looks right.
And by the way (a little off-topic now): Mathieu, I recently compilated GridFlow and tried the [note] object you did. Humm! What a nice object. I still would prefer that the output would be the midi note and the slide to go chromatically because at least for me is so much easier for the calculations, but kudos to you.
Well, when I made it, I already planned that I would incompatibly change it from what it is, so that it becomes MIDI. That's on my TODO list. Maybe I will do it for 9.14.
| Mathieu Bouchard ---- tél: +1.514.383.3801 ---- Villeray, Montréal, QC