[PD] variable signal outlets and inlets?

Rama Gottfried rama.gottfried at gmail.com
Sun Aug 30 21:36:48 CEST 2015


hi dave!
check out the dsp_addv function, I think it’s meant for exactly this. I don’t have any code right in front of me… oh wait, I do …  I’m pretty sure this works:

void grans_dsp(t_grans *x, t_signal **sp)
{
    int num = x->numinlets + x->numoutlets;
    t_int **w = x->w;
    w[0] = (t_int *)x;
    w[1] = (t_int *)sp[0]->s_n;
    
    int i;
    for (i = 0; i < num; i++) {
        w[i+2] = (t_int *)sp[i]->s_vec;
    }
    
    dsp_addv(grans_perform, num+2, (t_int *)w);
}


hope that’s useful!

cheers,
rama



> On Aug 30, 2015, at 12:09 PM, David Medine <dmedine at ucsd.edu> wrote:
> 
> Does any one know how to write a ~ object that has a variable number signal outlets and inlets? The only thing I've been able to come up with is to have a dsp routine that looks like:
> 
> switch(x->n_sigs){
>    case 3:
>      dsp_add(whatever_tilde_perform,
>      5,
>      x,
>      sp[0]->s_vec,
>      sp[1]->s_vec,
>      sp[2]->s_vec,
>      sp[0]->s_n);
>      break;
> 
>    case 4:
>      dsp_add(whatever_tilde_perform,
>      6,
>      x,
>      sp[0]->s_vec,
>      sp[1]->s_vec,
>      sp[2]->s_vec,
> sp[3]->s_vec,
>      sp[0]->s_n);
>      break;
> // so on and so forth...
> 
> }
> 
> It feels like there should be a better way to do this.
> Thanks,
> David
> 
> _______________________________________________
> Pd-list at lists.iem.at mailing list
> UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20150830/2a35fa5a/attachment.html>


More information about the Pd-list mailing list