#N canvas 433 61 664 634 12;
#X declare -stdpath ./;
#X text 34 51 Pd is usually compiled to work on 32-bit audio samples.
These do not \, in general \, have enough precision for use as indices
into an array of more than about 32K samples. This is because the mantissa
of a 32-bit floating point number has only 24 bits \, out of which
you would be using 16 bits or more to address a sample more than 32K
into the array \, so there would remain 8 or fewer bits to supply the
fraction. In the most extreme situation possible \, the sample could
contain a Nyquist frequency sinusoid and the output would then have
only about 8 bits of accuracy!, f 85;
#X text 34 161 You can use the "onset" inlet to tabread4~ to get good
accuracy reading longer arrays. The tabread4~ object adds the index
and the "main" (signal) inlet in 64-bit precision. So if \, for example
\, the onset inlet could specify an integer exactly up to about 8 million
(190 seconds at 44100 Hz) \, and the signal inlet could act as a displacement.
, f 85;
#X text 56 11 USING ONSETS INTO TABREAD4~ TO IMPROVE ACCURACY;
#X obj 60 512 output~;
#X obj 407 428 samplerate~;
#X obj 407 452 / 2;
#X obj 394 505 tabwrite~ \$0-tab;
#X obj 60 478 tabread4~ \$0-tab;
#X obj 407 476 osc~;
#X obj 191 478 tabread4~ \$0-tab;
#X obj 191 512 output~;
#X obj 60 395 *~ 10000;
#X obj 60 448 +~;
#X floatatom 300 397 6 0 0 0 - - - 0;
#X msg 300 367 1;
#X obj 394 545 table \$0-tab 200000;
#X obj 60 366 phasor~ 0.02;
#X msg 245 367 150001;
#X text 34 240 At left below an onset (1 or 150000 samples) is added
to the index of a table lookup. If you select the onset of 150001 \,
you should hear the truncation error. (The table contains a Nyquist
signal and the "correct" output should be a 100 Hz. tone.) At right
\, the onset is presented in the separate onset inlet. The worst-case
truncation error drops by about 30 dB., f 85;
#X text 76 572 BAD;
#X text 208 569 GOOD;
#X text 246 346 ONSET INTO TABLE;
#X obj 423 12 declare -stdpath ./;
#X text 422 341 First \, generate the table:;
#X msg 418 379 \; pd dsp 1 \, fast-forward 4500;
#X text 404 597 updated for Pd version 0.52;
#X obj 394 341 bng 17 250 50 0 empty empty empty 17 7 0 10 #dfdfdf
#000000 #000000;
#X connect 4 0 5 0;
#X connect 5 0 8 0;
#X connect 7 0 3 0;
#X connect 7 0 3 1;
#X connect 8 0 6 0;
#X connect 9 0 10 0;
#X connect 9 0 10 1;
#X connect 11 0 12 0;
#X connect 11 0 9 0;
#X connect 12 0 7 0;
#X connect 13 0 9 1;
#X connect 13 0 12 1;
#X connect 14 0 13 0;
#X connect 16 0 11 0;
#X connect 17 0 13 0;
#X connect 26 0 4 0;
#X connect 26 0 6 0;
#X connect 26 0 24 0;
