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