On 16/03/16 13:25, i go bananas wrote:
pd using the same address for inlets and outlets as an optimisation?
Yes, Pd recycles signal vectors so your output vector could be the same as the input vector, which means this code is unsafe because it could trash the inputs:
// loop through the 4 oscillators, adding the left to right: for (int osc = 0; osc < 4; osc++) { int n = (int)(w[14]); while (n--) *output[osc]++ = *left[osc]++ + *right[osc]++; }
The easiest fix would be to reverse the order of the loops:
int n = (int)(w[14]); while (n--) { for (int osc = 0; osc < 4; osc++) *output[osc] = *left[osc] + *right[osc]; output++; left++; right++; }
Your alternative method of changing the iolet creation orders is not a fix, it might "work" for one particular patch but another patch could break it again.