PDA

View Full Version : Problem with multiple outs


DukeRoodee
11-18-2010, 01:38 AM
Hi all :-)

i ran into some trouble trying to make my instrument "multi - output" (up to 8 stereo pairs) on mac (AU).

First, the only way to make it multi-out for AULab was to set this channel io in resource.h
#define PLUG_CHANNEL_IO "0-2 0-4 0-6 0-8 0-10 0-12 0-14 0-16"

I guess this is correct because AULab actually shows me the 8 stereo pairs when loading the plug.
Using only "0-16" failed with a runtime error…. i didn´t try "0-2 0-16" yet, may also work.

The problem i am facing is assigning the samples into double** outputs in processDoubleReplacing().
This is a plot of my code (its simplified just to show the important parts)
BTW, this worked with multi out on windows (VST version) !


for (s = 0; s < nFrames; s++) {

// do midi stuff

double* outL;
double* outR;

//initialize output[][] with 0

// sum the midi channels… more than 1 midi channel can play on one output.
for( int i = 0; i<PLUG_MMIDI_CHANNELS; i++ ) {
renderingEngine = engine[i];
int outputNr = renderingEngine->getOutputNr() * 2;
if( IsOutChannelConnected(outputNr) ) {
outL = &outputs[outputNr][s];
outR = &outputs[outputNr+1][s];
renderingEngine->render();
*outL += renderingEngine->sample;
*outR += renderingEngine->sample;
}
}
}

I know i could implement this in different and more performant manner but there were more important things to do so far ;-)

As AU this works like a charm with 1 stereo pair (but only using "0-2").

When i use other channel setups (eg"0-16"),
first problem is that IsOutChannelConnected returns true only for values 0 and 1 (the first stereo pair).
Second problem: at runtime i would hear some distorted (or maybe stuttering) signal.
Third problem: If i delete the "if (IsOutChannelConnected(outputNr))" statement, then the assignment to output[0] and output[1] would be ok,
but assigning output[>=2] would result in a bad memory access error. In fact it seems that the host would always call processDoubleReplacing with a output structure for 1 stereo pair only (even using "0-16").

Somebody of you can help me ? What am i doing wrong ?

Thanks in advance….

regards
Rudi