#N canvas 12 0 1074 786 12;
#X msg 257 7 bang;
#X obj 257 35 delay 5;
#X text 497 269 end of note;
#X obj 363 35 r note;
#N canvas 459 46 678 451 samples 0;
#N canvas 0 0 450 300 graph1 0;
#X array sample1 176403 float 0;
#X coords 0 1.02 176403 -1.02 200 130 1;
#X restore 262 41 graph;
#X text 264 376 ------ 4 seconds ------;
#N canvas 0 0 450 300 graph1 0;
#X array sample2 176403 float 0;
#X coords 0 1.02 176403 -1.02 200 130 1;
#X restore 262 226 graph;
#X restore 33 277 pd samples;
#N canvas 21 287 947 410 recorder 0;
#X obj 318 43 inlet;
#X obj 272 196 adc~ 1;
#X obj 272 224 hip~ 5;
#X obj 341 254 line~;
#X obj 272 253 *~;
#X msg 341 226 1;
#X obj 400 191 del 3990;
#X msg 377 226 0 10;
#X obj 272 304 tabwrite~ sample1;
#X obj 124 110 makefilename sample%1;
#X msg 124 139 set \$1 \, bang;
#X msg 446 162 stop;
#X msg 400 162 bang;
#X obj 557 182 loadbang;
#X obj 660 137 openpanel;
#X msg 660 109 bang;
#X text 702 108 <-- browse for samples;
#X text 628 233 v-- re-read original samples;
#X obj 318 72 route record stop reload browse;
#X obj 557 319 soundfiler;
#X msg 557 261 read ../sound/bell.aiff sample1 \, read ../sound/voice2.wav
sample2;
#X msg 660 164 read \$1 sample1;
#X obj 660 191 soundfiler;
#X connect 0 0 18 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 20 0;
#X connect 14 0 21 0;
#X connect 15 0 14 0;
#X connect 18 0 9 0;
#X connect 18 0 12 0;
#X connect 18 0 5 0;
#X connect 18 1 7 0;
#X connect 18 1 11 0;
#X connect 18 2 20 0;
#X connect 18 3 15 0;
#X connect 20 0 19 0;
#X connect 21 0 22 0;
#X restore 33 443 pd recorder;
#X msg 33 305 record 1;
#X msg 33 360 stop;
#N canvas 359 226 666 626 playback 0;
#X obj 20 45 line~;
#X obj 39 237 line~;
#X obj 20 268 *~;
#X obj 39 208 r cutoff;
#X obj 20 16 r phase;
#X obj 20 592 outlet~;
#X obj 20 564 hip~ 5;
#X obj 32 79 r sample-number;
#X obj 32 108 makefilename sample%d;
#X msg 32 136 set \$1;
#X obj 20 177 tabread4~ sample1;
#X obj 38 304 r envelope;
#X obj 38 362 dbtorms;
#X obj 38 333 unpack;
#X obj 38 391 sqrt;
#X obj 38 420 sqrt;
#X obj 38 448 line~;
#X obj 20 535 *~;
#X obj 38 477 *~;
#X obj 38 506 *~;
#X text 90 17 messages to the phase generating line~;
#X text 171 80 setting the sample number.;
#X text 221 109 compute the name;
#X text 93 137 and send a "set" message to the tabread4~.;
#X text 99 236 line~ for de-clicking;
#X text 139 307 The envelope generator. Rather than sending our message
straight to the line~ we unpack it in order to fool with the amplitude
field.;
#X text 109 363 convert amplitude to linear units.;
#X text 104 392 take the fourth root. This because we want to raies
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.;
#X text 77 480 square the output twice to get the fourth power.;
#X connect 0 0 10 0;
#X connect 1 0 2 1;
#X connect 2 0 17 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 13 0;
#X connect 12 0 14 0;
#X connect 13 0 12 0;
#X connect 13 1 16 1;
#X connect 14 0 15 0;
#X connect 15 0 16 0;
#X connect 16 0 18 0;
#X connect 16 0 18 1;
#X connect 17 0 6 0;
#X connect 18 0 19 0;
#X connect 18 0 19 1;
#X connect 19 0 17 1;
#X restore 33 480 pd playback;
#X msg 33 332 record 2;
#X text 645 25 ARGUMENTS FOR NOTES:;
#X text 666 53 pitch in halftones;
#X text 666 77 amplitude (dB);
#X text 666 125 sample number;
#X text 666 101 duration (msec);
#X text 666 149 start location (msec);
#X text 666 173 rise time (msec);
#X text 666 197 decay time (msec);
#X obj 363 62 unpack 0 0 0 0 0 0 0;
#X text 50 6 CHOCOLATE SAMPLER;
#X obj 521 168 f;
#X obj 456 142 f;
#X obj 387 142 f;
#X obj 350 142 f;
#X obj 318 142 f;
#X obj 224 142 f;
#X obj 224 169 mtof;
#X obj 224 197 / 261.62;
#X obj 224 224 * 4.41e+08;
#X obj 224 252 +;
#X obj 489 142 delay;
#X obj 318 312 pack 0 0 0 0 0;
#X obj 257 62 t b b b;
#X text 498 346 This starts the note \, sending to "receives" in the
playback subptach. The new receive "envelope" is an amplitude control
in parallel with the cutoff control. The "sample-number" switches the
tabread4~ between tables.;
#X msg 156 44 \; pd dsp 1 \; cutoff 0 5;
#X obj 387 197 + 1;
#X msg 556 467 60 100 10000 1 0 0 0;
#X obj 556 737 s note;
#X msg 521 196 \; envelope 0 \$1;
#X msg 675 691 62;
#X msg 710 691 64;
#X msg 641 691 60;
#X msg 612 691 55;
#X msg 743 691 72;
#X msg 580 691 48;
#X msg 642 734 60.5;
#X msg 556 494 60 90 10000 1 0 0 0;
#X msg 556 522 60 100 10000 2 0 0 0;
#X msg 556 550 60 100 10000 1 3000 0 0;
#X obj 387 169 * 44.1;
#X msg 556 605 60 100 100 1 0 0 0;
#X msg 556 632 60 100 100 1 0 0 1000;
#X msg 556 577 60 100 10000 1 0 1000 0;
#X msg 318 340 \; envelope 0 \, \$1 \$2 \; phase \$3 \, \$4 1e+07 \;
sample-number \$5 \; cutoff 1 5 \;;
#X text 117 305 <-- record;
#X msg 33 388 reload;
#X msg 33 415 browse;
#X text 7 109 transposition works;
#X text 7 133 by altering the phase;
#X text 7 181 The mtof and / 261;
#X text 7 205 calculate speed change;
#X text 7 229 considering 60 as unity.;
#X text 24 43 as before we;
#X text 15 64 mute and wait;
#X text 7 157 target ($4 below right.);
#X text 450 303 combine amplitude \, rise time \, start phase \, end
phase \, and sample number in one message;
#X text 764 467 straight playback;
#X text 764 493 change amplitude;
#X text 767 521 change sample number;
#X text 769 550 change start location;
#X text 768 576 change rise time;
#X text 768 609 change duration;
#X text 769 633 ... and decay time;
#X text 692 736 microtones OK too.;
#X text 580 667 If you omit values they stay unchanged;
#X text 552 426 Here are buttons to demonstrate the effect of varying
the parameters one by one.;
#X obj 34 511 output~;
#X text 13 596 This patch take the same principle as the earlier "one-shot
sampler" \, but allows you to parametrize 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.;
#X text 823 763 updated for Pd version 0.37;
#X connect 0 0 1 0;
#X connect 0 0 34 0;
#X connect 1 0 32 0;
#X connect 3 0 18 0;
#X connect 6 0 5 0;
#X connect 7 0 5 0;
#X connect 8 0 76 0;
#X connect 8 0 76 1;
#X connect 9 0 5 0;
#X connect 18 0 25 1;
#X connect 18 0 0 0;
#X connect 18 1 24 1;
#X connect 18 2 30 1;
#X connect 18 3 23 1;
#X connect 18 4 22 1;
#X connect 18 5 21 1;
#X connect 18 6 20 1;
#X connect 20 0 38 0;
#X connect 21 0 31 1;
#X connect 22 0 49 0;
#X connect 23 0 31 4;
#X connect 24 0 31 0;
#X connect 25 0 26 0;
#X connect 26 0 27 0;
#X connect 27 0 28 0;
#X connect 28 0 29 0;
#X connect 29 0 31 3;
#X connect 30 0 20 0;
#X connect 31 0 53 0;
#X connect 32 0 24 0;
#X connect 32 1 25 0;
#X connect 32 2 21 0;
#X connect 32 2 22 0;
#X connect 32 2 23 0;
#X connect 32 2 30 0;
#X connect 35 0 31 2;
#X connect 35 0 29 1;
#X connect 36 0 37 0;
#X connect 39 0 37 0;
#X connect 40 0 37 0;
#X connect 41 0 37 0;
#X connect 42 0 37 0;
#X connect 43 0 37 0;
#X connect 44 0 37 0;
#X connect 45 0 37 0;
#X connect 46 0 37 0;
#X connect 47 0 37 0;
#X connect 48 0 37 0;
#X connect 49 0 35 0;
#X connect 50 0 37 0;
#X connect 51 0 37 0;
#X connect 52 0 37 0;
#X connect 55 0 5 0;
#X connect 56 0 5 0;
