Forums > Dev

Perform method – inlet connection state

November 23, 2013 | 6:34 am

Hello folks,

I know I should be ashamed for such a question, however I am no longer sure if I can do something like this:

void mydspobject_dsp64(t_mydspobject *x, t_object *dsp64, short *count, double samplerate, long vectorsize, long flags)
{
    dsp_add64(dsp64, (t_object *)x, (t_perfroutine64)mydspobject_perform64, 0, (void *)count);
}

and

void mydspobject_perform64(t_mydspobject *x, t_object *dsp64, double **ins, long numins, double **outs, long numouts, long sampleframes, long flags, void *userparam)
{
    short *count = (short *)userparam;
    long i;
    for (i = 0; i < numins; i++) {
        if (count[i]) { // only process audio vector if there is a connection
            // DSP processing…
        }
    }
}

Is the pointer to the ‘count’ array guaranteed to keep pointing to valid memory across subsequent calls to the perform method?

This is an attempt to pass the state of inlet connections to the perform routine in order to optimize the DSP processing.
I am trying to reduce the size of my object struct and the above code would save me the allocation of an array of shorts.

Thanks

- Luigi


January 16, 2014 | 9:15 am

Yes — you can use the ‘count’ array. Your configuration will not change between calls to your perform method without your dsp method being called first.


January 16, 2014 | 1:41 pm

Good to know… Thanks Tim.

- Luigi


Viewing 3 posts - 1 through 3 (of 3 total)