commit 0956f24c1f95c9c4424b9f507d424f14c5ba9eb2
parent f96dd68100b0c898946ddc2df4d8f1e8539e353d
Author: Adam Malone <1319733+freddyz@users.noreply.github.com>
Date: Wed, 17 Jul 2019 15:31:52 -0500
Roly Pouter should not attempt to read input channels beyond channel count
Diffstat:
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/src/ComputerscareRolyPouter.cpp b/src/ComputerscareRolyPouter.cpp
@@ -4,18 +4,14 @@ struct ComputerscareRolyPouter;
const int numKnobs = 16;
-const int numToggles = 16;
-const int numOutputs = 16;
-
struct ComputerscareRolyPouter : Module {
int counter = 0;
int routing[numKnobs];
+ int numOutputChannels = 16;
ComputerscareSVGPanel* panelRef;
enum ParamIds {
KNOB,
- TOGGLES = KNOB + numKnobs,
- NUM_PARAMS = TOGGLES + numToggles
-
+ NUM_PARAMS = KNOB + numKnobs
};
enum InputIds {
POLY_INPUT,
@@ -23,7 +19,7 @@ struct ComputerscareRolyPouter : Module {
};
enum OutputIds {
POLY_OUTPUT,
- NUM_OUTPUTS = POLY_OUTPUT + numOutputs
+ NUM_OUTPUTS
};
enum LightIds {
NUM_LIGHTS
@@ -42,6 +38,8 @@ struct ComputerscareRolyPouter : Module {
}
void process(const ProcessArgs &args) override {
counter++;
+ int inputChannels = inputs[POLY_INPUT].getChannels();
+ int knobSetting;
if (counter > 5012) {
//printf("%f \n",random::uniform());
counter = 0;
@@ -50,9 +48,15 @@ struct ComputerscareRolyPouter : Module {
}
}
- outputs[POLY_OUTPUT].setChannels(16);
- for (int i = 0; i < numKnobs; i++) {
- outputs[POLY_OUTPUT].setVoltage(inputs[POLY_INPUT].getVoltage(params[KNOB + i].getValue() - 1), i);
+ outputs[POLY_OUTPUT].setChannels(numOutputChannels);
+ for (int i = 0; i < numOutputChannels; i++) {
+ knobSetting = params[KNOB+i].getValue();
+ if(knobSetting > inputChannels) {
+ outputs[POLY_OUTPUT].setVoltage(0,i);
+ }
+ else {
+ outputs[POLY_OUTPUT].setVoltage(inputs[POLY_INPUT].getVoltage(knobSetting - 1), i);
+ }
}
}