[PD] convert an audio signal to floats at single audio sample precision

Derek Holzer macumbista at gmail.com
Sat Oct 15 19:06:53 CEST 2022


Hi Thomas,

thanks for your reply!

Yes I have tried re-[block~]ing the patch to 1 sample and using snapshot.

I have also tried using [tabsend~] at normal 64 sample block size, and 
then various means of reading out the samples from the table, including 
[until] and [timer].

I got close with using an integer-based counter [i]x[f] and then either 
resetting it or using a modulo. Both had their downsides.

The first patch, using a modulo [%] object to cycle from 0 to 63, 
startsed out very precise but degraded over time as the integer from the 
counter structure above it increases.

The second patch, using [select] to reset the counter and cycle from 0 
to 63, was far less accurate and gives periodic errors from the very start.

I thought that I had gotten it working with [block~] and [timer], but 
returning to that patch after a year I see that it does not in fact do 
it. I have attached the patch here for your scrutiny.

Best!
Derek


#N canvas 790 130 932 636 12;
#N canvas 399 190 1021 779 sig2float 0;
#X obj 37 27 inlet~ sig;
#X obj 157 27 inlet bang;
#X obj 157 260 outlet float;
#X text 377 225 Derek Holzer;
#X text 378 281 macumbista at gmail.com;
#N canvas 0 22 450 278 (subpatch) 0;
#X array \$0-sig 64 float 2;
#X coords 0 1 64 -1 200 140 1 0 0;
#X restore 380 58 graph;
#X obj 256 27 inlet IntExt;
#X obj 157 63 spigot;
#X obj 256 51 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1
1;
#X obj 157 223 tabread \$0-sig;
#X text 376 253 October 2021 Stockholm;
#X obj 160 101 bang~;
#X obj 159 145 timer 1 sample;
#X obj 40 223 tabread~ \$0-sig;
#X obj 39 256 outlet~ sig;
#X obj 256 73 switch~;
#X obj 37 63 tabsend~ \$0-sig;
#X connect 0 0 16 0;
#X connect 1 0 7 0;
#X connect 6 0 8 0;
#X connect 7 0 12 1;
#X connect 8 0 7 1;
#X connect 8 0 15 0;
#X connect 9 0 2 0;
#X connect 11 0 12 0;
#X connect 12 0 9 0;
#X connect 12 0 13 0;
#X connect 13 0 14 0;
#X restore 244 255 pd sig2float;
#X obj 285 172 metro;
#X obj 285 151 tgl 15 1 empty empty empty 17 7 0 10 -262144 -1 -1 1
1;
#X msg 305 147 tempo 1 samp;
#X obj 244 212 osc~ 440;
#X obj 325 213 tgl 15 1 empty empty empty 17 7 0 10 -262144 -1 -1 1
1;
#X obj 305 112 loadbang;
#X obj 53 359 cnv 15 210 219 empty empty empty 20 12 0 14 -4034 -66577
0;
#N canvas 0 22 450 300 (subpatch) 0;
#X array \$0-sum1 1001 float 0;
#X coords 0 1.02 1000 -1.02 200 50 1 0 0;
#X restore 55 376 graph;
#X obj 121 139 loadbang;
#X msg 116 162 1;
#X obj 175 319 tabwrite~ \$0-sum1;
#N canvas 0 22 450 300 (subpatch) 0;
#X array \$0-sum2 1001 float 0;
#X coords 0 1.02 1000 -1.02 200 50 1 0 0;
#X restore 56 441 graph;
#N canvas 0 22 450 300 (subpatch) 0;
#X array \$0-sum3 1001 float 0;
#X coords 0 1.1 1000 -1.1 200 50 1 0 0;
#X restore 56 506 graph;
#X obj 244 291 tabwrite~ \$0-sum2;
#X obj 325 320 tabwrite~ \$0-sum3;
#X obj 328 387 samplerate~;
#X floatatom 181 563 7 0 0 1 _ms-- #0-msin #0-msout;
#X obj 328 362 loadbang;
#X obj 98 185 metro 200;
#X obj 328 412 expr (1000 / $f1) * 1000;
#X obj 389 363 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
-1 -1;
#X text 43 562 -- 1000 samples or;
#X obj 328 441 s \$0-msin;
#X text 352 254 <------conversion from signal to float;
#X connect 0 0 14 0;
#X connect 0 1 15 0;
#X connect 1 0 0 1;
#X connect 2 0 1 0;
#X connect 3 0 1 0;
#X connect 4 0 0 0;
#X connect 4 0 11 0;
#X connect 5 0 0 2;
#X connect 6 0 3 0;
#X connect 9 0 10 0;
#X connect 10 0 19 0;
#X connect 16 0 20 0;
#X connect 18 0 16 0;
#X connect 19 0 11 0;
#X connect 19 0 14 0;
#X connect 19 0 15 0;
#X connect 20 0 23 0;
#X connect 21 0 16 0;


On 2022-10-15 18:37, Thomas Grill wrote:
> Hi Derek,
> not sure exactly whether you have covered this, but
> - what about a subpatch/abstraction with blocksize 1 and a [bang~]/[snapshot~] to deliver the sample?
> - or at normal blocksize a [tabsend~] and then [until] to read out the frames from the buffer?
> the physical timing will be more or less the same, because it all depends on the block input from the audio system.
> 
>  From what i read in your email, i guess you would like (with the timer) to have a physically correct timing.
> But this will never be the case. It is all in logical time, with all single-frame processing happening between blocks of (usually) 64 frames input from the audio IO.

-- 
Derek Holzer
noise.art.technology
http://macumbista.net





More information about the Pd-list mailing list