[PD-dev] signal external and IOhannes's tutorial

Adam T. Lindsay atl at comp.lancs.ac.uk
Wed Sep 25 16:16:05 CEST 2002


Olaf, thanks for your reply.

I'll continue to flaunt my ignorance on the public list with my reply...

Olaf Matthes said this at Wed, 25 Sep 2002 15:32:13 +0200:

>"Adam T. Lindsay" schrieb:
>
>> >Optimization of the DSP-tree tries to avoid unnecessary copy-operations.
>> >Therefore it is possible, that in- and out-signal are located at the same
>> >address in the memory. In this case, the programmer has to be careful not
>> >to write into the out-signal before having read the in-signal to avoid
>> >overwriting data that is not yet saved.
>>
>> <http://iem.kug.ac.at/pd/externals-HOWTO/
>> node6.html#SECTION00065000000000000000>
>>
>> To me, this is a bit ambiguous (and my German officemate couldn't help
>> with the lang-de version). Who does the optimization?
>
>Pd does. It uses 'the same address in memory'. Thus you have to read in a
>sample before writing a sample. Writing just overwrites the input samples...
>In case you want 'silence' you have to set all samples to 0. Otherwise you
>would hear your input signal!
>
>Using this method saves a lot of memory allocation.

Thanks. That's clear now. 
I guess I'm now confused by sending pointers to each "in" and "out"
buffer, but I can sort of see the rationale.

But more importantly, how do I pass these pointers to enforce an in-place
computation on the part of the signal processing network? Should I do
something that looks "wrong," like:

void inPlace_dsp(t_inPlace *x, t_signal **sp)
{
  dsp_add(inPlace_perform, 4, x,
          sp[0]->s_vec, sp[0]->s_vec, sp[0]->s_n); // in and out are the same
}

t_int *inPlace_perform(t_int *w)
{
  t_inPlace *x = (t_inPlace *)(w[1]);
  t_sample  *in =    (t_sample *)(w[2]);
  t_sample  *out =    (t_sample *)(w[2]);
  int          n =           (int)(w[3]);
/*
    etc...
*/
  return (w+6);
}

Thanks for the help,
adam


-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Adam T. Lindsay                      atl at comp.lancs.ac.uk
 Computing Dept, Lancaster University   +44(0)1524/594.537
 Lancaster, LA1 4YR, UK             Fax:+44(0)1524/593.608
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-





More information about the Pd-dev mailing list