Forums > MaxMSP

best way to implement multiple random samples

July 27, 2007 | 7:19 pm

Hello.
I want to use a few different samples of the same sound in my patch so that the performance sounds a little more realistic/musical. Basically, I want the sample being used to be chosen randomly as I’m playing a drum pad that’s assigned to one particular sound.
Is this the best way to do this?

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 417 220 32 196617 sel 3;
#P newex 341 219 32 196617 sel 2;
#P newex 260 223 32 196617 sel 1;
#P newex 337 182 27 196617 + 1;
#P newex 337 159 52 196617 random 3;
#P toggle 336 111 15 0;
#P newex 337 137 64 196617 metro 1000;
#P message 156 337 74 196617 0 , 3000 3000;
#P newex 234 364 32 196617 line~;
#P message 485 293 82 196617 set samplethree;
#P message 332 293 75 196617 set sampletwo;
#P message 196 292 73 196617 set sampleone;
#P newex 332 396 84 196617 play~ sampleone;
#P newex 472 68 102 196617 buffer~ samplethree;
#P newex 331 71 95 196617 buffer~ sampletwo;
#P newex 180 72 93 196617 buffer~ sampleone;
#P connect 12 0 13 0;
#P connect 12 0 14 0;
#P connect 12 0 15 0;
#P connect 15 0 6 0;
#P connect 14 0 5 0;
#P connect 13 0 4 0;
#P connect 11 0 12 0;
#P connect 9 0 11 0;
#P connect 10 0 9 0;
#P connect 8 0 7 0;
#P connect 7 0 3 0;
#P connect 6 0 3 0;
#P connect 5 0 3 0;
#P connect 4 0 3 0;
#P window clipboard copycount 16;

I just made this quick as an example. The finished patch my actually use more samples.
Thanks.


July 27, 2007 | 8:23 pm

Eric Sheffield skrev:
> Hello.
> I want to use a few different samples of the same sound in my patch so that the performance sounds a little more realistic/musical. Basically, I want the sample being used to be chosen randomly as I’m playing a drum pad that’s assigned to one particular sound.
> Is this the best way to do this?
>
> …snip…
>
> I just made this quick as an example. The finished patch my actually use more samples.
> Thanks.
Here’s what I would do – it would show its worth when you start adding
more samples in the finished patch, I think.

Best,
Andreas.

#P window setfont "Sans Serif" 9.;
#P window linecount 2;
#P comment 380 187 100 9109513 – just add more "buffer~ sample[int]s";
#P number 173 57 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P message 126 148 50 9109513 sample1;
#B color 14;
#P newex 100 104 100 9109513 sprintf "set sample%i";
#P newex 100 78 52 9109513 random 3;
#P toggle 100 36 15 0;
#P newex 100 56 64 9109513 metro 1000;
#P message 34 138 62 9109513 0 , 3000 3000;
#P newex 34 162 32 9109513 line~;
#P newex 100 202 84 9109513 play~ sampleone;
#P newex 381 160 77 9109513 buffer~ sample2;
#P newex 381 118 77 9109513 buffer~ sample1;
#P newex 381 139 77 9109513 buffer~ sample2;
#P window linecount 9;
#P comment 228 90 100 9109513 < - the sprintf solution allows you to
increase the number of potential sample buffers without getting into
trouble when scaling ; no more arrays of message-boxes.;
#P window linecount 1;
#P comment 342 231 100 9109513 andreas wetterberg.;
#P fasten 13 0 10 1 178 76 147 76;
#P connect 11 0 5 0;
#P connect 11 0 12 0;
#P connect 10 0 11 0;
#P connect 8 0 10 0;
#P connect 9 0 8 0;
#P connect 7 0 6 0;
#P connect 6 0 5 0;
#P window clipboard copycount 15;


July 27, 2007 | 8:32 pm

I think using a coll to store the sample names would be easier. This way you don’t have to wire up more objects every time you add a sample. And there are a few other benefits:
- You can save the coll contents to create reusable sample packs
- You can store additional information about the sample in the coll. So for example, if you samples are different lengths you might want to use sfinfo~ to get the sample length and store [index samplename samplelength] in coll, then unpack the data coming out of coll and pass the sample length to the line~ object.

Adam

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 336 252 57 9109513 prepend set;
#P newex 336 228 63 9109513 route symbol;
#P user textedit 426 292 526 311 32896 139 9 sampleone;
#N coll samples;
#T flags 1 0;
#T 0 sampleone;
#T 1 sampletwo;
#T 2 samplethree;
#P newobj 336 205 60 9109513 coll samples;
#P newex 336 172 52 9109513 random 3;
#P toggle 335 121 15 0;
#P newex 336 147 64 9109513 metro 1000;
#P message 187 224 74 9109513 0 , 3000 3000;
#P newex 265 251 32 9109513 line~;
#P newex 336 294 84 9109513 play~ sampleone;
#P newex 472 68 102 9109513 buffer~ samplethree;
#P newex 331 71 95 9109513 buffer~ sampletwo;
#P newex 180 72 93 9109513 buffer~ sampleone;
#P connect 5 0 4 0;
#P connect 7 0 6 0;
#P connect 6 0 8 0;
#P connect 8 0 9 0;
#P connect 9 0 11 0;
#P connect 11 0 12 0;
#P connect 12 0 3 0;
#P connect 4 0 3 0;
#P connect 12 0 10 0;
#P window clipboard copycount 13;

Quote: mopppish wrote on Fri, 27 July 2007 12:19
—————————————————-
> Hello.
> I want to use a few different samples of the same sound in my patch so that the performance sounds a little more realistic/musical. Basically, I want the sample being used to be chosen randomly as I’m playing a drum pad that’s assigned to one particular sound.
> Is this the best way to do this?
>
> #P window setfont "Sans Serif" 9.;
> #P window linecount 1;
> #P newex 417 220 32 196617 sel 3;
> #P newex 341 219 32 196617 sel 2;
> #P newex 260 223 32 196617 sel 1;
> #P newex 337 182 27 196617 + 1;
> #P newex 337 159 52 196617 random 3;
> #P toggle 336 111 15 0;
> #P newex 337 137 64 196617 metro 1000;
> #P message 156 337 74 196617 0 , 3000 3000;
> #P newex 234 364 32 196617 line~;
> #P message 485 293 82 196617 set samplethree;
> #P message 332 293 75 196617 set sampletwo;
> #P message 196 292 73 196617 set sampleone;
> #P newex 332 396 84 196617 play~ sampleone;
> #P newex 472 68 102 196617 buffer~ samplethree;
> #P newex 331 71 95 196617 buffer~ sampletwo;
> #P newex 180 72 93 196617 buffer~ sampleone;
> #P connect 12 0 13 0;
> #P connect 12 0 14 0;
> #P connect 12 0 15 0;
> #P connect 15 0 6 0;
> #P connect 14 0 5 0;
> #P connect 13 0 4 0;
> #P connect 11 0 12 0;
> #P connect 9 0 11 0;
> #P connect 10 0 9 0;
> #P connect 8 0 7 0;
> #P connect 7 0 3 0;
> #P connect 6 0 3 0;
> #P connect 5 0 3 0;
> #P connect 4 0 3 0;
> #P window clipboard copycount 16;
>
> I just made this quick as an example. The finished patch my actually use more samples.
> Thanks.
—————————————————-


July 31, 2007 | 8:18 am

Eric Sheffield schrieb:
> Hello. I want to use a few different samples of the same sound in my
> patch so that the performance sounds a little more realistic/musical.
> Basically, I want the sample being used to be chosen randomly as I’m
> playing a drum pad that’s assigned to one particular sound. Is this
> the best way to do this?

Beside the valid suggestions about using a coll:

I’d not use play~, as you’d need to know the length of the samples. In
this case groove~ is better.
I’d not use a metro to select new samples, as you most likely will
switch the sound while playing, which will create clicks. select the new
sample just before you play it… (trigger is your friend…)

No example patch, to let you some excersise for patching… ;-)

Stefan


Stefan Tiedje————x——-
–_____———–|————–
–(_|_ —-|—–|—–()——-
– _|_)—-|—–()————–
———-()——–www.ccmix.com


Viewing 4 posts - 1 through 4 (of 4 total)