commit af8986180c0c4847c0039bd666099ffbd12b57d2
parent a3c8845987bf845f450f92a517e301adc711927b
Author: Matt Demanett <matt@demanett.net>
Date: Fri, 25 Nov 2022 17:31:10 -0500
POLYMULT: allow a mono signal at CHAN to act as a CV over the channel count; use only the first channel of the input, rather than the poly sum, to produce the outputs.
Diffstat:
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/README-prerelease.md b/README-prerelease.md
@@ -1379,9 +1379,11 @@ _When <a href="#bypassing">bypassed</a>:_ no output.
#### <a name="polymult"></a> POLYMULT
-POLYMULT will turn a mono signal into a polyphonic signal, with a given number of channels, where each channel gets a copy of the input voltage. The number of channels is set by the CHAN knob, unless an input is present at the CHAN input, in which case the channel count is taken from that input, and the knob is ignored. Each OUT output is identical.
+POLYMULT will turn a mono signal into a polyphonic signal, with a given number of channels, where each channel gets a copy of the input voltage. The number of channels is set by the CHAN knob, unless an input is present at the CHAN input, in which case:
+ - If the signal at CHAN is polyphonic, the channel count is taken from that signal, and the knob is ignored.
+ - If the signal at CHAN is monophonic, it acts as a CV (0-10V), selecting the channel count up to the maximum set by the knob.
-To simply make copies of an already-polyphonic signal, use the regular <a href="#mult">MULT</a> module.
+Each OUT output is identical. To simply make copies of an already-polyphonic signal, use the regular <a href="#mult">MULT</a> module. If the input is a polyphonic singal, only the first channel is used to produce the outputs.
_When <a href="#bypassing">bypassed</a>:_ no output.
diff --git a/src/PolyMult.cpp b/src/PolyMult.cpp
@@ -4,10 +4,16 @@
void PolyMult::processAll(const ProcessArgs& args) {
int cn = clamp(params[CHANNELS_PARAM].getValue(), 1.0f, 16.0f);
if (inputs[CHANNELS_INPUT].isConnected()) {
- cn = inputs[CHANNELS_INPUT].getChannels();
+ int channels = inputs[CHANNELS_INPUT].getChannels();
+ if (channels == 1) {
+ cn = clamp(roundf(inputs[CHANNELS_INPUT].getVoltage() / 10.0f * cn), 1.0f, 16.0f);
+ }
+ else {
+ cn = channels;
+ }
}
- float out = inputs[IN_INPUT].getVoltageSum();
+ float out = inputs[IN_INPUT].getVoltage();
outputs[OUT1_OUTPUT].setChannels(cn);
outputs[OUT2_OUTPUT].setChannels(cn);
outputs[OUT3_OUTPUT].setChannels(cn);