Skip to content

Commit 47075cb

Browse files
committed
Cascade: add average output
1 parent 4f654ff commit 47075cb

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/funcgen.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ struct Funcgen : Module {
2929
CASCADE_EOC_OUTPUT,
3030
MIN_OUTPUT,
3131
MAX_OUTPUT,
32+
AVG_OUTPUT,
3233
AGTB_OUTPUT,
3334
AGTC_OUTPUT,
3435
AGTD_OUTPUT,
@@ -92,8 +93,9 @@ struct Funcgen : Module {
9293
configOutput(FUNCTION_OUTPUT + i, "Function");
9394
configOutput(EOC_OUTPUT + i, "EOC");
9495
}
95-
configOutput(MIN_OUTPUT, "Min");
96-
configOutput(MAX_OUTPUT, "Max");
96+
configOutput(MIN_OUTPUT, "Minimum");
97+
configOutput(MAX_OUTPUT, "Maximum");
98+
configOutput(AVG_OUTPUT, "Average");
9799
configOutput(AGTB_OUTPUT, "A > B");
98100
configOutput(AGTC_OUTPUT, "A > C");
99101
configOutput(AGTD_OUTPUT, "A > D");
@@ -227,6 +229,7 @@ struct Funcgen : Module {
227229
float d = envelope[3].env;
228230
outputs[MIN_OUTPUT].setVoltage(std::min(a, std::min(b, std::min(c, d))));
229231
outputs[MAX_OUTPUT].setVoltage(std::max(a, std::max(b, std::max(c, d))));
232+
outputs[AVG_OUTPUT].setVoltage((a + b + c + d) / CHANNEL_COUNT);
230233
outputs[AGTB_OUTPUT].setVoltage(a > b ? 10.f : 0.f);
231234
outputs[AGTC_OUTPUT].setVoltage(a > c ? 10.f : 0.f);
232235
outputs[AGTD_OUTPUT].setVoltage(a > d ? 10.f : 0.f);
@@ -330,6 +333,8 @@ struct FuncgenWidget : ModuleWidget {
330333
addOutput(createOutputCentered<PJ301MPort>(Vec(x, y), module, Funcgen::MIN_OUTPUT));
331334
x += dx;
332335
addOutput(createOutputCentered<PJ301MPort>(Vec(x, y), module, Funcgen::MAX_OUTPUT));
336+
x += dx;
337+
addOutput(createOutputCentered<PJ301MPort>(Vec(x, y), module, Funcgen::AVG_OUTPUT));
333338
}
334339
};
335340

0 commit comments

Comments
 (0)