|
|
@@ -48,6 +48,19 @@ struct Rampage : Module { |
|
|
|
NUM_OUTPUTS, |
|
|
|
}; |
|
|
|
|
|
|
|
float lastOutA = 0.0; |
|
|
|
float lastOutB = 0.0; |
|
|
|
|
|
|
|
float comparatorLight = 0.0; |
|
|
|
float minLight = 0.0; |
|
|
|
float maxLight = 0.0; |
|
|
|
float outALight = 0.0; |
|
|
|
float outBLight = 0.0; |
|
|
|
float risingALight = 0.0; |
|
|
|
float fallingALight = 0.0; |
|
|
|
float risingBLight = 0.0; |
|
|
|
float fallingBLight = 0.0; |
|
|
|
|
|
|
|
Rampage(); |
|
|
|
void step(); |
|
|
|
}; |
|
|
@@ -60,6 +73,43 @@ Rampage::Rampage() { |
|
|
|
} |
|
|
|
|
|
|
|
void Rampage::step() { |
|
|
|
// TEMP |
|
|
|
float outA = getf(inputs[IN_A_INPUT]); |
|
|
|
float outB = getf(inputs[IN_B_INPUT]); |
|
|
|
setf(outputs[OUT_A_OUTPUT], outA); |
|
|
|
setf(outputs[OUT_B_OUTPUT], outB); |
|
|
|
outALight = outA / 10.0; |
|
|
|
outBLight = outB / 10.0; |
|
|
|
|
|
|
|
// Slope detector |
|
|
|
const float slopeThreshold = 1.0; // volts per second |
|
|
|
#define SLOPE(out, lastOut, rising, falling, risingLight, fallingLight) { \ |
|
|
|
float slope = (out - lastOut) / gSampleRate; \ |
|
|
|
lastOut = out; \ |
|
|
|
float rising = slope > slopeThreshold ? 10.0 : 0.0; \ |
|
|
|
float falling = slope < -slopeThreshold ? 10.0 : 0.0; \ |
|
|
|
setf(outputs[rising], rising); \ |
|
|
|
setf(outputs[falling], falling); \ |
|
|
|
risingLight = rising / 10.0; \ |
|
|
|
fallingLight = falling / 10.0; \ |
|
|
|
} |
|
|
|
SLOPE(outA, lastOutA, RISING_A_OUTPUT, FALLING_A_OUTPUT, risingALight, fallingALight) |
|
|
|
SLOPE(outB, lastOutB, RISING_B_OUTPUT, FALLING_B_OUTPUT, risingBLight, fallingBLight) |
|
|
|
|
|
|
|
// Analog logic processor |
|
|
|
float balance = params[BALANCE_PARAM]; |
|
|
|
const float balancePower = 0.5; |
|
|
|
outA *= powf(1.0 - balance, balancePower); |
|
|
|
outB *= powf(balance, balancePower); |
|
|
|
float max = fmaxf(outA, outB); |
|
|
|
float min = fminf(outA, outB); |
|
|
|
float comparator = outB > outA ? 10.0 : 0.0; |
|
|
|
setf(outputs[MAX_OUTPUT], max); |
|
|
|
setf(outputs[MIN_OUTPUT], min); |
|
|
|
setf(outputs[COMPARATOR_OUTPUT], comparator); |
|
|
|
maxLight = max / 10.0; |
|
|
|
minLight = min / 10.0; |
|
|
|
comparatorLight = comparator / 20.0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@@ -94,18 +144,18 @@ RampageWidget::RampageWidget() { |
|
|
|
addInput(createInput<PJ3410Port>(Vec(142-3, 290-3), module, Rampage::CYCLE_B_INPUT)); |
|
|
|
|
|
|
|
addParam(createParam<BefacoSwitch>(Vec(96-2, 35-3), module, Rampage::RANGE_A_PARAM, 0.0, 2.0, 0.0)); |
|
|
|
addParam(createParam<BefacoTinyKnob>(Vec(27, 90), module, Rampage::SHAPE_A_PARAM, 0.0, 1.0, 0.0)); |
|
|
|
addParam(createParam<BefacoTinyKnob>(Vec(27, 90), module, Rampage::SHAPE_A_PARAM, -1.0, 1.0, 0.0)); |
|
|
|
addParam(createParam<BefacoPush>(Vec(72, 82), module, Rampage::TRIGG_A_PARAM, 0.0, 1.0, 0.0)); |
|
|
|
addParam(createParam<BefacoSlidePot>(Vec(21-5, 140-5), module, Rampage::RISE_A_PARAM, 0.0, 1.0, 0.0)); |
|
|
|
addParam(createParam<BefacoSlidePot>(Vec(62-5, 140-5), module, Rampage::FALL_A_PARAM, 0.0, 1.0, 0.0)); |
|
|
|
addParam(createParam<BefacoSwitch>(Vec(101, 240-2), module, Rampage::CYCLE_A_PARAM, 0.0, 1.0, 0.0)); |
|
|
|
addParam(createParam<BefacoSwitch>(Vec(149-2, 35-3), module, Rampage::RANGE_B_PARAM, 0.0, 2.0, 0.0)); |
|
|
|
addParam(createParam<BefacoTinyKnob>(Vec(217, 90), module, Rampage::SHAPE_B_PARAM, 0.0, 1.0, 0.0)); |
|
|
|
addParam(createParam<BefacoTinyKnob>(Vec(217, 90), module, Rampage::SHAPE_B_PARAM, -1.0, 1.0, 0.0)); |
|
|
|
addParam(createParam<BefacoPush>(Vec(170, 82), module, Rampage::TRIGG_B_PARAM, 0.0, 1.0, 0.0)); |
|
|
|
addParam(createParam<BefacoSlidePot>(Vec(202-5, 140-5), module, Rampage::RISE_B_PARAM, 0.0, 1.0, 0.0)); |
|
|
|
addParam(createParam<BefacoSlidePot>(Vec(243-5, 140-5), module, Rampage::FALL_B_PARAM, 0.0, 1.0, 0.0)); |
|
|
|
addParam(createParam<BefacoSwitch>(Vec(141, 240-2), module, Rampage::CYCLE_B_PARAM, 0.0, 1.0, 0.0)); |
|
|
|
addParam(createParam<Davies1900hWhiteKnob>(Vec(117, 76), module, Rampage::BALANCE_PARAM, 0.0, 1.0, 0.0)); |
|
|
|
addParam(createParam<Davies1900hWhiteKnob>(Vec(117, 76), module, Rampage::BALANCE_PARAM, 0.0, 1.0, 0.5)); |
|
|
|
|
|
|
|
addOutput(createOutput<PJ3410Port>(Vec(8-3, 326-3), module, Rampage::RISING_A_OUTPUT)); |
|
|
|
addOutput(createOutput<PJ3410Port>(Vec(67-3, 326-3), module, Rampage::FALLING_A_OUTPUT)); |
|
|
@@ -118,4 +168,14 @@ RampageWidget::RampageWidget() { |
|
|
|
addOutput(createOutput<PJ3410Port>(Vec(122-3, 133-3), module, Rampage::COMPARATOR_OUTPUT)); |
|
|
|
addOutput(createOutput<PJ3410Port>(Vec(89-3, 156-3), module, Rampage::MIN_OUTPUT)); |
|
|
|
addOutput(createOutput<PJ3410Port>(Vec(155-3, 156-3), module, Rampage::MAX_OUTPUT)); |
|
|
|
|
|
|
|
addChild(createValueLight<SmallLight<RedValueLight>>(Vec(131, 167), &module->comparatorLight)); |
|
|
|
addChild(createValueLight<SmallLight<RedValueLight>>(Vec(122, 174), &module->minLight)); |
|
|
|
addChild(createValueLight<SmallLight<RedValueLight>>(Vec(140, 174), &module->maxLight)); |
|
|
|
addChild(createValueLight<SmallLight<RedValueLight>>(Vec(125, 185), &module->outALight)); |
|
|
|
addChild(createValueLight<SmallLight<RedValueLight>>(Vec(137, 185), &module->outBLight)); |
|
|
|
addChild(createValueLight<SmallLight<RedValueLight>>(Vec(17, 312), &module->risingALight)); |
|
|
|
addChild(createValueLight<SmallLight<RedValueLight>>(Vec(77, 312), &module->fallingALight)); |
|
|
|
addChild(createValueLight<SmallLight<RedValueLight>>(Vec(186, 312), &module->risingBLight)); |
|
|
|
addChild(createValueLight<SmallLight<RedValueLight>>(Vec(245, 312), &module->fallingBLight)); |
|
|
|
} |