how to make variable msp outlets

Jun 16, 2008 at 12:05am

how to make variable msp outlets

Dear all,

I am trying to build an MSP external where the object takes an argument that defines the number of signal outlets. I have managed to create the specified amount of outlets by placing the outlet_new function in a for loop. But when I come to the dsp function of my object (where I have to call the dsp_add function), I have to specify signals as sp[0]->s_vec. How can I tell the dsp_add function to add as many signals as defined by the objects argument?

#38426
Jun 16, 2008 at 3:49am

there’s an alternate version of the dsp_add function (named something else), that takes a variable length list of values, similar to the way printf works

#134064
Jun 16, 2008 at 6:38am

Thanks a lot. :)

#134065
Jun 16, 2008 at 8:16pm

I think it much less error prone to keep the dsp_add() call the same where there can be many variations and just pass it a pointer to your object and the buffer size.

e.g., something like:

void mymsp_dsp(t_mymsp *x, t_signal **sp, short *count)
{
//…store i/o buffer info in x

dsp_add(mymsp_perform, 2, x, sp[0]->s_n);
}

t_int *mymsp_perform(t_int *w)
{
t_mymsp *x = (t_mymsp *)(w[1]);
int numSamples = (int)(w[2]);

//…process stuff by getting at the i/o buffers
// stored in x in dsp_add()

return (w+3);
}

If you need efficiency gained by passing the buffers on directly via dsp_add() you can do this later.

#134066

You must be logged in to reply to this topic.