#N canvas 231 23 1061 650 12;
#X declare -stdpath ./;
#N canvas 305 163 433 432 samples 0;
#N canvas 0 0 450 300 (subpatch) 0;
#X array sample3 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 sample4 176403 float 0;
#X coords 0 1.02 176403 -1.02 200 130 1;
#X restore 138 212 graph;
#X restore 852 61 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 631 17 r note;
#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 text 851 106 record \, etc.;
#X text 340 203 allocate sampler voice;
#X text 366 228 drop note off again;
#X obj 684 455 qlist;
#X obj 558 436 r comment;
#X text 707 386 sailors to untie him..., f 39;
#X text 707 345 Lashed to the mast of his boat \, Ulysses;
#X text 707 366 hears beautiful singing. He begs his, f 39;
#X obj 559 348 output~;
#X text 263 175 supply delayed note-off message;
#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~ sample3;
#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 sample3 \, read ../sound/voice2.wav
sample4, f 33;
#X msg 378 155 read \$1 sample3;
#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 872 257 pd recorder;
#X msg 865 133 record 1;
#X msg 879 177 stop;
#X msg 872 155 record 2;
#X msg 885 199 reload;
#X msg 890 221 browse;
#X obj 856 302 declare -stdpath ./;
#X obj 617 262 pack f f f f f f f f;
#X obj 631 44 unpack f f f f f f f;
#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 with the [clone] object. 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 [clone] one to see how.;
#X obj 617 296 clone -s 1 sampvoice 8;
#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 [clone] routes to internal instances of the abstraction.;
#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 832 612 updated for Pd version 0.52;
#X msg 684 425 read qlist-sampler.txt \, rewind \, tempo 1 \, bang
;
#X obj 558 460 print comment;
#X msg 565 556 line 0 \, auto;
#X text 687 552 rewind and start automatically, f 16;
#X obj 881 567 text define -k seq;
#A set note 60 90 50 4 50 30 30 \; 15 note 60 \; 15 note 60 \; 15 note
60 \; 15 note 60 \; 15 note 60 \; 15 note 60 \; 15 note 60 \; 15 note
60 \; 15 note 60 \; 15 note 60 \; 15 note 60 \; 15 note 60 \; 15 note
60 \; 15 note 60 \; 15 note 60 \; 15 note 60 \; 15 note 60 \; 100 note
59 90 100 \; comment measure 1 \; 100 note 60 90 150 4 0 \; note 36
90 200 4 50 \; 200 note 48 90 250 4 0 \; note 40 90 200 4 50 \; note
43 90 200 4 50 \; 200 note 48 90 250 4 0 \; note 31 90 200 4 50 \;
200 note 55 90 100 \; note 41 90 200 \; note 43 90 200 \; 100 note
53 90 100 \; 100 note 52 90 100 \; note 36 90 200 \; 100 note 55 90
100 \; 100 note 60 90 100 \; note 40 90 200 \; note 43 90 200 \; 100
note 59 90 100 \; 100 note 60 90 100 \; note 25 90 200 \; 100 note
64 90 100 \; 100 note 62 90 100 \; note 39 90 200 \; note 43 90 200
\; 100 note 61 90 100 \; comment measure 2 \; 100 note 62 90 150 4
0 \; note 26 90 200 \; 200 note 50 90 250 4 50 \; note 41 90 200 \;
note 42 90 200 \; 200 note 50 90 250 \; note 29 90 200 \; 200 note
50 90 100 \; note 30 90 200 \; note 44 90 200 \; note 48 90 200 \;
100 note 48 90 100 \; 100 note 47 90 100 \; note 31 90 200 \; note
43 90 200 \; note 47 90 200 \; 100 note 50 90 100 \; 100 note 55 90
100 \; note 34 90 200 \; note 42 90 200 \; note 46 90 200 \; 100 note
54 90 100 \; 100 note 55 90 200 \; note 35 90 200 \; note 42 90 200
\; note 45 90 200 \; 200 note 57 90 100 \; note 41 90 200 \; note 47
90 200 \; 100 note 59 90 100 \; comment measure 3 \; 100 note 60 90
100 \; note 24 90 200 \; note 40 90 200 \; note 48 90 200 4 0 \; 100
note 59 90 100 4 50 \; 100 note 57 90 100 \; 100 note 55 90 100 \;
100 note 57 90 100 \; note 28 90 200 \; note 38 90 200 \; note 46 90
200 \; 100 note 55 90 100 \; 100 note 53 90 100 \; 100 note 52 90 100
\; 100 note 53 90 100 \; note 29 90 100 \; note 36 90 100 \; note 45
90 100 \; 100 note 52 90 100 \; 100 note 50 90 100 \; note 29 90 300
\; note 36 90 300 \; note 45 90 300 \; 100 note 48 90 100 \; 100 note
50 90 100 \; 100 note 48 90 100 \; 100 note 47 90 100 \; note 29 90
300 \; note 38 90 300 \; note 44 90 300 4 0 \; 100 note 45 90 100 4
50 \; comment measure 4 \; 100 note 43 90 100 \; note 31 90 200 \;
note 38 90 200 \; 100 note 48 90 100 \; 100 note 47 90 100 \; note
31 90 300 \; note 40 90 300 \; note 43 90 300 4 0 \; 100 note 50 90
100 4 50 \; 100 note 48 90 100 \; 100 note 52 90 100 \; 100 note 50
90 100 \; note 31 90 300 4 0 \; note 41 90 300 \; note 43 90 300 \;
100 note 53 90 100 4 50 \; 100 note 52 90 200 \; note 31 90 300 4 50
\; 200 note 48 90 200 \; note 19 90 200 4 50 \; note 29 90 200 4 50
\; note 36 90 200 4 50 \; 200 note 48 90 100 4 50 0 4000 \; note 12
90 300 \; note 28 90 300 \; note 36 90 300 \;;
#X obj 565 600 text sequence seq -g;
#X text 658 556 <--;
#X text 546 500 You can use [qlist] or the more modern [text sequence]
object \, which can save its contents with the patch., f 64;
#X text 893 541 click to open:;
#X connect 10 0 37 0;
#X connect 11 0 12 0;
#X connect 11 1 36 1;
#X connect 12 0 13 0;
#X connect 12 0 15 0;
#X connect 13 0 14 0;
#X connect 14 0 12 1;
#X connect 15 0 16 0;
#X connect 15 1 16 1;
#X connect 16 0 17 0;
#X connect 16 2 17 1;
#X connect 17 0 36 0;
#X connect 22 0 44 0;
#X connect 30 0 29 0;
#X connect 31 0 29 0;
#X connect 32 0 29 0;
#X connect 33 0 29 0;
#X connect 34 0 29 0;
#X connect 36 0 39 0;
#X connect 37 0 11 0;
#X connect 37 1 36 2;
#X connect 37 2 15 2;
#X connect 37 2 36 3;
#X connect 37 3 36 4;
#X connect 37 4 36 5;
#X connect 37 5 36 6;
#X connect 37 6 36 7;
#X connect 39 0 26 1;
#X connect 39 0 26 0;
#X connect 43 0 21 0;
#X connect 45 0 48 0;
