use of thousands of signal in-&out-lets

Guenter Geiger geiger at epy.co.at
Mon Jul 19 15:27:18 CEST 1999


forum::für::umläute writes:
 > Guenter Geiger schrieb:
 > > 
 > > forum::für::umläute writes:
 > >  > Hi all !
 > >  >
 > >  > I have one major problem and that is concerning writing externals (again
 > >  > !)
 > >  > Can I create an oject that has any (!) user-defined (via creation
 > >  > arguments) number of signal in/out-lets ? Me thinketh of something like
 > >  > the multichannel dac~/adc~ objects, but I have to access all ~inlets at
 > >  > the same (!) time and not sequentially...
 > >  >
 > > 
 > >  This seems to be a matter of calling dsp_add with a sufficient number
 > >  of arguments. I don't know how this could be done dynamically.
 > 
 > That's exactly what's my question about; surely I could do something
 > really annoying like calling the dsp_add with 64 or so arguments and
 > then use only the desired number; but of course that's not what I wanna
 > do;
 > 
 > hannes
 > 

In this case you'd have to reimplement dsp_add the way you want
it. It's not that hard, look in "d_ugens.c" for dsp_add and implement
a function there which takes the following arguments:


EXTERN void dsp_add_v(t_perfroutine f, int n, t_int* args);

You can then rewrite dsp_add to not use the va_start, va_arg, va_end 
macros and just iterate over your supplied array of objects.


untested (and may not work at all, but you get the idea) ... :

----------------------------------------------------------------------------
void dsp_add_v(t_perfroutine f, int n, t_int* args)
{
    int newsize = dsp_chainsize + n+1;
    int  i;
    dsp_chain = t_resizebytes(dsp_chain, dsp_chainsize * sizeof (t_int),
        newsize * sizeof (t_int));

    dsp_chain[dsp_chainsize-1] = (t_int)f;
    for (i = 0; i < n; i++)
    {
        dsp_chain[dsp_chainsize + i] = *args++;
    }
    dsp_chain[newsize-1] = 0;
    dsp_chainsize = newsize;
}
----------------------------------------------------------------------------

add the prototype to m_pd.h and recompile pd ... and later, get Miller
to include the function in the pd distribution :)

Well, after all that's how I would try to do it.

Guenter




More information about the Pd-list mailing list