Skip to content

Commit

Permalink
comparator tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
scanner-darkly committed May 27, 2024
1 parent 6f99c44 commit ce47cb3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/SDComparator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ struct SDComparator : Module {
SDComparator() {
config(PARAMS_LEN, INPUTS_LEN, OUTPUTS_LEN, LIGHTS_LEN);

configParam(LEVEL1_PARAM, -10.f, 10.f, 0.f, "");
configParam(LEVEL2_PARAM, -10.f, 10.f, 0.f, "");
configParam(LEVEL3_PARAM, -10.f, 10.f, 0.f, "");
configParam(LEVEL4_PARAM, -10.f, 10.f, 0.f, "");
configParam(LEVEL5_PARAM, -10.f, 10.f, 0.f, "");
configParam(LEVEL6_PARAM, -10.f, 10.f, 0.f, "");
configParam(LEVEL7_PARAM, -10.f, 10.f, 0.f, "");
configParam(LEVEL8_PARAM, -10.f, 10.f, 0.f, "");
configParam(LEVEL1_PARAM, -10.f, 10.f, 0.f, "Threshold Level 1");
configParam(LEVEL2_PARAM, -10.f, 10.f, 0.f, "Threshold Level 2");
configParam(LEVEL3_PARAM, -10.f, 10.f, 0.f, "Threshold Level 3");
configParam(LEVEL4_PARAM, -10.f, 10.f, 0.f, "Threshold Level 4");
configParam(LEVEL5_PARAM, -10.f, 10.f, 0.f, "Threshold Level 5");
configParam(LEVEL6_PARAM, -10.f, 10.f, 0.f, "Threshold Level 6");
configParam(LEVEL7_PARAM, -10.f, 10.f, 0.f, "Threshold Level 7");
configParam(LEVEL8_PARAM, -10.f, 10.f, 0.f, "Threshold Level 8");

configSwitch(DOT_PARAM, 0.0, 1.0, 0.0, "Dot Mode", {"On", "Off"});
getParamQuantity(DOT_PARAM)->randomizeEnabled = false;
Expand Down Expand Up @@ -89,12 +89,15 @@ struct SDComparator : Module {
bool gates[CHANNEL_COUNT];
float level, voltage, highest;
voltage = inputs[INPUT_INPUT].getVoltage();

highest = -100.f;
int highest_index = -1;
bool higher;

int level_count = inputs[LEVELS_INPUT].getChannels();

for (int i = 0; i < CHANNEL_COUNT; i++) {
level = inputs[LEVELS_INPUT].getVoltage(i) + params[LEVEL1_PARAM + i].getValue();
level = (i < level_count ? inputs[LEVELS_INPUT].getVoltage(i) : 0.f) + params[LEVEL1_PARAM + i].getValue();
higher = voltage >= level;

gates[i] = higher;
Expand Down
1 change: 1 addition & 0 deletions src/SDTransgate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ struct SDTransgate : Module {
}

void process(const ProcessArgs& args) override {

int input_count = inputs[INPUT_INPUT].getChannels();
float last_voltage = input_count > 0 ? inputs[INPUT_INPUT].getVoltage(input_count - 1) : 0.f;

Expand Down

0 comments on commit ce47cb3

Please sign in to comment.