Implementing 1 input, 2 outputs (i.e. mono -> stereo)

The reason that crashes is unrelated. If you don’t have 2-2 as an option, there will not be a scratch buffer for input channel 2, and this code will try to access invalid channel data.

void IPlugEffect::ProcessBlock(sample** inputs, sample** outputs, int nFrames)
{
  const double gain = GetParam(kGain)->Value() / 100.;
  const int nChans = NOutChansConnected();
  
  for (int s = 0; s < nFrames; s++) {
    for (int c = 0; c < nChans; c++) {
      outputs[c][s] = inputs[c][s] * gain; // inputs[1][s] is invalid with PLUG_CHANNEL_IO “1-2”
    }
  }
}
1 Like