#N canvas 370 60 747 726 12;
#X declare -stdpath ./;
#N canvas 0 0 450 300 (subpatch) 0;
#X array sample-table 48003 float 2;
#A color 0;
#A width 2;
#X coords 0 1.02 48003 -1.02 259 147 1 0 0;
#X restore 460 213 graph;
#X obj 72 450 tabread4~ sample-table;
#X obj 72 392 line~;
#X floatatom 72 205 7 0 100 0 - - - 0;
#X obj 220 498 loadbang;
#X text 77 672 For more on reading and writing soundfiles to tables \, setting their lengths \, etc \, see "arrays" in the "control examples" series., f 85;
#X text 121 392 convert smoothly to audio signal;
#X text 136 223 (range is 0-100.) YOU ONLY HEAR OUTPUT;
#X text 135 241 WHEN THIS IS 0-100 AND ACTIVELY CHANGING.;
#X msg 220 524 read ../sound/voice.wav sample-table;
#X obj 220 552 soundfiler;
#X obj 72 508 output~;
#X obj 554 27 declare -stdpath ./;
#X obj 72 291 pack f 100;
#X text 129 205 <-- read point in 100ths of a second, f 39;
#X listbox 72 321 15 0 0 0 - - - 0;
#X text 243 442 read from the table (the input is the index in samples), f 30;
#X obj 66 23 cnv 5 5 25 empty empty Scratch\ Machine 15 13 0 16 #dfdfdf #202020 0;
#X text 490 517 message to read a soundfile into the table., f 27;
#X msg 91 357 0 \, 48000 1000;
#X obj 72 419 +~ 1;
#X text 39 70 This patch implements a simples scratch machine with [tabread4~] \, which reads audio samples out of a floating-point array \, often called a "sample table." The input is the index of the sample to read. The output is calculated using 4-point cubic interpolation \, which is adequate for most purposes. Because of the interpolation scheme \, [tabread4~]'s input cannot be less than one or greater than the table length minus two., f 96;
#X text 490 397 (one second plus three extra for 4-point interpolation), f 28;
#X text 195 356 read the whole one second;
#X obj 75 172 hsl 162 19 0 100 0 0 empty empty empty -2 -10 0 12 #dfdfdf #000000 #000000 0 1;
#X text 252 172 <-- move for scratching;
#X text 315 552 Note this doesn't make copies for extra points \, so we effectively loose 3 samples and fail to perform a perfect wrapping loop. Nonetheless \, this is not a significant issue for playing samples., f 52;
#X text 188 314 sample destination and line duration, f 18;
#X text 113 418 add one to avoid beginning of table;
#X obj 72 263 * 480;
#X text 515 368 --- 48003 samples ---;
#X text 77 624 Fanatics take note: if you want really high-fidelity sampling \, use a high-quality resampling program to up-sample your soundfile to 96000 to drastically reduce interpolation error., f 85;
#X text 119 263 convert to SAMPLES (480 samples in 0.01 sec);
#X connect 1 0 11 0;
#X connect 2 0 20 0;
#X connect 3 0 29 0;
#X connect 4 0 9 0;
#X connect 9 0 10 0;
#X connect 13 0 15 0;
#X connect 15 0 2 0;
#X connect 19 0 2 0;
#X connect 20 0 1 0;
#X connect 24 0 3 0;
#X connect 29 0 13 0;
