Forums > MaxMSP

how do samplers work?!

December 14, 2006 | 9:41 am

i’m trying to integrate a sample player built in maxmsp with a rewire host ,usually ableton.
how do monophonic samplers manage to play a loop triggered by midi, without clicking? (since they cant know in advance when the next midi note will occur)


December 14, 2006 | 10:38 am

adsr~ ?


December 14, 2006 | 11:04 am

adsr~ doesnt seem to work for me in this case. i dont see how i can fade to zero gain *before* retriggering the sample ,other than having every single midi note made a little bit short (a pain in the ass) to allow the envelope to close in time befor i retrigger it.

i was wondering how a commercial sampler app deals with this problem



FP
December 14, 2006 | 3:29 pm

it could be very great and interesting if somebody could answer to this question.
it’s really not easy for young maxers…

and it’s certainly very simple for you, o masters of max.
:)

please.
;)

fp.

ps: i have only a solution for simple wave (thx ej):

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 272 189 52 196617 route list;
#P newex 209 61 38 196617 sel 32;
#P newex 209 33 40 196617 key;
#P newex 272 209 32 196617 line~;
#P newex 124 241 27 196617 *~;
#P newex 124 177 61 196617 cycle~ 440;
#P message 42 234 67 196617 startwindow;
#P newex 122 272 31 196617 dac~;
#P user function 209 82 409 182 1 1 0 0;
#X frgb 82 82 82;
#X brgb 204 204 204;
#X rgb2 85 85 85;
#X rgb3 255 255 255;
#X rgb4 0 0 0;
#X rgb5 0 0 0;
#X add 0. 0. 0;
#X add 122.340424 1. 0;
#X add 648.936157 1. 0;
#X add 1000. 0. 0;
#X domain 1000.;
#X range 0. 1.;
#X done;
#P connect 8 0 5 0;
#P connect 0 1 8 0;
#P connect 7 0 0 0;
#P connect 6 0 7 0;
#P connect 4 0 1 0;
#P connect 4 0 1 1;
#P connect 5 0 4 1;
#P connect 3 0 4 0;
#P connect 2 0 1 0;
#P window clipboard copycount 9;


December 14, 2006 | 3:58 pm


December 14, 2006 | 4:35 pm

Here is a solution taking advantage of info~ to know the length of the sample. If you trigger the loop, the envelope will automatically go to 0. then rise for the fade in/out time (default 10ms). The sample will play and then the envelope will fade out to 0 during the last 10 ms of the sample. Again, if you re-trigger the
sample at any time, the envelope will re-trigger as well.

I put in a quick little loop thing as well, so you can see how this would allow any loop to continue without clicks at the start/end points (if thats something you wanted).

I’ve always found line~ and curve~ to be the best envelope tools, they do exactly what you tell them.

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P hidden newex 302 500 29 196617 gate;
#P toggle 302 472 15 0;
#P hidden button 373 146 15 0;
#P newex 349 467 32 196617 line~;
#P message 349 445 61 196617 0. 0. $1 $1;
#P newex 349 423 31 196617 float;
#P hidden newex 486 520 72 196617 loadmess 100;
#P newex 421 571 35 196617 *~ 1.;
#P flonum 496 599 35 9 0 0 8352 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P hidden newex 476 625 49 196617 * 0.01;
#P user uslider 476 544 16 58 101 1 0 0;
#P toggle 393 570 15 0;
#P newex 421 604 31 196617 dac~;
#P newex 421 546 27 196617 *~;
#P newex 438 463 32 196617 line~;
#B color 14;
#P message 438 436 112 196617 0. 0. 1. $1 1. $2 0. $1;
#B color 14;
#P newex 349 489 74 196617 play~ sampler;
#P newex 312 360 38 196617 sel 32;
#P newex 312 333 40 196617 key;
#P newex 380 367 19 196617 t b;
#P newex 358 331 32 196617 sel 0;
#P newex 343 310 40 196617 notein;
#P newex 438 381 62 196617 prepend set;
#P hidden newex 273 179 66 196617 loadmess 10;
#P newex 314 235 180 196617 t f f;
#B color 14;
#P newex 438 407 56 196617 pack 0. 0.;
#B color 14;
#P newex 438 206 53 196617 t b f;
#B color 14;
#P newex 484 343 34 196617 !- 0.;
#B color 14;
#P newex 484 317 31 196617 * 2;
#B color 14;
#P number 314 209 35 9 0 20 3 3 0 0 0 255 92 174 222 222 222 0 0 0;
#P newex 360 174 105 196617 info~ sampler;
#B color 14;
#P newex 176 117 81 196617 prepend replace;
#P message 284 119 43 196617 replace;
#P user dropfile 176 37 319 100 0;
#P newex 284 144 86 196617 buffer~ sampler;
#P window linecount 2;
#P comment 200 59 100 196617 Drag & drop file here;
#P user panel 177 47 139 46;
#X brgb 191 191 191;
#X frgb 0 0 0;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P window linecount 1;
#P comment 330 121 136 196617 < --- or click for open dialog;
#P comment 469 177 211 196617 When sample is loaded , get total sampel time;
#P comment 202 210 111 196617 Fade In/Out Time (ms);
#P window linecount 2;
#P comment 83 235 219 196617 usually around 10 to 20 ms will remove clicks without any noticeable fade-in;
#P window linecount 1;
#P comment 160 314 170 196617 Note-on (or spacebar) triggers loop;
#P window linecount 4;
#P comment 576 377 276 196617 This tells the line-based envelope to go from 0. to 1. over the fade in/out time. The envelope stays at 1 for the duration of the sample – (fade in/out time * 2) then goes to 0 in the fade in/out time;
#P window linecount 1;
#P comment 494 587 42 196617 Volume;
#P comment 267 449 74 196617 Sample player;
#P user panel 194 197 168 36;
#X brgb 171 204 226;
#X frgb 0 0 0;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P hidden comment 391 145 138 196617 retrigger value (for testing);
#P user panel 434 301 139 189;
#X brgb 232 215 215;
#X frgb 0 0 0;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P comment 238 474 62 196617 Loop on/off;
#P hidden fasten 48 0 29 0 307 544 385 544;
#P hidden fasten 45 1 48 1 378 486 326 486;
#P fasten 31 0 29 0 317 384 370 384 370 350 385 350;
#P hidden connect 47 0 48 0;
#P connect 34 0 35 1;
#P fasten 24 0 26 0 319 271 443 271;
#P fasten 22 1 43 1 486 297 375 297;
#P lcolor 7;
#P fasten 22 1 21 1 486 298 513 298;
#P lcolor 7;
#P connect 21 0 23 1;
#P connect 24 1 20 0;
#P connect 33 0 34 0;
#P connect 18 6 22 0;
#P fasten 29 0 43 0 385 396 354 396;
#P lcolor 13;
#P fasten 29 0 23 0 385 407 443 407;
#P lcolor 13;
#P connect 30 0 31 0;
#P hidden connect 46 0 18 0;
#P hidden fasten 39 0 41 1 481 650 471 650 471 544 451 544;
#P hidden fasten 39 0 40 0 481 658 501 658;
#P connect 41 0 36 0;
#P fasten 41 0 36 1 426 596 447 596;
#P fasten 37 0 36 0 398 592 426 592;
#P connect 43 0 44 0;
#P connect 45 0 32 0;
#P connect 44 0 45 0;
#P hidden fasten 42 0 38 0 491 518 481 518;
#P connect 35 0 41 0;
#P hidden connect 38 0 39 0;
#P fasten 32 0 35 0 354 511 426 511;
#P connect 23 0 33 0;
#P connect 28 1 29 0;
#P connect 27 1 28 0;
#P connect 26 0 23 0;
#P hidden fasten 25 0 19 0 278 202 319 202;
#P connect 19 0 24 0;
#P fasten 22 0 20 0 443 269 489 269;
#P connect 20 0 21 0;
#P connect 14 1 18 0;
#P connect 16 0 14 0;
#P fasten 17 0 14 0 181 139 289 139;
#P connect 15 0 17 0;
#P window clipboard copycount 49;


December 14, 2006 | 5:05 pm

After re-reading your post, i think I may have misunderstood your problem. Here is another solution using two line~ objects to do the following things:

fade out the sample over 5 ms
(re)trigger the sample
fade the ssample back in over 5 ms

This way you can re-trigger the sample over and over again, click free. I tried it and the 10 ms total fade-in out time doesn’t seem too bad, though you could tweak these values up or down to taste.

(edited….forgot a couple of things..)

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P hidden newex 461 299 66 196617 loadmess 37;
#P number 461 326 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P hidden newex 345 123 72 196617 loadmess 100;
#N vpatcher 40 104 391 378;
#P button 183 61 15 0;
#N comlet Trigger Sample;
#P inlet 183 41 15 0;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 183 167 32 196617 line~;
#P message 183 145 61 196617 0. 0. $1 $1;
#P newex 183 123 31 196617 float;
#P newex 183 189 74 196617 play~ sampler;
#P newex 126 80 105 196617 info~ sampler;
#B color 14;
#P newex 50 50 86 196617 buffer~ sampler;
#N comlet Messages to buffer;
#P inlet 50 30 15 0;
#N comlet sampler output;
#P outlet 182 212 15 0;
#P connect 1 0 2 0;
#P connect 2 1 3 0;
#P connect 4 0 0 0;
#P connect 8 0 9 0;
#P connect 9 0 5 0;
#P connect 5 0 6 0;
#P connect 6 0 7 0;
#P connect 7 0 4 0;
#P connect 3 6 5 1;
#P pop 1;
#P newobj 58 251 54 196617 p sampler;
#P message 58 218 43 196617 replace;
#P user scope~ 427 360 557 490 37 3 128 -1. 1. 0 0. 0 0. 102 255 51 135 135 135 0;
#P comment 207 375 44 196617 volume;
#P newex 171 340 27 196617 *~;
#P newex 171 373 27 196617 *~;
#P flonum 377 286 35 9 0 0 8352 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P hidden newex 357 312 49 196617 * 0.01;
#P user uslider 357 159 18 128 101 1 0 0;
#P user ezdac~ 170 416 214 449 0;
#P newex 188 35 40 196617 key;
#P newex 280 265 32 196617 t 1 1;
#P newex 188 280 74 196617 selector~ 2 1.;
#P newex 188 61 38 196617 sel 32;
#P newex 210 176 66 196617 t b 2 0. b;
#P message 210 214 26 196617 1. 5;
#P message 188 104 26 196617 0. 5;
#P newex 246 246 32 196617 line~;
#P newex 188 142 32 196617 line~;
#P comment 377 267 42 196617 Volume;
#P comment 204 343 44 196617 envelope;
#P user panel 178 94 119 109;
#X brgb 223 206 208;
#X frgb 0 0 0;
#X border 0;
#X rounded 0;
#X shadow 0;
#X done;
#P comment 296 96 192 196617 Fade out , trigger sample , trigger fade in;
#P comment 262 217 41 196617 Fade in;
#P user panel 207 208 106 112;
#X brgb 214 228 233;
#X frgb 0 0 0;
#X border 0;
#X rounded 0;
#X shadow 0;
#X done;
#P comment 38 202 65 196617 Load Sample;
#P comment 115 219 78 196617 Trigger sample;
#P hidden connect 29 0 28 0;
#P connect 28 0 24 0;
#P connect 14 0 22 1;
#P fasten 14 0 24 0 193 332 432 332;
#P connect 13 0 10 0;
#P fasten 15 0 14 0 285 309 184 309 184 262 193 262;
#P fasten 15 1 8 0 307 298 330 298 330 128 193 128;
#P fasten 9 1 15 0 273 267 285 267;
#P hidden connect 27 0 18 0;
#P fasten 26 0 22 0 63 297 176 297;
#P fasten 12 3 26 1 269 217 107 217;
#P lcolor 15;
#P connect 25 0 26 0;
#P connect 12 2 9 0;
#P fasten 12 1 14 0 233 205 193 205;
#P connect 8 1 12 0;
#P connect 12 0 11 0;
#P connect 21 0 17 0;
#P connect 21 0 17 1;
#P hidden fasten 19 0 21 1 362 362 193 362;
#P hidden fasten 19 0 20 0 362 345 382 345;
#P connect 22 0 21 0;
#P hidden connect 18 0 19 0;
#P connect 16 0 13 0;
#P fasten 9 0 14 2 251 271 257 271;
#P fasten 8 0 14 1 193 244 225 244;
#P fasten 11 0 9 0 215 237 251 237;
#P connect 10 0 8 0;
#P window clipboard copycount 30;


December 14, 2006 | 6:28 pm

so basically youre suggesting introducing a latency into the sampler to allow time to fade out. is this what the exs24 or kontakt or whatever does? how come you cant hear a latency in those instruments?

i would guess this concept isnt going to get on too well with a max sampler using poly~ thispoly~ etc…..

>adsr~ @legato 1? It won’t force to start at 0 (like the [route >list] trick).

surely the envelope has to go to zero to stop the sample clicking at the start ….theres a discontinuity when the sample is retriggered, not caused by the gain envelope



FP
December 14, 2006 | 6:39 pm

i’m really sorry but none solution work well for me.
tried with "cello-f2.aif" in the examples/sound folder.
??


December 14, 2006 | 7:59 pm

i think i may have the answer!
use adsr~ and send a retrigger amount of 10ms say. when the second outlet of adsr~ goes from 0 to 1 the sample is retriggered, so it will always trigger when the envelope is at zero. i think this will work inside poly~ too

of course then i have a latency of 10ms, but i guess i can compensate in my host somehow

please test this out

max v2;
#N vpatcher 143 223 907 704;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 199 102 40 196617 / 127.;
#N vpreset 1;
#X append 1 2 12 77 336 flonum float 10. ; 13 77 410 flonum float 1. ; 14 77 376 flonum float 10. ; 15 76 447 flonum float 380. ; 16 75 487 flonum float 10. ; 17 123 198 flonum float;
#X append 1 2 0.314961 ;;
#P preset 561 50 47 27;
#P user scope~ 412 320 542 450 256 3 128 -1. 1. 0 0. 0 0. 102 255 51 135 135 135 0;
#P newex 409 259 36 196617 edge~;
#P newex 408 237 37 196617 ==~ 1;
#P newex 405 215 46 196617 change~;
#P flonum 198 123 43 9 0. 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 487 75 35 9 0. 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 447 76 35 9 0. 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 376 77 35 9 0. 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 410 77 35 9 0. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 336 77 35 9 0. 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 320 116 32 196617 sel 0;
#P newex 270 117 40 196617 / 127.;
#P newex 250 55 40 196617 notein;
#P message 280 281 51 196617 startloop;
#P newex 274 190 38 196617 sig~ 1;
#P user ezdac~ 346 395 390 428 0;
#P newex 377 335 27 196617 *~;
#P message 136 227 43 196617 replace;
#P newex 132 248 111 196617 buffer~ sample 10000;
#P newex 265 307 81 196617 groove~ sample;
#P message 481 109 67 196617 retrigger $1;
#P newex 377 188 66 196617 adsr~;
#P connect 4 0 3 0;
#P connect 23 0 17 0;
#P connect 9 0 23 0;
#P connect 8 0 2 0;
#P connect 7 0 2 0;
#P connect 9 1 10 0;
#P connect 17 0 7 0;
#P connect 20 0 8 0;
#P connect 9 1 11 0;
#P connect 5 0 6 0;
#P connect 10 0 0 0;
#P connect 1 0 0 0;
#P connect 2 0 5 0;
#P connect 5 0 6 1;
#P connect 12 0 0 1;
#P connect 0 0 5 1;
#P connect 14 0 0 2;
#P connect 0 1 18 0;
#P connect 18 0 19 0;
#P connect 19 0 20 0;
#P connect 0 0 21 0;
#P connect 13 0 0 3;
#P connect 15 0 0 4;
#P connect 16 0 1 0;
#P pop;



FP
December 14, 2006 | 8:26 pm

perfect…
thx.

in fact i had a conflict between adsr~ (max release) and adsr~ Lyon potpourri… strange.


December 14, 2006 | 9:55 pm

I beleive you can work with two play~ or groove~ or whatever. This wait you won’t have the 10ms latency… All you need to do is alternate for one to the other. When you start reading a sound from one, you fade the other.


December 14, 2006 | 10:01 pm

actually this seems to work better…..the envelope is a simple Attack-decay with retrigger setting also

max v2;
#N vpatcher 82 109 1149 796;
#P user scope~ 442 366 642 452 256 3 128 -1. 1. 0 0. 0 0. 102 255 51 135 135 135 0;
#N vpreset 1;
#X append 1 2 9 123 198 flonum float 0.123203 ; 13 142 469 flonum float 0.67 ; 16 140 536 flonum float 2.26 ; 20 140 577 flonum float 0.96 ;;
#P preset 503 68 47 27;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P comment 577 122 34 196617 decay;
#P comment 534 122 38 196617 attack;
#P newex 170 192 20 196617 t b;
#P newex 331 327 41 196617 * 44.1;
#P newex 253 327 73 196617 delay~ 22050;
#P flonum 577 140 35 9 0. 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 506 261 31 196617 0 $1;
#P newex 444 141 20 196617 t b;
#P newex 340 101 32 196617 sel 0;
#P flonum 536 140 35 9 0. 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 443 238 36 196617 zl reg;
#P newex 469 201 49 196617 pak 0. 0.;
#P flonum 469 142 35 9 0. 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 443 262 55 196617 0 $1 1 $2;
#P newex 443 324 32 196617 line~;
#P newex 199 102 40 196617 / 400.;
#P flonum 198 123 43 9 0. 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 325 52 40 196617 notein;
#P message 170 215 51 196617 startloop;
#P newex 255 216 38 196617 sig~ 1;
#P user ezdac~ 238 445 282 478 0;
#P newex 251 383 27 196617 *~;
#P message 60 255 43 196617 replace;
#P newex 60 278 111 196617 buffer~ sample 10000;
#P newex 252 301 81 196617 groove~ sample;
#P comment 469 123 50 196617 retrigger;
#P connect 3 0 2 0;
#P connect 17 1 23 0;
#P connect 23 0 7 0;
#P connect 10 0 9 0;
#P connect 8 0 10 0;
#P connect 4 0 5 0;
#P connect 21 0 4 0;
#P connect 6 0 1 0;
#P connect 7 0 1 0;
#P connect 1 0 21 0;
#P connect 9 0 6 0;
#P connect 11 0 4 1;
#P connect 4 0 5 1;
#P connect 22 0 21 1;
#P connect 13 0 22 0;
#P connect 8 1 17 0;
#P connect 11 0 27 0;
#P connect 18 0 15 0;
#P connect 15 0 12 0;
#P connect 19 0 11 0;
#P connect 12 0 11 0;
#P connect 17 1 18 0;
#P connect 13 0 14 0;
#P connect 14 0 15 1;
#P connect 20 0 19 0;
#P connect 17 0 19 0;
#P connect 16 0 14 1;
#P pop;


December 14, 2006 | 10:06 pm

>I beleive you can work with two play~ or groove~ or whatever. This >wait you won’t have the 10ms latency… All you need to do is >alternate for one to the other. When you start reading a sound >from one, you fade the other.

that would double your CPU load though, if only for a millisecond or so


December 14, 2006 | 10:53 pm

Quote: bin wrote on Thu, 14 December 2006 04:04
—————————————————-
> adsr~ doesnt seem to work for me in this case. i dont see how i can fade to zero gain *before* retriggering the sample ,other than having every single midi note made a little bit short (a pain in the ass) to allow the envelope to close in time befor i retrigger it.
>
> i was wondering how a commercial sampler app deals with this problem
—————————————————-

realtime programs do not _need to know the next (midi)
event _BEFORE it comes to perform an action on audio
(like interpolating or crossfading but also think about
_starting a new audio event.)

realtime systems like ableton live or the plug-in interfaces
(VST AU RTAS…) do the opposite: the events from the
sequencing part of the software are sent _earlier than you
think/see/hear them.

without that simple trick cubase or protools would not even
be able to start 10 tracks of disk audio at the same moment
( =within 1 sample =eventually 1/192 milliseconds)

in the case of ableton live (i.e. or a similar solution within
MAXMSP) you could also perform a complex declicking or
crossfading DSP _offline as soon as the main speed in the
"song" is changed. for such a system, you would use 2 buffers
for every sample slot, so that the calculation of newly
processed files will be fast enough so that one does not
notice the process.

lastly, if all what you are looking for is a quick hack to
remove the bad bad click in a loop, why not just fadout
the sample slot for 10-12 milliseconds; noone will notice
that in a drumloop.

or give up drumloops, they stopped beeing cool in 1996.


December 15, 2006 | 1:39 am

check out the audiorate-sequencing-looping folder in the max examples folder or msp examples or something. Groove duck I think is the name of the patch, good way to duck in and out loops at the begin and ending curtousy of jhno.

I thought it was 93 when drum loops went out ;)


December 15, 2006 | 8:57 am

I’m not trying to play a loop, cool/uncool drums or otherwise
youre not understanding my initial question! i cant use that groove duck patch because i’m not playing a loop. the end point is unknown by the max patch!

the problem is to do with retriggering a sample, or playing a sequence of samples in sucession with no clicks between them, triggered by midi input…..

adsr~ has a retrigger function, but it seems to be hard to synchronise the triggering of a sample with the zero point after the retrigger ramp down. this is not such an issue with synth patches since its less likely to be a discontinuity in the audio being enveloped

the last patch i posted was giving me good results last night if anyone is interested in this sort of thing….



f.e
December 15, 2006 | 9:43 am

Build a poly~ player :

[Bang]
|
[random 127]
|
[makenote 127 0]
|
[poly 4 1]
| | |
[pack 0 0 0]
|
(target $1, $2 $3)
|
yourpoly~
|

|
[unpack 0 0]
|
[sel 127]
|
(startloop)

While the[makenote]‘s third inlet is fed by the seventh outlet of an
[info~] object linked to your buffer~.
Inside your poly~ player, you may add a smoothing mechanism (using
line~) to get rid of clicks when retriggering : buffer the message, wait
for line to finish, output the message.

f.e

f.e chanfrault | aka | personal computer music
> >>>>>> http://www.personal-computer-music.com
> >>>>>> |sublime music for a desperate people|

bin ray wrote:
> I’m not trying to play a loop, cool/uncool drums or otherwise
> youre not understanding my initial question! i cant use that groove duck patch because i’m not playing a loop. the end point is unknown by the max patch!
>
> the problem is to do with retriggering a sample, or playing a sequence of samples in sucession with no clicks between them, triggered by midi input…..
>
> adsr~ has a retrigger function, but it seems to be hard to synchronise the triggering of a sample with the zero point after the retrigger ramp down. this is not such an issue with synth patches since its less likely to be a discontinuity in the audio being enveloped
>
> the last patch i posted was giving me good results last night if anyone is interested in this sort of thing….
>
>
>
>
>


December 15, 2006 | 10:15 am

im finding buffering the message to restart the sample alot less accurate than delaying the audio from the sample player (before enveloping it).


December 15, 2006 | 10:25 am

sorry i was confusing y’all. my loop is a midi loop , not an audio one. there is no looping audio



f.e
December 15, 2006 | 10:39 am

No accuracy loss at all, unless you made it the wrong way. Works with or
without loop.

f.e

f.e chanfrault | aka | personal computer music
> >>>>>> http://www.personal-computer-music.com
> >>>>>> |sublime music for a desperate people|

bin ray wrote:
> im finding buffering the message to restart the sample alot less accurate than delaying the audio from the sample player (before enveloping it).
>
>



f.e
December 15, 2006 | 10:40 am

Yes. Works either.

f.e

f.e chanfrault | aka | personal computer music
> >>>>>> http://www.personal-computer-music.com
> >>>>>> |sublime music for a desperate people|

bin ray wrote:
> sorry i shouldnt have said i was playing a loop at first, its just about triggering midi without clicks, in a loop or otherwise
>
>


December 15, 2006 | 10:53 am

show me a patch?


December 16, 2006 | 4:29 am

Quote: bin wrote on Fri, 15 December 2006 01:57
—————————————————-
> I’m not trying to play a loop, cool/uncool drums or otherwise
> youre not understanding my initial question! i cant use that groove duck patch because i’m not playing a loop. the end point is unknown by the max patch!
>
> the problem is to do with retriggering a sample, or playing a sequence of samples in sucession with no clicks between them, triggered by midi input…..

lets say a sample _usually starts with some waveform
smoothly beginning at 0.0 – and if not, the click which
would occur if wanted.

so the "click problem" you see is only at the end of
the sample – where it is cut off at an unknown time and
instantly plays again from the start.

a solution could be to let your sample fade out 20 ms
or so instead of cutting it off immediatley when you
retrigger it.

if you ue groove~ instead of buffer~ you do not even
need 2 buffers to play a sample with such an overlap.

-110


December 16, 2006 | 7:53 am

bin ray wrote:
> adsr~ doesnt seem to work for me in this case. i dont see how i can
> fade to zero gain *before* retriggering the sample….surely that the
> only way to have no click…

You’d still need two voices for a mono sampler, just any new note will
switch of the old voice with its envelope…

Stefan


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


December 16, 2006 | 11:49 am

Emmanuel Jourdan wrote:
> adsr~ @legato 1? It won’t force to start at 0 (like the [route list]
> trick).

But if you jump at the same time to the beginning of the sample, it
would create a click, it works with synths though…

Stefan


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


December 16, 2006 | 1:01 pm

bin ray wrote:
> that would double your CPU load though, if only for a millisecond or
> so

for 10ms to be exact, and only if you put it into a properly setup poly~
- but if you’re concerned about that, I’d recommend to sing, this will
bring your CPU down to zero…

Stefan


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


December 16, 2006 | 1:05 pm

Roman Thilenius wrote:
> or give up drumloops, they stopped beeing cool in 1996.

I thought it was 1986, but I guess I was ahead of time that time.
(Timing has been confusing me always thats why I can’t keep it…)

Stefan


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


December 17, 2006 | 12:13 pm

>bin ray wrote:
>> that would double your CPU load though, if only for a >millisecond or
>> so

>for 10ms to be exact, and only if you put it into a properly setup >poly~
>- but if you’re concerned about that, I’d recommend to sing, this >will
>bring your CPU down to zero…

do you not think it would be a problem to double CPU load for even 10 ms? it would certainly screw up the audio output if you went above 100 percent load….crossfading isnt an option for me since i am working at around 50 percent CPU load normally


December 17, 2006 | 12:25 pm

the last patch i posted using line~ seems to give me clickless playback using a host sequencer, or from any midi input. albeit with a latency of the same time as the retrigger time.
however it would be useful if anyone could tell me to use adsr~ to do the same thing seeing as thats what it is supposed to be for? and its nicer for muting and stuff.
please build me a patch! you clever people


December 17, 2006 | 1:51 pm

Quote: bin wrote on Thu, 14 December 2006 19:28
—————————————————-
> so basically youre suggesting introducing a latency into the sampler to allow time to fade out. is this what the exs24 or kontakt or whatever does? how come you cant hear a latency in those instruments?
>

I assume these samplers are all polyphonic, which means they will always start a newly triggered sample on a new voice (just like poly~), fading out the previous sample independently from the new one in its own release phase. This is a feature that of course uses more cpu power than a monophonic approach. If there would be only one voice I assume you’d get clicks.

Mattijs



f.e
December 17, 2006 | 2:17 pm

> please build me a patch! you clever people
>
I didn’t give an answer to your last post because of this. Don’t order
people to ‘show a patch’ as i usually do when asking for C code
about delays ;-)

We sure got the solution but :

1 – you don’t explain your problem _clearly
2 – you’re way too much nervous & aggressive to give people the taste to
help you.

Again, the 10ms solution is the best one in any case, mono or poly.
Human usually detect a delay starting at 20ms… I use this solution
since years, in *every* MSP patch i have, to avoid any kinds of clicks.
5ms fade out, then 5ms fade in. Simple as that. If it doesn’t work at
your home, it’s because you don’t build it correctly.

If your ears are too delicate for this delay, it also depends how long
is your sample. If you’re playing a drum, building a minimum voices
poly~ would never charge your cpu. And for drum, you don’t even need
anything else than a simple groove~ player AND the fade solution. If
you’re playing long waves, 24 poly voices will be ok. About commercial
samplers, please note that, in the case of Kontakt, for example, there’s
ALWAYS a problem with voices, stealing & cpu charge. All my different
versions of Kontakt begun to play shit after the 24 full voices were fed.

Forget about adsr~, it’s not as good as it seems to be. Build your own
enveloppe with line~ or, better, curve~. This last one will allow you to
use a very handfull curve factor.

f.e

> –
> http://www.myspace.com/binray
>
>


December 17, 2006 | 2:53 pm

"please build me a patch" is not meant to be agressive.
its alot easier for me to understand a patch than a description of one. i share enough of my patches, such as they are. you can have the tracks i made with em for free too!

anyways, i agree adsr~ seems not as useful as building your own envelope… i couldnt get rid of clicks using adsr~ in a monophonic player

and you are all very clever;)



f.e
December 17, 2006 | 3:19 pm

Ok. If you’re ok in a mono world, here’s what you need :

[ddg.mono] external by Darwin Grosse (you should have since your first
days, if not -> Maxobjects.com)

[fe.nocut~.pat] :

#P window setfont "Sans Serif" 10.;
#P window linecount 1;
#P comment 66 505 228 9109514 http://www.personal-computer-music.com;
#P comment 66 489 228 9109514 fe.nocut~ by f.e 2006;
#P comment 66 470 228 9109514 ___________________________________;
#P window setfont "Sans Serif" 9.;
#P window linecount 0;
#P message 232 408 50 9109513;
#P window linecount 1;
#P newex 288 358 57 9109513 prepend set;
#N comlet message;
#P outlet 232 436 15 0;
#N comlet (signal) R;
#P outlet 104 436 15 0;
#N comlet (signal) L / mono;
#P outlet 72 436 15 0;
#N comlet (signal) R;
#P inlet 104 44 15 0;
#N comlet (signal) L / mono;
#P inlet 72 44 15 0;
#P newex 72 398 28 9109513 *~ 1.;
#P newex 104 398 28 9109513 *~ 1.;
#N comlet message;
#P inlet 159 44 15 0;
#P newex 159 109 27 9109513 t b 1;
#P newex 202 242 27 9109513 gate;
#P newex 202 290 40 9109513 t b 0 b;
#P message 202 337 29 9109513 1. $1;
#P message 191 149 29 9109513 0. $1;
#P newex 191 187 38 9109513 line~ 1.;
#P connect 9 0 8 0;
#P connect 8 0 11 0;
#P fasten 0 0 8 1 196 382 95 382;
#P connect 10 0 7 0;
#P connect 7 0 12 0;
#P fasten 0 0 7 1 196 382 127 382;
#P connect 6 0 5 0;
#P connect 5 0 1 0;
#P connect 1 0 0 0;
#P fasten 2 0 0 0 207 364 162 364 162 175 196 175;
#P fasten 3 1 4 0 222 317 183 317 183 234 207 234;
#P fasten 5 1 4 0 181 229 207 229;
#P connect 4 0 3 0;
#P connect 3 0 2 0;
#P connect 0 1 4 1;
#P connect 3 2 15 0;
#P fasten 14 0 15 0 293 392 237 392;
#P connect 15 0 13 0;
#P fasten 6 0 14 0 164 82 293 82;
#P window clipboard copycount 19;

[fe.nocut~.help] :

#P window setfont "Sans Serif" 10.;
#P window linecount 1;
#P comment 129 497 228 9109514 http://www.personal-computer-music.com;
#P comment 129 481 228 9109514 fe.nocut~ by f.e 2006;
#P comment 129 462 228 9109514 ___________________________________;
#P window setfont "Sans Serif" 9.;
#P message 183 218 26 9109513 stop;
#P newex 170 356 45 9109513 loadbang;
#P message 286 218 31 9109513 1000.;
#P user ezdac~ 50 481 94 514 0;
#P message 250 218 31 9109513 4500.;
#P message 218 218 26 9109513 500.;
#P message 133 218 44 9109513 startloop;
#B color 5;
#P message 178 104 26 9109513 stop;
#P message 237 105 90 9109513 setloop 4500. 8500.;
#P message 100 104 75 9109513 loop 1 , startloop;
#B color 5;
#P newex 48 104 36 9109513 sig~ 1.;
#P user gain~ 78 334 24 100 158 0 1.071519 7.94321 10.;
#P user gain~ 50 334 24 100 158 0 1.071519 7.94321 10.;
#P message 170 380 78 9109513 replace anton.aif;
#P newex 49 197 68 9109513 groove~ snd 2;
#P newex 170 406 96 9109513 buffer~ snd 10000. 2;
#P newex 49 268 67 9109513 fe.nocut~ 5;
#P window setfont "Sans Serif" 24.;
#P user com 20 19 116 9109528 5;
#K set 0 26213 11886 28515 30068 32256;
#K end;
#B frgb 255 255 255;
#P window setfont "Sans Serif" 9.;
#P user com 21 52 306 9109513 26;
#K set 0 26469 29728 29289 25632 28518 8309 28279 24942 29797 25632
25461 29811 8311 26725 28192 31087 29984 29285 29810 26983 26469 29216
28780 24953 25185 25451;
#K end;
#B frgb 255 255 255;
#P comment 122 269 153 9109513 arguments : (int / float) fade time;
#P user panel 15 11 366 61;
#X brgb 0 0 0;
#X frgb 0 0 0;
#X border 0;
#X rounded 0;
#X shadow 0;
#X done;
#P connect 7 0 5 0;
#P connect 19 0 7 0;
#P fasten 14 0 4 2 138 251 110 251;
#P fasten 15 0 4 2 223 251 110 251;
#P fasten 16 0 4 2 255 251 110 251;
#P fasten 18 0 4 2 291 251 110 251;
#P fasten 20 0 4 2 188 251 110 251;
#P connect 9 0 17 1;
#P connect 4 1 9 0;
#P hidden connect 8 1 9 0;
#P connect 6 1 4 1;
#P connect 8 0 17 0;
#P connect 4 0 8 0;
#P connect 6 0 4 0;
#P fasten 4 2 6 0 110 299 31 299 31 187 54 187;
#P connect 10 0 6 0;
#P fasten 11 0 6 0 105 187 54 187;
#P fasten 12 0 6 0 242 187 54 187;
#P fasten 13 0 6 0 183 187 54 187;
#P window clipboard copycount 24;

This is an example patch built from yours :

#P window setfont "Sans Serif" 10.;
#P window linecount 1;
#P newex 252 168 35 9109514 / 400.;
#P newex 295 90 56 9109514 ddg.mono;
#P message 341 216 27 9109514 stop;
#P newex 341 168 112 9109514 sel 0 1;
#P message 392 216 48 9109514 startloop;
#P newex 341 141 27 9109514 > 0;
#P newex 295 48 103 9109514 notein;
#P user gain~ 253 345 24 100 158 0 1.071519 7.94321 10.;
#P window setfont "Sans Serif" 9.;
#P newex 253 304 98 9109513 fe.nocut~ 5;
#P newex 252 216 36 9109513 sig~ 1.;
#P user ezdac~ 253 490 297 523 0;
#P message 73 279 98 9109513 replace DrumLoop.aif;
#P newex 73 302 85 9109513 buffer~ snd 10000;
#P newex 253 253 60 9109513 groove~ snd;
#P connect 0 0 5 0;
#P fasten 5 2 0 0 346 336 232 336 232 242 258 242;
#P connect 5 0 6 0;
#P fasten 9 0 5 2 397 270 346 270;
#P connect 11 0 5 2;
#P connect 13 0 4 0;
#P connect 12 0 13 0;
#P connect 12 1 8 0;
#P connect 7 1 12 1;
#P connect 7 0 12 0;
#P connect 10 0 11 0;
#P connect 10 1 9 0;
#P connect 8 0 10 0;
#P connect 4 0 0 0;
#P connect 6 0 3 0;
#P connect 6 0 3 1;
#P connect 2 0 1 0;
#P window clipboard copycount 14;

cheers

f.e

f.e chanfrault | aka | personal computer music
> >>>>>> http://www.personal-computer-music.com
> >>>>>> |sublime music for a desperate people|

Mattijs Kneppers wrote:
> Quote: bin wrote on Thu, 14 December 2006 19:28
> —————————————————-
>
>> so basically youre suggesting introducing a latency into the sampler to allow time to fade out. is this what the exs24 or kontakt or whatever does? how come you cant hear a latency in those instruments?
>>
>>
>
> I assume these samplers are all polyphonic, which means they will always start a newly triggered sample on a new voice (just like poly~), fading out the previous sample independently from the new one in its own release phase. This is a feature that of course uses more cpu power than a monophonic approach. If there would be only one voice I assume you’d get clicks.
>
> Mattijs
> –
> SmadSteck – http://www.smadsteck.nl
> Interactive audiovisual sampling soft- and hardware
>
>
>


December 17, 2006 | 5:02 pm

thanks!
that fe.nocut~ patch is just what i needed…


December 17, 2006 | 6:54 pm

use the pipe object to delay the midi note for 5ms or so, and have a bang go to the adsr~ to start from zero gain. Then the delayed midi note is processed.


December 18, 2006 | 9:31 pm

f.e wrote:
> Forget about adsr~, it’s not as good as it seems to be. Build your own
> enveloppe with line~ or, better, curve~. This last one will allow you to
> use a very handfull curve factor.

I completely agree, though I use cycle~ for fades, it just sounds so
much better…
(just to add another approach for enhanced confusion experience… ;-)

Stefan


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


December 20, 2006 | 3:39 am

> Forget about adsr~, it’s not as good as it seems to be. Build your own
> enveloppe with line~ or, better, curve~. This last one will allow you
> to use a very handfull curve factor.
>

Quick hack for exponential envelopes with adsr~:

adsr~
|
|
*~ (send the leftmost outlet of adsr~ into BOTH inlets of *~)

Now when you set the velocity for adsr~, presumably at control rate,
just take the square root before sending it in to adsr~. Same for
sustain point.
You can’t adjust the curve factor, but it definitely improves the sound
of adsr~ and it’s CPU cheap.

Also, if you’re using line~ and function (the graphical envelope
object) be sure to check "output only list for line~". This ensures
that it sends only one control-rate event rather than two, so the time
accuracy will be better. (try it both ways in a
line~-bang-when-done-loop and you’ll see…)

Peter McCulloch


December 20, 2006 | 12:41 pm

On 20-Dec-2006, at 4:39, Peter McCulloch wrote:

> Quick hack for exponential envelopes with adsr~:
>
> adsr~
> |
> |
> *~ (send the leftmost outlet of adsr~ into BOTH inlets of *~)

That’s not exponential, it’s parabolic. Those are two different animals.

A parabolic release curve is maybe better than linear, but don’t
pretend it’s the same as exponential.

————– http://www.bek.no/~pcastine/Litter/ ————-
Peter Castine +–> Litter Power & Litter Bundle for Jitter
Universal Binaries on the way
iCE: Sequencing, Recording &
Interface Building for |home | chez nous|
Max/MSP Extremely cool |bei uns | i nostri|
http://www.dspaudio.com/ http://www.castine.de


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