Perform method – inlet connection state

Nov 23, 2013 at 6:34am

Perform method – inlet connection state

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

#273575
Jan 16, 2014 at 9:15am

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.

#278384
Jan 16, 2014 at 1:41pm

Good to know… Thanks Tim.

- Luigi

#278399

You must be logged in to reply to this topic.