[PD] [vcf~] analyser (float32 rounding errors)

Claude Heiland-Allen claudiusmaximus at goto10.org
Fri Aug 27 04:13:16 CEST 2010


I like to use [vcf~] as a ringing/decaying oscillator, so I made a patch 
(attached) to analyse [vcf~], in the hope of feeding the analysis data 
to some surface-fitting software to find an equation for decay-time and 
peak amplitude from filter frequency and Q settings.

The patch is designed to be run in batch mode like:

$ pd -r 44100 -batch -open vcf_analyser.pd

with the output saved to "vcf_analysis.txt", so if you want to check out 
how it works then load it with 'pd -noloadbang'.  On my machine it takes 
a few minutes to analyse a few hours of audio.

But the output was really rather strange, with peaks and troughs where I 
didn't expect to see any (red in the attached graph of decay time in ms 
vs frequency in midi note numbers).

I suspected accumulating floating point rounding error might be to 
blame, so I did further testing, and it turns out that rounding error is 
indeed the cause: with a [vcf~] using 'double' internally instead of 
'float', the graph is *much* more regular (green in the attached graph).

Attached is the source code 'vcf~.c' modified from 
'pd-0.42-5/src/d_osc.c' source code, I compiled it on Linux with:

$ gcc -std=c99 -Wall -pedantic -O3 -fPIC -shared -o vcf~.pd_linux vcf~.c -lm

If you are using a version of Pd that supports aliasing internal objects 
(like recent Pd 'vanilla', but not Pd 'extended'), you can just use it 
by adding '-lib vcf~' to your Pd start command (or prefs).

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: vcf_analyser.pd
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20100827/bb7faff1/attachment-0001.asc>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vcf~_decay_time_32bit_vs_64bit.png
Type: image/png
Size: 61578 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20100827/bb7faff1/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vcf~.c
Type: text/x-csrc
Size: 2478 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20100827/bb7faff1/attachment-0001.c>

More information about the Pd-list mailing list