#N canvas 458 23 794 797 12;
#X msg 243 27 bang;
#X obj 243 64 delay 5;
#X text 419 290 end of note;
#X obj 372 55 r note;
#N canvas 282 191 671 441 recorder 0;
#X obj 218 34 inlet;
#X obj 128 258 adc~ 1;
#X obj 128 286 hip~ 5;
#X obj 197 316 line~;
#X obj 128 315 *~;
#X msg 197 288 1;
#X obj 256 253 del 3990;
#X msg 233 288 0 10;
#X obj 128 366 tabwrite~ sample1;
#X obj 42 191 makefilename sample%1;
#X msg 42 220 set \$1 \, bang;
#X msg 300 224 stop;
#X msg 256 224 bang;
#X obj 382 226 loadbang;
#X obj 378 128 openpanel;
#X msg 378 100 bang;
#X text 422 265 v-- re-read original samples;
#X obj 218 63 route record stop reload browse;
#X obj 382 347 soundfiler;
#X msg 382 289 read ../sound/bell.aiff sample1 \, read ../sound/voice2.wav
sample2, f 33;
#X msg 378 155 read \$1 sample1;
#X obj 378 182 soundfiler;
#X text 416 100 <= browse for samples;
#X connect 0 0 17 0;
#X connect 1 0 2 0;
#X connect 2 0 4 0;
#X connect 3 0 4 1;
#X connect 4 0 8 0;
#X connect 5 0 3 0;
#X connect 6 0 7 0;
#X connect 7 0 3 0;
#X connect 9 0 10 0;
#X connect 10 0 8 0;
#X connect 11 0 6 0;
#X connect 12 0 6 0;
#X connect 13 0 19 0;
#X connect 14 0 20 0;
#X connect 15 0 14 0;
#X connect 17 0 9 0;
#X connect 17 0 12 0;
#X connect 17 0 5 0;
#X connect 17 1 7 0;
#X connect 17 1 11 0;
#X connect 17 2 19 0;
#X connect 17 3 15 0;
#X connect 19 0 18 0;
#X connect 20 0 21 0;
#X restore 631 179 pd recorder;
#X msg 624 55 record 1;
#X msg 638 99 stop;
#N canvas 808 188 569 656 playback 0;
#X obj 57 60 line~;
#X obj 75 252 line~;
#X obj 57 283 *~;
#X obj 75 223 r cutoff;
#X obj 57 31 r phase;
#X obj 57 607 outlet~;
#X obj 57 579 hip~ 5;
#X obj 69 94 r sample-number;
#X obj 69 123 makefilename sample%d;
#X msg 69 151 set \$1;
#X obj 57 192 tabread4~ sample1;
#X obj 75 319 r envelope;
#X obj 75 377 dbtorms;
#X obj 75 406 sqrt;
#X obj 75 435 sqrt;
#X obj 75 463 line~;
#X obj 57 550 *~;
#X obj 75 492 *~;
#X obj 75 521 *~;
#X text 127 32 messages to the phase generating line~;
#X text 190 95 setting the sample number.;
#X text 230 123 compute the name;
#X text 124 150 and send a "set" message to the tabread4~.;
#X text 135 251 line~ for de-clicking;
#X text 167 309 The envelope generator. Rather than sending our message
straight to the line~ we unpack it in order to fool with the amplitude
field., f 45;
#X text 146 378 convert amplitude to linear units.;
#X text 141 407 take the fourth root. This because we want to raise
the line~'s output to the 4th power afterward. This is an inexpensive
way to give the rise and decay a more natural sounding evolution than
just a straight line., f 52;
#X text 112 505 square the output twice to get the fourth power.;
#X obj 75 348 unpack f f;
#X connect 0 0 10 0;
#X connect 1 0 2 1;
#X connect 2 0 16 0;
#X connect 3 0 1 0;
#X connect 4 0 0 0;
#X connect 6 0 5 0;
#X connect 7 0 8 0;
#X connect 8 0 9 0;
#X connect 9 0 10 0;
#X connect 10 0 2 0;
#X connect 11 0 28 0;
#X connect 12 0 13 0;
#X connect 13 0 14 0;
#X connect 14 0 15 0;
#X connect 15 0 17 0;
#X connect 15 0 17 1;
#X connect 16 0 6 0;
#X connect 17 0 18 0;
#X connect 17 0 18 1;
#X connect 18 0 16 1;
#X connect 28 0 12 0;
#X connect 28 1 15 1;
#X restore 467 656 pd playback;
#X msg 631 77 record 2;
#X text 50 272 ARGUMENTS FOR NOTES:;
#X text 81 294 pitch in halftones, f 21;
#X text 81 311 amplitude (dB), f 21;
#X text 81 345 sample number, f 21;
#X text 81 328 duration (msec), f 21;
#X text 81 362 start location (msec);
#X text 81 379 rise time (msec), f 21;
#X text 81 397 decay time (msec), f 21;
#X text 27 16 CHOCOLATE SAMPLER;
#X obj 491 188 f;
#X obj 442 162 f;
#X obj 373 162 f;
#X obj 336 162 f;
#X obj 304 162 f;
#X obj 227 162 f;
#X obj 227 189 mtof;
#X obj 227 217 / 261.62;
#X obj 227 244 * 4.41e+08;
#X obj 263 278 +;
#X obj 243 91 t b b b;
#X text 461 353 This starts the note \, sending to "receives" in the
playback subpatch. The new receive "envelope" is an amplitude control
in parallel with the cutoff control. The "sample-number" switches the
tabread4~ between tables., f 43;
#X obj 373 217 + 1;
#X msg 42 485 60 100 10000 1 0 0 0;
#X obj 57 747 s note;
#X msg 491 216 \; envelope 0 \$1;
#X msg 185 667 62;
#X msg 220 667 64;
#X msg 151 667 60;
#X msg 119 667 55;
#X msg 253 667 72;
#X msg 87 667 48;
#X msg 252 693 60.5;
#X msg 49 508 60 90 10000 1 0 0 0;
#X obj 373 189 * 44.1;
#X msg 74 598 60 100 100 1 0 0 0;
#X msg 78 621 60 100 100 1 0 0 1000;
#X msg 69 576 60 100 10000 1 0 1000 0;
#X msg 309 359 \; envelope 0 \, \$1 \$2 \; phase \$3 \, \$4 1e+07 \;
sample-number \$5 \; cutoff 1 5 \;;
#X msg 644 121 reload;
#X msg 649 143 browse;
#X text 418 311 combine amplitude \, rise time \, start phase \, end
phase \, and sample number in one message, f 43;
#X text 191 485 straight playback;
#X text 189 507 change amplitude;
#X text 204 529 change sample number;
#X text 230 552 change start location;
#X text 237 574 change rise time;
#X text 212 597 change duration;
#X text 233 619 ... and decay time;
#X text 289 693 microtones OK too.;
#X text 90 643 If you omit values they stay unchanged;
#X obj 467 693 output~;
#X text 566 725 updated for Pd version 0.37;
#X text 688 55 <= record;
#X obj 372 82 unpack f f f f f f f;
#X obj 309 322 pack f f f f f;
#X text 25 157 transposition works by altering the phase target (\$4
below right.) The mtof and / 261 calculate speed change considering
60 as unity., f 26;
#X text 39 70 as before we mute and wait, f 13;
#X text 31 442 These demonstrate the effect of varying the parameters
one by one., f 34;
#X obj 478 162 del;
#X text 409 470 This patch takes the same principle as the earlier
"one-shot sampler" \, but allows you to parameterize sample playback.
Since we must wait 5 msec before starting the playback \, we store
all the parameters in "f" objects \, and recall them to construct the
new note. Transposition is done by altering the amount to play back
in the (artificial) ten thousand seconds (1e+07). The playback segment
can be altered to start in the middle of the sample instead of the
beginning \, and you can change the duration and rise and decay times.
, f 50;
#X msg 62 552 60 100 10000 1 3000 0 0;
#X msg 56 530 60 100 10000 2 0 0 0;
#X msg 139 69 \; cutoff 0 5;
#N canvas 305 163 336 422 samples 0;
#N canvas 0 0 450 300 (subpatch) 0;
#X array sample1 176403 float 0;
#X coords 0 1.02 176403 -1.02 200 130 1;
#X restore 71 36 graph;
#X text 86 351 ------ 4 seconds ------;
#N canvas 0 0 450 300 (subpatch) 0;
#X array sample2 176403 float 0;
#X coords 0 1.02 176403 -1.02 200 130 1;
#X restore 70 203 graph;
#X restore 635 223 pd samples;
#X connect 0 0 1 0;
#X connect 0 0 71 0;
#X connect 1 0 28 0;
#X connect 3 0 62 0;
#X connect 5 0 4 0;
#X connect 6 0 4 0;
#X connect 7 0 59 0;
#X connect 7 0 59 1;
#X connect 8 0 4 0;
#X connect 18 0 33 0;
#X connect 19 0 63 1;
#X connect 20 0 42 0;
#X connect 21 0 63 4;
#X connect 22 0 63 0;
#X connect 23 0 24 0;
#X connect 24 0 25 0;
#X connect 25 0 26 0;
#X connect 26 0 27 0;
#X connect 27 0 63 3;
#X connect 28 0 22 0;
#X connect 28 1 23 0;
#X connect 28 2 19 0;
#X connect 28 2 20 0;
#X connect 28 2 21 0;
#X connect 28 2 67 0;
#X connect 30 0 27 1;
#X connect 30 0 63 2;
#X connect 31 0 32 0;
#X connect 34 0 32 0;
#X connect 35 0 32 0;
#X connect 36 0 32 0;
#X connect 37 0 32 0;
#X connect 38 0 32 0;
#X connect 39 0 32 0;
#X connect 40 0 32 0;
#X connect 41 0 32 0;
#X connect 42 0 30 0;
#X connect 43 0 32 0;
#X connect 44 0 32 0;
#X connect 45 0 32 0;
#X connect 47 0 4 0;
#X connect 48 0 4 0;
#X connect 62 0 23 1;
#X connect 62 0 0 0;
#X connect 62 1 22 1;
#X connect 62 2 67 1;
#X connect 62 3 21 1;
#X connect 62 4 20 1;
#X connect 62 5 19 1;
#X connect 62 6 18 1;
#X connect 63 0 46 0;
#X connect 67 0 18 0;
#X connect 69 0 32 0;
#X connect 70 0 32 0;
