Dear List,
I can see that you are busy with a lot of meetings and I don't want to bother you, but I'd like to hear your opinion about my project.
I'm trying to program a MultiOutUgen which is at the same time a sort of "MultiIn" Ugen.
This is the class:
NewOne : MultiOutUGen {
*ar {
arg in, mul = 1.0, add = 0.0;
^this.multiNewList(['audio']++ in.asArray)
}
init { arg ... theInputs;
inputs = theInputs;
^this.initOutputs(inputs.size, rate);
}
}
The number of outputs is always equal to the number of inputs.
In C++ the NewOne_next function defines:
int n = unit->mNumInputs;
out = OUT(0);
float a[n]; // prepare an empty array for processing
// fill the array with the values of each input
for (int ch = 0; ch < n; ch++) {
in = IN(ch);
a[ch] = *in;
}
"a" is now an array of length "n" (equals to the number of inputs, and I'm ready to manipulate it).
To process the array I'm calling the function "process) which returns an array of the same size:
float *result = process(a, n); // returns an array of floats
the function "process" works perfectly (I mean: it does what I need).
Now the only thing that is missing is sending each index of the array to the appropriate output. I'm trying to do it with a classic for loop:
// output loop
for(int i=0; i<inNumSamples; i++){
but unfortunately the order of the elements of the arrays is wrong.
Let me give you an example:
a = [1,0,1,0];
result = [1,1,0,0];
but in SC if I poll the output of the Ugen the result is:
UGen Array [0]: 1 // correct
UGen Array [1]: 0 // should be 1
UGen Array [2]: 1 // should be 0
UGen Array [3]: 0 // correct
I'm learning cpp through coding so, there might be inconsistencies in what I presented you, but for what I managed to debug, I think that the problem lies in the "output for loop". If I print result[i] inside the "output loop" the order is correct.
Could you help me? Do you need more informations, or more code?
thank you
Davide