[PD] how to iterate over left and right channel separately in one Pd class?

Miller Puckette msp at ucsd.edu
Fri Jan 11 19:57:13 CET 2013


Hi Katja -

There's one example of this in sigfft_dspx() - a complex FFT that 'natively'
works on 2 signals in-place but has to deal with various cases in which
buffers get re-used.  It's ugly but the basic idea is first to get the
inputs copied to the outputs (unless they're already there in the correct
order in which case nothing needs to be done) and then run the in-place
algorithm.

If the algo only works out-of-place (i.e. you need 4 distinct buffers, 2
in and 2 out) the only way out is (at least conditionally) allocate temporary
copies of the inputs before writing to any outputs.

I may be able to add an optional way tilde objects can request that output
buffers be distinct from input ones sometime in the future - but this is a
couple of steps away for me right now :)

M

On Fri, Jan 11, 2013 at 03:32:09PM +0100, katja wrote:
> Hello,
> 
> I'm working on a Pd class with stereo channels (reverb), and the
> routine happens to be most efficient when iterating over the samples
> per channel, instead of left and right together in the perform loop.
> However, when doing two while loops in one object, one for left and
> one for right, the right channel samples get overwritten because of
> sample-wise in-place computation. Is this an inescapable truth? I
> mean, I could write a left channel class and a right channel class
> (actually did that to verify that it works), but it's inconvenient to
> use. What could be an efficient way to get them in one object?
> 
> Thanks,
> Katja
> 
> _______________________________________________
> Pd-list at iem.at mailing list
> UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list



More information about the Pd-list mailing list