|
|
@@ -50,24 +50,115 @@ struct VCAWidget : ModuleWidget { |
|
|
|
VCAWidget::VCAWidget(VCA *module) : ModuleWidget(module) { |
|
|
|
setPanel(SVG::load(assetPlugin(plugin, "res/VCA.svg"))); |
|
|
|
|
|
|
|
addChild(Widget::create<ScrewSilver>(Vec(15, 0))); |
|
|
|
addChild(Widget::create<ScrewSilver>(Vec(box.size.x-30, 0))); |
|
|
|
addChild(Widget::create<ScrewSilver>(Vec(15, 365))); |
|
|
|
addChild(Widget::create<ScrewSilver>(Vec(box.size.x-30, 365))); |
|
|
|
|
|
|
|
addParam(ParamWidget::create<RoundLargeBlackKnob>(Vec(27, 57), module, VCA::LEVEL1_PARAM, 0.0f, 1.0f, 0.5f)); |
|
|
|
addParam(ParamWidget::create<RoundLargeBlackKnob>(Vec(27, 222), module, VCA::LEVEL2_PARAM, 0.0f, 1.0f, 0.5f)); |
|
|
|
|
|
|
|
addInput(Port::create<PJ301MPort>(Vec(11, 113), Port::INPUT, module, VCA::EXP1_INPUT)); |
|
|
|
addInput(Port::create<PJ301MPort>(Vec(54, 113), Port::INPUT, module, VCA::LIN1_INPUT)); |
|
|
|
addInput(Port::create<PJ301MPort>(Vec(11, 156), Port::INPUT, module, VCA::IN1_INPUT)); |
|
|
|
addInput(Port::create<PJ301MPort>(Vec(11, 276), Port::INPUT, module, VCA::EXP2_INPUT)); |
|
|
|
addInput(Port::create<PJ301MPort>(Vec(54, 276), Port::INPUT, module, VCA::LIN2_INPUT)); |
|
|
|
addInput(Port::create<PJ301MPort>(Vec(11, 320), Port::INPUT, module, VCA::IN2_INPUT)); |
|
|
|
|
|
|
|
addOutput(Port::create<PJ301MPort>(Vec(54, 156), Port::OUTPUT, module, VCA::OUT1_OUTPUT)); |
|
|
|
addOutput(Port::create<PJ301MPort>(Vec(54, 320), Port::OUTPUT, module, VCA::OUT2_OUTPUT)); |
|
|
|
addChild(Widget::create<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0))); |
|
|
|
addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); |
|
|
|
addChild(Widget::create<ScrewSilver>(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); |
|
|
|
addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); |
|
|
|
|
|
|
|
addParam(ParamWidget::create<RoundLargeBlackKnob>(mm2px(Vec(6.35, 19.11753)), module, VCA::LEVEL1_PARAM, 0.0, 1.0, 0.0)); |
|
|
|
addParam(ParamWidget::create<RoundLargeBlackKnob>(mm2px(Vec(6.35, 74.80544)), module, VCA::LEVEL2_PARAM, 0.0, 1.0, 0.0)); |
|
|
|
|
|
|
|
addInput(Port::create<PJ301MPort>(mm2px(Vec(2.5907, 38.19371)), Port::INPUT, module, VCA::EXP1_INPUT)); |
|
|
|
addInput(Port::create<PJ301MPort>(mm2px(Vec(14.59752, 38.19371)), Port::INPUT, module, VCA::LIN1_INPUT)); |
|
|
|
addInput(Port::create<PJ301MPort>(mm2px(Vec(2.5907, 52.80642)), Port::INPUT, module, VCA::IN1_INPUT)); |
|
|
|
addInput(Port::create<PJ301MPort>(mm2px(Vec(2.5907, 93.53435)), Port::INPUT, module, VCA::EXP2_INPUT)); |
|
|
|
addInput(Port::create<PJ301MPort>(mm2px(Vec(14.59752, 93.53435)), Port::INPUT, module, VCA::LIN2_INPUT)); |
|
|
|
addInput(Port::create<PJ301MPort>(mm2px(Vec(2.5907, 108.14706)), Port::INPUT, module, VCA::IN2_INPUT)); |
|
|
|
|
|
|
|
addOutput(Port::create<PJ301MPort>(mm2px(Vec(14.59752, 52.80642)), Port::OUTPUT, module, VCA::OUT1_OUTPUT)); |
|
|
|
addOutput(Port::create<PJ301MPort>(mm2px(Vec(14.59752, 108.14706)), Port::OUTPUT, module, VCA::OUT2_OUTPUT)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Model *modelVCA = Model::create<VCA, VCAWidget>("Fundamental", "VCA", "VCA", AMPLIFIER_TAG, DUAL_TAG); |
|
|
|
struct VCA_1 : Module { |
|
|
|
enum ParamIds { |
|
|
|
LEVEL_PARAM, |
|
|
|
EXP_PARAM, |
|
|
|
NUM_PARAMS |
|
|
|
}; |
|
|
|
enum InputIds { |
|
|
|
CV_INPUT, |
|
|
|
IN_INPUT, |
|
|
|
NUM_INPUTS |
|
|
|
}; |
|
|
|
enum OutputIds { |
|
|
|
OUT_OUTPUT, |
|
|
|
NUM_OUTPUTS |
|
|
|
}; |
|
|
|
enum LightIds { |
|
|
|
NUM_LIGHTS |
|
|
|
}; |
|
|
|
|
|
|
|
float lastCv = 0.f; |
|
|
|
|
|
|
|
VCA_1() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) {} |
|
|
|
|
|
|
|
void step() override { |
|
|
|
float cv = inputs[CV_INPUT].normalize(10.f) / 10.f; |
|
|
|
if ((int) params[EXP_PARAM].value == 0) |
|
|
|
cv = powf(cv, 4.f); |
|
|
|
lastCv = cv; |
|
|
|
outputs[OUT_OUTPUT].value = inputs[IN_INPUT].value * params[LEVEL_PARAM].value * cv; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
struct VCA_1VUKnob : Knob { |
|
|
|
VCA_1VUKnob() { |
|
|
|
box.size = mm2px(Vec(10, 46)); |
|
|
|
} |
|
|
|
|
|
|
|
void draw(NVGcontext *vg) override { |
|
|
|
nvgBeginPath(vg); |
|
|
|
nvgRoundedRect(vg, 0, 0, box.size.x, box.size.y, 2.0); |
|
|
|
nvgFillColor(vg, nvgRGB(0, 0, 0)); |
|
|
|
nvgFill(vg); |
|
|
|
|
|
|
|
VCA_1 *module = dynamic_cast<VCA_1*>(this->module); |
|
|
|
|
|
|
|
const int segs = 25; |
|
|
|
const Vec margin = Vec(4, 4); |
|
|
|
Rect r = box.zeroPos().shrink(margin); |
|
|
|
|
|
|
|
for (int i = 0; i < segs; i++) { |
|
|
|
float segValue = clamp(value * segs - (segs - i - 1), 0.f, 1.f); |
|
|
|
float amplitude = value * module->lastCv; |
|
|
|
float segAmplitude = clamp(amplitude * segs - (segs - i - 1), 0.f, 1.f); |
|
|
|
nvgBeginPath(vg); |
|
|
|
nvgRect(vg, r.pos.x, r.pos.y + r.size.y / segs * i, |
|
|
|
r.size.x + 0.5, r.size.y / segs - 1.0); |
|
|
|
if (segValue > 0.f) { |
|
|
|
nvgFillColor(vg, colorAlpha(nvgRGBf(0.33, 0.33, 0.33), segValue)); |
|
|
|
nvgFill(vg); |
|
|
|
} |
|
|
|
if (segAmplitude > 0.f) { |
|
|
|
nvgFillColor(vg, colorAlpha(COLOR_GREEN, segAmplitude)); |
|
|
|
nvgFill(vg); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
struct VCA_1Widget : ModuleWidget { |
|
|
|
VCA_1Widget(VCA_1 *module) : ModuleWidget(module) { |
|
|
|
setPanel(SVG::load(assetPlugin(plugin, "res/VCA-1.svg"))); |
|
|
|
|
|
|
|
addChild(Widget::create<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0))); |
|
|
|
addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0))); |
|
|
|
addChild(Widget::create<ScrewSilver>(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); |
|
|
|
addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); |
|
|
|
|
|
|
|
addParam(ParamWidget::create<VCA_1VUKnob>(mm2px(Vec(2.62103, 12.31692)), module, VCA_1::LEVEL_PARAM, 0.0, 1.0, 0.0)); |
|
|
|
addParam(ParamWidget::create<CKSS>(mm2px(Vec(5.24619, 79.9593)), module, VCA_1::EXP_PARAM, 0.0, 1.0, 1.0)); |
|
|
|
|
|
|
|
addInput(Port::create<PJ301MPort>(mm2px(Vec(3.51261, 60.4008)), Port::INPUT, module, VCA_1::CV_INPUT)); |
|
|
|
addInput(Port::create<PJ301MPort>(mm2px(Vec(3.51398, 97.74977)), Port::INPUT, module, VCA_1::IN_INPUT)); |
|
|
|
|
|
|
|
addOutput(Port::create<PJ301MPort>(mm2px(Vec(3.51398, 108.64454)), Port::OUTPUT, module, VCA_1::OUT_OUTPUT)); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
Model *modelVCA_1 = Model::create<VCA_1, VCA_1Widget>("Fundamental", "VCA-1", "VCA-1", AMPLIFIER_TAG); |
|
|
|
Model *modelVCA = Model::create<VCA, VCAWidget>("Fundamental", "VCA", "VCA-2", AMPLIFIER_TAG, DUAL_TAG); |