#N canvas 401 67 816 663 12;
#X declare -stdpath ./;
#N canvas 0 0 450 300 (subpatch) 0;
#X array cos-output 24000 float 2;
#A color 0;
#A width 2;
#X coords 0 1.02 24000 -1.02 200 130 1 0 0;
#X restore 510 201 graph;
#N canvas 0 0 450 300 (subpatch) 0;
#X array table18 48003 float 2;
#A color 0;
#A width 2;
#X coords 0 1.02 48003 -1.02 200 130 1;
#X restore 507 26 graph;
#X obj 509 530 loadbang;
#X floatatom 142 70 6 0 0 0 - \$0-freq - 0;
#X floatatom 225 127 7 0 1000 0 - - - 0;
#X obj 207 203 +~ 1;
#X obj 529 373 adc~ 1;
#X obj 142 179 -~ 0.5;
#X obj 142 239 cos~;
#X obj 142 272 *~;
#X obj 509 584 soundfiler;
#X obj 142 97 phasor~;
#X obj 142 204 *~ 0.5;
#X obj 142 363 output~;
#X obj 207 178 *~;
#X text 35 611 It is possible to get much more control over the shape of the envelope \, but this will be taken up later., f 61;
#X obj 207 229 tabread4~ table18;
#X obj 529 478 tabwrite~ table18;
#X msg 509 559 read ../sound/voice.wav table18;
#X text 567 423 <-- click here to record to table, f 17;
#X text 575 538 v-- re-read the original sound;
#X text 191 69 <-- frequency (Hz.);
#X obj 544 422 bng 19 250 50 0 empty empty empty 17 7 0 10 #dfdfdf #000000 #000000;
#X text 35 452 Here we apply an amplitude envelope to protect against discontinuities at the loop point. The envelope is just a cosine wave from -90 degrees to +90 degrees \, (-pi/2 to pi/2 radians) \, i.e. \, the part that is zero or positive in sign. The [cos~] object's input is in cycles (units of 2pi radians) so -1/4 to +1/4 addresses the desired part of the waveform., f 61;
#X obj 53 14 cnv 5 5 25 empty empty Enveloping\ your\ Looping\ Sampler 15 13 0 16 #dfdfdf #202020 0;
#X text 281 126 <-- chunk size (ms);
#X obj 206 265 bng 19 250 50 0 empty empty empty 17 7 0 10 #dfdfdf #000000 #000000;
#X text 229 264 <-- graph once;
#X obj 233 292 tgl 19 0 empty empty empty 0 -10 0 12 #dfdfdf #000000 #000000 0 1;
#X text 257 291 <-- graph repeatedly, f 10;
#N canvas 146 130 450 300 graph 0;
#X obj 256 73 inlet;
#X obj 192 73 inlet;
#X obj 122 73 inlet~;
#X obj 256 137 metro 550;
#X obj 192 203 tabwrite~ cos-output;
#X connect 0 0 3 0;
#X connect 1 0 4 0;
#X connect 2 0 4 0;
#X connect 3 0 4 0;
#X restore 180 325 pd graph;
#X text 529 335 ----- 0.5 second ------;
#N canvas 817 451 319 293 init 0;
#X obj 80 94 loadbang;
#X obj 80 182 s \$0-freq;
#X obj 162 182 s \$0-size;
#X msg 162 144 250;
#X msg 80 138 5;
#X text 57 23 This subpatch initializes the patch and loads values in number boxes., f 29;
#X obj 93 230 declare -stdpath ./;
#X connect 0 0 4 0;
#X connect 0 0 3 0;
#X connect 3 0 2 0;
#X connect 4 0 1 0;
#X restore 367 179 pd init;
#X text 35 542 To see the envelope \, put the [phasor~] on 5 Hz or so \, click the "graph" button \, and look at "cos-output." This is multiplied by the [tabread4~] output so that it doesn't click when the phase wraps around., f 61;
#X text 37 179 -1/2 to +1/2;
#X text 37 204 -1/4 to +1/4;
#X obj 228 100 hsl 162 19 0 1000 0 0 empty \$0-size empty -2 -10 0 12 #dfdfdf #000000 #000000 0 1;
#X text 538 158 -- 48003 samples ---;
#X obj 225 154 * 48;
#X connect 2 0 18 0;
#X connect 3 0 11 0;
#X connect 4 0 38 0;
#X connect 5 0 16 0;
#X connect 6 0 17 0;
#X connect 7 0 12 0;
#X connect 8 0 9 0;
#X connect 9 0 30 0;
#X connect 9 0 13 0;
#X connect 11 0 14 0;
#X connect 11 0 7 0;
#X connect 12 0 8 0;
#X connect 14 0 5 0;
#X connect 16 0 9 1;
#X connect 18 0 10 0;
#X connect 22 0 17 0;
#X connect 26 0 30 1;
#X connect 28 0 30 2;
#X connect 36 0 4 0;
#X connect 38 0 14 1;
