View Single Post
Old 11-03-2020, 01:12 PM   #11
Ric Vega
Human being with feelings
 
Join Date: May 2020
Posts: 13
Default

Quote:
Originally Posted by Nonlinear View Post
Hmm...not sure what your code is doing - looks like it's all stereo processing (If (in/out) > 1). How are you setting up 1 in to 2 out?
I made a minimal plugin as l mentioned above in which I try the three main configurations (mono, stereo, and mono->stereo), if the plugin is stereo l merely swap the channels, if it's mono->stereo l apply the gain, and if it's mono l apply the inverse of the gain, that way l can check if the plugin is doing what is expected:

Code:
void Minimal2::ProcessBlock(sample** inputs, sample** outputs, int nFrames)
{
double gain = GetParam(kGain)->Value() / 100.;

// Stereo (swap L and R)
if (NInChansConnected() > 1)
{
    for (int s=0 ; s<nFrames ; ++s)
    {
        outputs[0][s] = inputs[1][s];
        outputs[1][s] = inputs[0][s];
    }
}

else
{   // Mono -> Stereo (apply gain)
    if (NOutChansConnected() > 1)
    {
        for (int s=0 ; s<nFrames ; ++s)
        {
            outputs[0][s] = inputs[0][s] * gain;
            outputs[1][s] = inputs[0][s] * gain;
        }
    }
    
    else
    {
        // Mono (apply inverse gain)
        for (int s=0 ; s<nFrames ; ++s)
        {
            outputs[0][s] = inputs[0][s] * (1.0 - gain);
        }
    }
}
}
Ric Vega is offline   Reply With Quote