[PD-dev] Variable amount of signal inlets and outlets

Christof Ressi info at christofressi.com
Sat May 23 12:57:34 CEST 2020


Other examples would be zexy's [mux~] and [demux~].

> is there a reason that cyclone/matrix~ is using dsp_add over dsp_addv?

Generally, you don't *need* to pass the individual signal buffers to 
dsp_add. Many externals with variable inputs/outputs simply allocate an 
array of t_float pointers inside the object and store the signal buffers 
there, meaning that they don't pass them to dsp_add at all. It's just a 
matter of personal style.

One word of warning about externals with multiple signal inputs/outputs 
(quoting from https://github.com/pure-data/externals-howto#signal-classes):

"Optimisation 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."

This is still a bit vague, though, I would rephrase it like this:

"In this case, the programmer has to be careful not to write into *any* 
out-signal before having read *all* in-signals"

Christof

On 23.05.2020 09:21, Eric Lennartson wrote:
> is there a reason that cyclone/matrix~ is using dsp_add over dsp_addv?
>
> On Fri, May 22, 2020 at 8:26 PM Alexandre Torres Porres 
> <porres at gmail.com <mailto:porres at gmail.com>> wrote:
>
>     see the code of cyclone/mtx~ for instance
>
>     basically, you do"
>     for(i = 0; i < n_inlet; i++)
>         inlet_new()...
>
>     and stuff
>
>     Em sex., 22 de mai. de 2020 às 23:17, Eric Lennartson
>     <lennartsoneric at gmail.com <mailto:lennartsoneric at gmail.com>> escreveu:
>
>         Hello all,
>
>         I was wondering how one would go about creating an external
>         that given two creation arguments created that many inlets and
>         outlets? I've been browsing the source code for externals that
>         do something similar, but I think I'm going to need a bit more
>         of an explanation.
>
>         Thanks for the help.
>         _______________________________________________
>         Pd-dev mailing list
>         Pd-dev at lists.iem.at <mailto:Pd-dev at lists.iem.at>
>         https://lists.puredata.info/listinfo/pd-dev
>
>
> _______________________________________________
> Pd-dev mailing list
> Pd-dev at lists.iem.at
> https://lists.puredata.info/listinfo/pd-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-dev/attachments/20200523/959bcbc0/attachment.html>


More information about the Pd-dev mailing list