I am trying to code an msp external with variable number of outlets (i.e. the number of outlets is unknown to me while writing my code)
To make my code more efficient, I determined that only 2 outlets compute a signal at any given time - this means, the rest output a signal of 0.0
I am able to determine these two signal outlets on a per-sample basis. This means, on every sample I recompute which of the many outlets are the two that need to do any dsp - the rest merely output a signal of 0.0
Currently I do this by having a nested loop, naïvely writing a value of 0.0 to every outlet (on every sample), then overwriting the two computed values to the respective outlets (previously determined as described above).
My question is: Can I avoid the nested loop?
I.e. is there a way to initialize my t_float** to 0.0 to have *all* outlets silenced and then overwrite my values to each respective outlet on each sample as needed?
I tried using memset, for example, but for some odd reason, computing the sample values in the succeeding loop thereafter does not overwrite anything and all my signals are merely silenced (constant 0.0 value).
I would LOVE to look that objects like [gate~] as it seems very efficient, but since its outlet control is also control rate based (not audio rate based, like the object I am writing), it also might not help very much in my case.
I would embrace any help if anyone has experience with this.
P.S.: I tried stating this question before here, but I am afraid my wording was very confusing. Please let me know if you do not quite understand my problem. Need help! Thanks!:)