Browse Source

Add VCA-1, redesign VCA to VCA-2

tags/v1.0.1
Andrew Belt 6 years ago
parent
commit
5f24597b7c
5 changed files with 3395 additions and 267 deletions
  1. +2539
    -0
      res/VCA-1.svg
  2. +745
    -249
      res/VCA.svg
  3. +1
    -0
      src/Fundamental.cpp
  4. +1
    -0
      src/Fundamental.hpp
  5. +109
    -18
      src/VCA.cpp

+ 2539
- 0
res/VCA-1.svg
File diff suppressed because it is too large
View File


+ 745
- 249
res/VCA.svg
File diff suppressed because it is too large
View File


+ 1
- 0
src/Fundamental.cpp View File

@@ -11,6 +11,7 @@ void init(rack::Plugin *p) {
p->addModel(modelVCO);
p->addModel(modelVCO2);
p->addModel(modelVCF);
p->addModel(modelVCA_1);
p->addModel(modelVCA);
p->addModel(modelLFO);
p->addModel(modelLFO2);


+ 1
- 0
src/Fundamental.hpp View File

@@ -9,6 +9,7 @@ extern Plugin *plugin;
extern Model *modelVCO;
extern Model *modelVCO2;
extern Model *modelVCF;
extern Model *modelVCA_1;
extern Model *modelVCA;
extern Model *modelLFO;
extern Model *modelLFO2;


+ 109
- 18
src/VCA.cpp View File

@@ -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);

Loading…
Cancel
Save