Hello,
I have been trying to solve this problem for a couple of days by now. I am pretty sure that this is a simple pointer arithmetics error on my part, but still, this is driving me crazy and I hope you don't mind asking me this question here.
I am writing a simple external which adds all the inlet signals. I expect to allow any number of inlets, so I am using the dsp_addv method. Here, for debugging purposes I am only using two inlets. When I access the inlets like in the example above everything works as expected.
t_int *ak_addthese_tilde_perform(t_int *w) {
int i, j;
t_ak_addthese_tilde *x = (t_ak_addthese_tilde *)(w[1]);
int n = (int)(w[2]);
t_sample * in1 = (t_sample *)(w[3]);
t_sample * in2 = (t_sample *)(w[4]);
t_sample * out = (t_sample *)(w[5]);
while(n--) {
*out++ = *in1++ + *in2++;
}
return (w + 6);
}
When I access all input signals with an array of pointers, I cannot hear the rightmost signal in the output. So in this code above I only hear the signal from the first inlet. Like so,
t_int *ak_addthese_tilde_perform(t_int *w) {
int i, j;
t_ak_addthese_tilde *x = (t_ak_addthese_tilde *)(w[1]);
t_int n = (t_int)(w[2]);
t_sample ** ins = getbytes(sizeof(t_sample *) * 2);
t_sample * out = (t_sample *)(w[5]);
for(i = 0; i < 2; i++) {
ins[i] = (t_sample *)(w[3 + i]);
}
while(n--) {
*out = 0.0;
for(j = 0; j < 2; j++) {
*out += *ins[j]++;
}
out++;
}
return (w + 6);
}
I would be grateful if you could point out where I am mistaken.
Best[/i]