#N canvas 100 131 1082 657 12;
#N canvas 305 163 441 440 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 139 45 graph;
#X text 154 360 ------ 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 138 212 graph;
#X restore 867 81 pd samples;
#X text 65 81 ARGUMENTS FOR NOTES:;
#X text 85 110 pitch in halftones, f 21;
#X text 85 130 amplitude (dB), f 21;
#X text 85 169 sample number, f 21;
#X text 85 149 duration (msec), f 21;
#X text 85 189 start location (msec);
#X text 85 208 rise time (msec), f 21;
#X text 85 228 decay time (msec), f 21;
#X text 44 23 POLYPHONIC SAMPLER;
#X obj 547 329 sampvoice;
#X obj 631 17 r note;
#X obj 631 44 unpack 0 0 0 0 0 0 0;
#X obj 604 76 t b f;
#X obj 544 109 f;
#X obj 580 109 + 1;
#X obj 552 146 mod 1e+06;
#X obj 544 175 makenote 64;
#X obj 544 203 poly 8 1;
#X obj 544 230 stripnote;
#X obj 617 272 pack 0 0 0 0 0 0 0 0;
#X obj 617 300 route 1 2 3 4 5 6 7 8;
#X text 866 126 record \, etc.;
#X text 340 203 allocate sampler voice;
#X text 366 228 drop note off again;
#X obj 704 516 qlist;
#X obj 870 520 r comment;
#X text 727 447 sailors to untie him..., f 39;
#X text 727 406 Lashed to the mast of his boat \, Ulysses;
#X text 727 427 hears beautiful singing. He begs his, f 39;
#X text 48 271 Here we take the previous patch and make it polyphonic
\, with 8 voices. The single voice which we had before has been made
into an abstraction \, "sampvoice.pd" \, which we instantiate in 8
copies. Earlier we used sends and receives to pass messages to "cutoff"
\, etc \, but here if we did that the copies of sampvoice would be
sending messages to each other \, so we combine the control and the
audio computation in the sampvoice abstraction without using send and
receive. Click on one to see how.;
#X text 48 408 The "poly" object essentially repeats pitch and velocity
pairs to its output \, but also sending a voice number from its left
outlet. To use it \, we unpack the 7 parameters \, calculate the voice
number \, repack the message as 8 parameters with voice number first
\, and use "route" to send it to one of the 8 voices., f 60;
#X text 48 503 There's some bother because poly expects to track note
on and note off messages separately as they would come from a MIDI
keyboard. So we assign each note a unique fake "pitch" \, use makenote
to generate the note-off messages \, and run poly on the resulting
stream. We then discard both pitch and velocity (using the velocity
only to strip note-offs) and rebuild the original message adding the
voice number we just scored.;
#X text 830 588 updated for Pd version 0.33;
#X msg 704 486 read qlist-sampler.txt \, rewind \, tempo 1 \, bang
;
#X obj 547 556 output~;
#X text 263 175 supply delayed note-off message;
#X obj 547 522 sampvoice;
#X obj 547 494 sampvoice;
#X obj 547 467 sampvoice;
#X obj 547 439 sampvoice;
#X obj 547 412 sampvoice;
#X obj 547 384 sampvoice;
#X obj 547 356 sampvoice;
#X text 301 111 increment mod 1e+06 to make tag (acts like a MIDI pitch
to identify the note to "poly"), f 31;
#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 887 277 pd recorder;
#X msg 880 153 record 1;
#X msg 894 197 stop;
#X msg 887 175 record 2;
#X msg 900 219 reload;
#X msg 905 241 browse;
#X connect 10 0 43 0;
#X connect 11 0 12 0;
#X connect 12 0 13 0;
#X connect 12 1 20 2;
#X connect 12 2 17 2;
#X connect 12 2 20 3;
#X connect 12 3 20 4;
#X connect 12 4 20 5;
#X connect 12 5 20 6;
#X connect 12 6 20 7;
#X connect 13 0 14 0;
#X connect 13 1 20 1;
#X connect 14 0 15 0;
#X connect 14 0 17 0;
#X connect 15 0 16 0;
#X connect 16 0 14 1;
#X connect 17 0 18 0;
#X connect 17 1 18 1;
#X connect 18 0 19 0;
#X connect 18 2 19 1;
#X connect 19 0 20 0;
#X connect 20 0 21 0;
#X connect 21 0 10 1;
#X connect 21 1 43 1;
#X connect 21 2 42 1;
#X connect 21 3 41 1;
#X connect 21 4 40 1;
#X connect 21 5 39 1;
#X connect 21 6 38 1;
#X connect 21 7 37 1;
#X connect 34 0 25 0;
#X connect 37 0 35 0;
#X connect 37 0 35 1;
#X connect 38 0 37 0;
#X connect 39 0 38 0;
#X connect 40 0 39 0;
#X connect 41 0 40 0;
#X connect 42 0 41 0;
#X connect 43 0 42 0;
#X connect 46 0 45 0;
#X connect 47 0 45 0;
#X connect 48 0 45 0;
#X connect 49 0 45 0;
#X connect 50 0 45 0;
