how to make variable msp outlets

dyka's icon

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?

thezer0ist@gmail.com's icon

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

dyka's icon

Thanks a lot. :)

martinrobinson's icon

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.