git.s-ol.nu vcvmods / ec9fd8b
update to rack v1 compat s-ol 14 days ago
4 changed file(s) with 47 addition(s) and 41 deletion(s). Raw diff Collapse all Expand all
2323
2424 CircleVCO() {
2525 config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
26 configParam(PITCH_PARAM, -54.0f, 54.0f, 0.0f);
2627 }
27 void step() override;
28 void process(const ProcessArgs &args) override;
2829 };
2930
3031
31 void CircleVCO::step() {
32 float deltaTime = 1.0f / engineGetSampleRate();
32 void CircleVCO::process(const ProcessArgs &args) {
33 float deltaTime = 1.0f / args.sampleRate;
3334
34 float pitch = params[PITCH_PARAM].value;
35 pitch += 12.0f * inputs[PITCH_INPUT].value;
35 float pitch = params[PITCH_PARAM].getValue();
36 pitch += 12.0f * inputs[PITCH_INPUT].getVoltage();
3637 float freq = 261.626f * powf(2.0f, pitch / 12.0f);
3738
3839 phase += freq * deltaTime;
4142
4243 float sine = sin(2.0f * M_PI * phase);
4344 float cosn = cos(2.0f * M_PI * phase);
44 outputs[SIN_OUTPUT].value = sine * 5.0f;
45 outputs[COS_OUTPUT].value = cosn * 5.0f;
46 outputs[PHS_OUTPUT].value = phase * 5.0f;
45 outputs[SIN_OUTPUT].setVoltage(sine * 5.0f);
46 outputs[COS_OUTPUT].setVoltage(cosn * 5.0f);
47 outputs[PHS_OUTPUT].setVoltage(phase * 5.0f);
4748 }
4849
4950
5354
5455 CircleVCOWidget::CircleVCOWidget(CircleVCO *module) {
5556 setModule(module);
56 setPanel(SVG::load(assetPlugin(pluginInstance, "res/CircleVCO.svg")));
57 setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/CircleVCO.svg")));
5758
5859 addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
5960 addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
6364 Vec center = Vec(box.size.x, 0).minus(p.box.size).div(2);
6465 Vec kcenter = Vec(box.size.x, 0).minus(k.box.size).div(2);
6566
66 addParam(createParam<RoundSmallBlackKnob>(kcenter.plus(Vec(0, 90)), module, CircleVCO::PITCH_PARAM, -54.0f, 54.0f, 0.0f));
67 addParam(createParam<RoundSmallBlackKnob>(kcenter.plus(Vec(0, 90)), module, CircleVCO::PITCH_PARAM));
6768
68 addInput(createPort<PJ301MPort>(center.plus(Vec(0, 144)), PortWidget::INPUT, module, CircleVCO::PITCH_INPUT));
69 addInput(createInput<PJ301MPort>(center.plus(Vec(0, 144)), module, CircleVCO::PITCH_INPUT));
6970
70 addOutput(createPort<PJ301MPort>(center.plus(Vec(0, 218)), PortWidget::OUTPUT, module, CircleVCO::SIN_OUTPUT));
71 addOutput(createPort<PJ301MPort>(center.plus(Vec(0, 268)), PortWidget::OUTPUT, module, CircleVCO::COS_OUTPUT));
72 addOutput(createPort<PJ301MPort>(center.plus(Vec(0, 318)), PortWidget::OUTPUT, module, CircleVCO::PHS_OUTPUT));
71 addOutput(createOutput<PJ301MPort>(center.plus(Vec(0, 218)), module, CircleVCO::SIN_OUTPUT));
72 addOutput(createOutput<PJ301MPort>(center.plus(Vec(0, 268)), module, CircleVCO::COS_OUTPUT));
73 addOutput(createOutput<PJ301MPort>(center.plus(Vec(0, 318)), module, CircleVCO::PHS_OUTPUT));
7374 }
7475
7576 Model *modelCircleVCO = createModel<CircleVCO, CircleVCOWidget>("CircleVCO");
2121
2222 Modulo() {
2323 config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
24 configParam(GAIN_PARAM, -3.0, 3.0, 0.0);
2425 }
25 void step() override;
26 void process(const ProcessArgs &args) override;
2627 };
2728
2829
29 void Modulo::step() {
30 float gain = powf(2.0, params[GAIN_PARAM].value) + inputs[GAIN_INPUT].value;
31 float val = inputs[SIGNAL_INPUT].value * gain;
30 void Modulo::process(const ProcessArgs &args) {
31 float gain = powf(2.0, params[GAIN_PARAM].getValue()) + inputs[GAIN_INPUT].getVoltage();
32 float val = inputs[SIGNAL_INPUT].getVoltage() * gain;
3233 float stair = floorf(val);
3334 float wrap = val - stair;
3435
35 outputs[STAIR_OUTPUT].value = stair / gain;;
36 outputs[WRAP_OUTPUT].value = wrap * 5;
36 outputs[STAIR_OUTPUT].setVoltage(stair / gain);;
37 outputs[WRAP_OUTPUT].setVoltage(wrap * 5);
3738 }
3839
3940
4344
4445 ModuloWidget::ModuloWidget(Modulo *module) {
4546 setModule(module);
46 setPanel(SVG::load(assetPlugin(pluginInstance, "res/Modulo.svg")));
47 setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/Modulo.svg")));
4748
4849 addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
4950 addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
5455 Vec kcenter = Vec(box.size.x, 0).minus(k.box.size).div(2);
5556
5657
57 addInput(createPort<PJ301MPort>(center.plus(Vec(0, 120)), PortWidget::INPUT, module, Modulo::SIGNAL_INPUT));
58 addInput(createPort<PJ301MPort>(center.plus(Vec(-15, 180)), PortWidget::INPUT, module, Modulo::GAIN_INPUT));
58 addInput(createInput<PJ301MPort>(center.plus(Vec(0, 120)), module, Modulo::SIGNAL_INPUT));
59 addInput(createInput<PJ301MPort>(center.plus(Vec(-15, 180)), module, Modulo::GAIN_INPUT));
5960
60 addParam(createParam<RoundSmallBlackKnob>(kcenter.plus(Vec(15, 180)), module, Modulo::GAIN_PARAM, -3.0, 3.0, 0.0));
61 addParam(createParam<RoundSmallBlackKnob>(kcenter.plus(Vec(15, 180)), module, Modulo::GAIN_PARAM));
6162
62 addOutput(createPort<PJ301MPort>(center.plus(Vec(0, 265)), PortWidget::OUTPUT, module, Modulo::STAIR_OUTPUT));
63 addOutput(createPort<PJ301MPort>(center.plus(Vec(0, 345)), PortWidget::OUTPUT, module, Modulo::WRAP_OUTPUT));
63 addOutput(createOutput<PJ301MPort>(center.plus(Vec(0, 265)), module, Modulo::STAIR_OUTPUT));
64 addOutput(createOutput<PJ301MPort>(center.plus(Vec(0, 345)), module, Modulo::WRAP_OUTPUT));
6465 }
6566
6667 Model *modelModulo = createModel<Modulo, ModuloWidget>("Modulo");
2626
2727 WrapComp() {
2828 config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
29 configParam(OFFSET_PARAM, -5.0, 5.0, 0.0);
30 configParam(RANGE_PARAM, -5.0, 5.0, 0.0);
31 configParam(A_OUT_PARAM, -8.0, 8.0, 1.0);
32 configParam(B_OUT_PARAM, -8.0, 8.0, 0.0);
2933 }
30 void step() override;
34 void process(const ProcessArgs &args) override;
3135 };
3236
3337
34 void WrapComp::step() {
35 float input = inputs[SIGNAL_INPUT].value + inputs[OFFSET_INPUT].normalize(0.0) + params[OFFSET_PARAM].value;
36 float width = clamp((inputs[RANGE_INPUT].normalize(0.0f) + params[RANGE_PARAM].value) / 2.0f, 0.0f, 5.0f);
38 void WrapComp::process(const ProcessArgs &args) {
39 float input = inputs[SIGNAL_INPUT].getVoltage() + inputs[OFFSET_INPUT].getNormalVoltage(0.0) + params[OFFSET_PARAM].getValue();
40 float width = clamp((inputs[RANGE_INPUT].getNormalVoltage(0.0f) + params[RANGE_PARAM].getValue()) / 2.0f, 0.0f, 5.0f);
3741
3842 while (input > 5.0)
3943 input -= 5.0;
4246
4347 bool a = input < width || input > (5.0 - width);
4448
45 outputs[MAIN_OUTPUT].value = a ? params[A_OUT_PARAM].value : params[B_OUT_PARAM].value;
49 outputs[MAIN_OUTPUT].setVoltage(a ? params[A_OUT_PARAM].getValue() : params[B_OUT_PARAM].getValue());
4650 lights[A_LIGHT].value = a ? 1.0 : 0.0;
4751 lights[B_LIGHT].value = a ? 0.0 : 1.0;
4852 }
5458
5559 WrapCompWidget::WrapCompWidget(WrapComp *module) {
5660 setModule(module);
57 setPanel(SVG::load(assetPlugin(pluginInstance, "res/WrapComp.svg")));
61 setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/WrapComp.svg")));
5862
5963 addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
6064 addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));
6872 Vec kcenter = Vec(box.size.x, 0).minus(k.box.size).div(2);
6973 Vec lcenter = Vec(box.size.x, 0).minus(l.box.size).div(2);
7074
71 addInput(createPort<PJ301MPort>(center.plus(Vec(0, 70)), PortWidget::INPUT, module, WrapComp::SIGNAL_INPUT));
75 addInput(createInput<PJ301MPort>(center.plus(Vec(0, 70)), module, WrapComp::SIGNAL_INPUT));
7276
73 addParam(createParam<RoundSmallBlackKnob>(kcenter.plus(Vec(25, 135)), module, WrapComp::OFFSET_PARAM, -5.0, 5.0, 0.0));
74 addInput(createPort<PJ301MPort>(center.plus(Vec(-25, 135)), PortWidget::INPUT, module, WrapComp::OFFSET_INPUT));
77 addParam(createParam<RoundSmallBlackKnob>(kcenter.plus(Vec(25, 135)), module, WrapComp::OFFSET_PARAM));
78 addInput(createInput<PJ301MPort>(center.plus(Vec(-25, 135)), module, WrapComp::OFFSET_INPUT));
7579
76 addParam(createParam<RoundSmallBlackKnob>(kcenter.plus(Vec(25, 210)), module, WrapComp::RANGE_PARAM, -5.0, 5.0, 0.0));
77 addInput(createPort<PJ301MPort>(center.plus(Vec(-25, 210)), PortWidget::INPUT, module, WrapComp::RANGE_INPUT));
80 addParam(createParam<RoundSmallBlackKnob>(kcenter.plus(Vec(25, 210)), module, WrapComp::RANGE_PARAM));
81 addInput(createInput<PJ301MPort>(center.plus(Vec(-25, 210)), module, WrapComp::RANGE_INPUT));
7882
7983 addChild(createLight<MediumLight<RedLight>>(lcenter.plus(Vec(-15, 255)), module, WrapComp::A_LIGHT));
8084 addChild(createLight<MediumLight<RedLight>>(lcenter.plus(Vec( 15, 255)), module, WrapComp::B_LIGHT));
8185
82 addParam(createParam<RoundSmallBlackKnob>(kcenter.plus(Vec(-25, 280)), module, WrapComp::A_OUT_PARAM, -8.0, 8.0, 1.0));
83 addParam(createParam<RoundSmallBlackKnob>(kcenter.plus(Vec( 25, 280)), module, WrapComp::B_OUT_PARAM, -8.0, 8.0, 0.0));
86 addParam(createParam<RoundSmallBlackKnob>(kcenter.plus(Vec(-25, 280)), module, WrapComp::A_OUT_PARAM));
87 addParam(createParam<RoundSmallBlackKnob>(kcenter.plus(Vec( 25, 280)), module, WrapComp::B_OUT_PARAM));
8488
85 addOutput(createPort<PJ301MPort>(center.plus(Vec(0, 315)), PortWidget::OUTPUT, module, WrapComp::MAIN_OUTPUT));
89 addOutput(createOutput<PJ301MPort>(center.plus(Vec(0, 315)), module, WrapComp::MAIN_OUTPUT));
8690 }
8791
8892 Model *modelWrapComp = createModel<WrapComp, WrapCompWidget>("WrapComp");
1 #include <rack0.hpp>
1 #include <rack.hpp>
22
33
44 using namespace rack;