PDA

View Full Version : Speaker arrangement type bug


Tale
04-26-2010, 04:50 AM
I believe I have found a bug in IPlug: When I load my ComboV plug-in into VSTHost, the host says the plug-in has 1 input and 2 outputs, while in fact it has 0 inputs (PLUG_CHANNEL_IO == "0-2"). Other VSTi plug-ins do report 0 inputs in VSTHost, so I figured something must be wrong in the way ComboV or IPlug reports its inputs to the host. After some digging I found the following lines in IPlugVST.cpp:

memset(&mInputSpkrArr, 0, sizeof(VstSpeakerArrangement));
memset(&mOutputSpkrArr, 0, sizeof(VstSpeakerArrangement));
mInputSpkrArr.numChannels = nInputs;
mOutputSpkrArr.numChannels = nOutputs;

What is missing here is the definition of the speaker arrangement type. Because memset() fills the struct with zeros the type always is 0, which is the value for kSpeakerArrMono and not kSpeakerArrEmpty as one might expect.

I think defining the type as follows would fix this bug:

mInputSpkrArr.type = nInputs == 0 ? kSpeakerArrEmpty : kSpeakerArrUserDefined;

Or perhaps even:

mInputSpkrArr.type = nInputs == 0 ? kSpeakerArrEmpty : nInputs == 1 ? kSpeakerArrMono : nInputs == 2 ? kSpeakerArrStereo : kSpeakerArrUserDefined;

The same fix should be applied to the output speaker arrangement.

Tale
04-26-2010, 08:57 AM
Here's another, somewhat related bug: If you have an odd number of inputs or outputs (e.g. a mono signal) then it gets flagged as being the first of a stereo pair by the following lines of code in IPlugVST.cpp:

pp->flags = kVstPinIsActive;
if (idx % 2 == 0) {
pp->flags |= kVstPinIsStereo;
}

This causes FL Studio 9 to send a mono signal only to the left channel, instead of to both the left and right channels. This can easily be fixed by checking if there actually is a second channel to pair with:

pp->flags = kVstPinIsActive;
if (idx % 2 == 0 && idx < _this->NOutChannels() - 1) {
pp->flags |= kVstPinIsStereo;
}

Again, this fixed should be applied to both the input and the output.

--

And while I'm at it: FL Studio lists the plug-in category, which is always kPlugCategEffect for an IPlug, even when the plug-in has effFlagsIsSynth set. I think a synth should report its category as kPlugCategSynth, which can be easily accomplished by changing the following lines of code:

Current code:
case effGetPlugCategory: {
return kPlugCategEffect;
}

Changed code:
case effGetPlugCategory: {
return pEffect->flags & effFlagsIsSynth ? kPlugCategSynth : kPlugCategEffect;
}

[EDIT] Or probably more consistent with existing source code:
case effGetPlugCategory: {
return _this->IsInst() ? kPlugCategSynth : kPlugCategEffect;
}

schwa
04-27-2010, 12:42 PM
Thanks! We'll merge these fixes in.

Tale
04-27-2010, 12:53 PM
You're welcome; I'm glad to be of service. :)

cc_
04-28-2010, 08:16 AM
Yes, thanks, glad you sorted this!