[PD-dev] help designing multichannel aware externals

Alexandre Torres Porres porres at gmail.com
Mon Jan 23 16:18:02 CET 2023


Hi smart pd-dev people, please help me. I'm miserably failing in designing
new externals with the amazing new multi-channel feature.

Getting inspired by some of the MAX objects, for fun and for starters I
thought I'd clonen [mc.list~], which is kinda like the new [pack~] but you
can set the values as arguments. It would also allow us to use the list box
to set all values.

My first and only 'mc' external so far is [nchs~], see -->
https://github.com/porres/pd-else/blob/master/Classes/Source/nchs~.c I
already mentioned it and said it'd be cool to have it in Vanilla. It
outputs a float value but I wanted, as a first step, to adapt it to output
a signal value instead, but I can't do not even that, let alone have a new
external that outputs a multichannel signal. From the [nchs~] code, I just
use the 'dsp method' to get 'sp[0]->s_nchans' (number of channels) and call
a bang function that outputs the float.

If I create a 'perform' method to get number of channels as a signal, Pd
blows up, and I don't know what I'm doing wrong as I'm doing what I do with
every other regular external. Not that I wanted a signal output, I'd rather
have the float output, but I expected this to work and I can't see the
problem. I am assuming multichannel externals are different and I don't
really know the secret or the recipe yet to mess with them. Check code
below.

*static* t_int *nchs_perform(t_int *w){

    t_check *x = (t_check *)(w[1]);

    *int* n = (t_int)(w[2]);

    t_sample *in = (t_sample *)(w[3]);

    t_sample *out = (t_sample *)(w[4]);

    *while*(n--)

        *out = x->x_nchans;

    *return*(w+5);

}


*static* *void* nchs_tilde_dsp(t_check *x, t_signal **sp){

    x->x_nchans = sp[0]->s_nchans;

    dsp_add(check_perform, 4, x, sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec);
}

I can't imagine the further challenges to output or treat multichannel
signals, but I'd like to start by clarifying this.

funny enough, [pack~]/[unpack~] do not have 'perform' methods so I can't
figure this out.

Thanks a lot.
cheers~
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-dev/attachments/20230123/01c5cd12/attachment.htm>


More information about the Pd-dev mailing list