[PD] I'm stuck in a corner, please help! RE: [delta~] object

Claude Heiland-Allen claudiusmaximus at goto10.org
Fri Mar 21 23:01:42 CET 2008


Hi,

Using the source:

pd/src/d_filter.c/sigrzero_perform()

         t_sample next = *in1++;
         t_sample coef = *in2++;
         *out++ = next - coef * last;
         last = next;


pure-data/externals/cxc/delta~.c/delta_perform()

       float f = *(in++);
       // *out++ = (f > 0 ? f : -f);	
       *out++ = (f > x->x_last ? fabs(f - x->x_last) : -fabs(f - 
x->x_last));
       x->x_last = f;

which mathematically translates thus:

     f>l ? |f-l| : -|f-l|
==
     f>l ? f-l : -|f-l|  (f>l => f-l > 0 => |f-l| == f-l)
==
     f>l ? f-l : f-l  (f<=l => f-l <= 0 => |f-l| == l-f)
==
     f-l

which is entirely equivalent to rzero~ when coef is 1.


BUT: IEEE floating point doesn't respect normal mathematical rules, so 
weird stuff is probably going on in delta~...


Hope this helps, personally I wouldn't want to use delta~ given the 
weirdness of its code (eg, using float instead of t_sample, using 
comparisons, using fabs() (which converts to double and back, iirc), 
etc) but there might be some reason for it that I can't fathom, similar 
to Miller's tabfudge stuff in phasor~ making it 5x-10x faster than my 
naive implementation.


Claude

Andy Farnell wrote:
> 
> I've put an example here so you can hear that they are not the same
> 
> These differences are important.
> 
> 
> [rzero~] and [delwrite~] methods come out louder
> and with apparently less dynamics. Using [z~] and [fexpr~]
> I get much closer results to [delta~], more detail in
> the poured water sound.
> 
> As I said I needed an _EXACT_ replacement for [delta~] for
> other patches too, which are much more sensitive to the
> differences. (so this is all about how it behaves in practice
> not in theory :)
> 
> I'm really not sure why this happens. Suppose I should hook
> them up to a graph and read sample by sample to see what's
> really going on. But, it doesn't help me because without 
> changing the source the fact is
> 
> [delta~] is the same as [z~]
> [z~] is as good as [fexpr~]
> [rzero~ 1] and [delwrite~] are not the same
> 
> 
> Unless... If you hear no difference it could be an architecture
> thing... Tell me what machines you're running on, I wonder if that
> has anything to do with it?
> 
> cheers,
> 
> Andy
> 
> 
> 
> 
> 
> On Fri, 21 Mar 2008 10:47:44 +0100
> Frank Barknecht <fbar at footils.org> wrote:
> 
>> Hallo,
>> Miller Puckette hat gesagt: // Miller Puckette wrote:
>>
>>> If I'm doing it for myself, I run sig~ into rzero~ 1.
>> For all I know, [rzero~ 1] is the same as [delta~]: Both compute the
>> difference between the current and the previous sample. Or am I
>> missing something? Some time ago I added this to the CVS (now SVN) as
>> abstractions/purepd/delta~.pd
>>
>> Ciao
>> -- 
>>  Frank Barknecht                                     _ ______footils.org__
>>
>> _______________________________________________
>> PD-list at iem.at mailing list
>> UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> PD-list at iem.at mailing list
> UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list

-- 
http://claudiusmaximus.goto10.org




More information about the Pd-list mailing list