All plugin developers should be aware of the following points when developing polyphonic modules (or monophonic, for the first point). It is also helpful for advanced users to be aware of these rules. If you see a module that does not follow the VCV Voltage Standards, send a bug report to the developer.
Audio inputs of monophonic modules should sum the polyphonic channels.
If you choose not to support polyphony, you should still sum the channels of a polyphonic cable before processing it as audio. To do this, replace getVoltage()
with getVoltageSum()
for all audio input ports.
For example, if a user patches a polyphonic oscillator playing a chord into a monophonic chorus module, the channels should be combined (summed) at the chorus’ input so that the entire chord is processed by the chorus.
Input ports intended for CV or hybrid CV/audio should not sum polyphonic channels, because the sum of polyphonic CV channels is usually not what the user intends.
This point is sometimes easy to forget, even for me, so if you see any monophonic audio inputs not summing polyphonic channels, send a bug report as usual.
There may be multiple “primary” input ports on your module which define your DSP engine’s number of channels.
For example, Audible Instruments Multiples has three inputs in its bottom section that are treated equally. The number of channels should be defined as the maximum number of channels in any of those ports.
int channels = std::max(
std::max(
std::max(inputs[C1_INPUT].getChannels(),
inputs[C2_INPUT].getChannels()),
inputs[C3_INPUT].getChannels()),
1);
Remember that getChannels()
returns 0 for unpatched cables, while you should always set at least 1 channel for output ports, so use std::max(..., 1)
when computing the your DSP engine’s number of channels.
In the above example, we must use getPolyVoltage(int channel)
on each input, since any of the signals might be monophonic.
float in = inputs[C1_INPUT].getPolyVoltage(c)
+ inputs[C2_INPUT].getPolyVoltage(c)
+ inputs[C3_INPUT].getPolyVoltage(c);
getPolyVoltage(c)
returns channel c
, or if the port is monophonic, it returns channel 0
.
Lights representing polyphonic signals should display the “root mean sum” of the channels.
The root mean sum is defined as
This formula returns 1 if any of the channels are 1, and it reduces to the identify function in the monophonic case.
VCV recommends to use blue for polyphonic signals, such as componentlibrary::SCHEME_BLUE
.