git.s-ol.nu vcvmods / 3fd5778
Update to Rack API v0.6. Christoph Scholtes authored 4 years ago s-ol committed 4 years ago
6 changed file(s) with 64 addition(s) and 79 deletion(s). Raw diff Collapse all Expand all
0 SLUG = s-ol
1 VERSION = 0.6.0
02
13 # FLAGS will be passed to both the C and C++ compiler
24 FLAGS +=
79 # Static libraries are fine.
810 LDFLAGS +=
911
10 # Add .cpp and .c files to the build
11 SOURCES = $(wildcard src/*.cpp)
12 SOURCES += $(wildcard src/*.cpp)
1213
14 DISTRIBUTABLES += $(wildcard LICENSE*) res
1315
14 # Must include the VCV plugin Makefile framework
15 include ../../plugin.mk
16
17
18 # Convenience target for including files in the distributable release
19 DIST_NAME = solmods
20 .PHONY: dist
21 dist: all
22 ifndef VERSION
23 $(error VERSION must be defined when making distributables)
24 endif
25 mkdir -p dist/$(DIST_NAME)
26 cp LICENSE* README* dist/$(DIST_NAME)/
27 cp $(TARGET) dist/$(DIST_NAME)/
28 cp -R res dist/$(DIST_NAME)/
29 cd dist && zip -5 -r $(DIST_NAME)-$(VERSION)-$(ARCH).zip $(DIST_NAME)
16 RACK_DIR ?= ../..
17 include $(RACK_DIR)/plugin.mk
3030
3131 float pitch = params[PITCH_PARAM].value;
3232 pitch += inputs[PITCH_INPUT].value;
33 pitch = clampf(pitch, -4.0, 4.0);
33 pitch = clamp(pitch, -4.0f, 4.0f);
3434 float freq = 200 * (powf(2.0, pitch) - powf(2.0, -4.0));
3535
3636 phase += freq * deltaTime;
4545 }
4646
4747
48 CircleVCOWidget::CircleVCOWidget() {
49 CircleVCO *module = new CircleVCO();
50 setModule(module);
48 struct CircleVCOWidget : ModuleWidget {
49 CircleVCOWidget(CircleVCO *module);
50 };
51
52 CircleVCOWidget::CircleVCOWidget(CircleVCO *module) : ModuleWidget(module) {
5153 setPanel(SVG::load(assetPlugin(plugin, "res/CircleVCO.svg")));
5254
53 addChild(createScrew<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
54 addChild(createScrew<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
55 addChild(Widget::create<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
56 addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
5557
5658 PJ301MPort p;
5759 RoundSmallBlackKnob k;
5860 Vec center = Vec(box.size.x, 0).minus(p.box.size).div(2);
5961 Vec kcenter = Vec(box.size.x, 0).minus(k.box.size).div(2);
6062
61 addParam(createParam<RoundSmallBlackKnob>(kcenter.plus(Vec(0, 90)), module, CircleVCO::PITCH_PARAM, 0.0, 1.0, 0.0));
63 addParam(ParamWidget::create<RoundSmallBlackKnob>(kcenter.plus(Vec(0, 90)), module, CircleVCO::PITCH_PARAM, 0.0, 1.0, 0.0));
6264
63 addInput(createInput<PJ301MPort>(center.plus(Vec(0, 144)), module, CircleVCO::PITCH_INPUT));
65 addInput(Port::create<PJ301MPort>(center.plus(Vec(0, 144)), Port::INPUT, module, CircleVCO::PITCH_INPUT));
6466
65 addOutput(createOutput<PJ301MPort>(center.plus(Vec(0, 218)), module, CircleVCO::SIN_OUTPUT));
66 addOutput(createOutput<PJ301MPort>(center.plus(Vec(0, 268)), module, CircleVCO::COS_OUTPUT));
67 addOutput(createOutput<PJ301MPort>(center.plus(Vec(0, 318)), module, CircleVCO::PHS_OUTPUT));
67 addOutput(Port::create<PJ301MPort>(center.plus(Vec(0, 218)), Port::OUTPUT, module, CircleVCO::SIN_OUTPUT));
68 addOutput(Port::create<PJ301MPort>(center.plus(Vec(0, 268)), Port::OUTPUT, module, CircleVCO::COS_OUTPUT));
69 addOutput(Port::create<PJ301MPort>(center.plus(Vec(0, 318)), Port::OUTPUT, module, CircleVCO::PHS_OUTPUT));
6870 }
71
72 Model *modelCircleVCO = Model::create<CircleVCO, CircleVCOWidget>("s-ol", "CircleVCO", "Circle VCO", OSCILLATOR_TAG, VISUAL_TAG);
3434 }
3535
3636
37 ModuloWidget::ModuloWidget() {
38 Modulo *module = new Modulo();
39 setModule(module);
37 struct ModuloWidget : ModuleWidget {
38 ModuloWidget(Modulo *module);
39 };
40
41 ModuloWidget::ModuloWidget(Modulo *module) : ModuleWidget(module) {
4042 setPanel(SVG::load(assetPlugin(plugin, "res/Modulo.svg")));
4143
42 addChild(createScrew<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
43 addChild(createScrew<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
44 addChild(Widget::create<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
45 addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
4446
4547 PJ301MPort p;
4648 RoundSmallBlackKnob k;
4850 Vec kcenter = Vec(box.size.x, 0).minus(k.box.size).div(2);
4951
5052
51 addInput(createInput<PJ301MPort>(center.plus(Vec(0, 120)), module, Modulo::SIGNAL_INPUT));
52 addInput(createInput<PJ301MPort>(center.plus(Vec(-15, 180)), module, Modulo::GAIN_INPUT));
53 addInput(Port::create<PJ301MPort>(center.plus(Vec(0, 120)), Port::INPUT, module, Modulo::SIGNAL_INPUT));
54 addInput(Port::create<PJ301MPort>(center.plus(Vec(-15, 180)), Port::INPUT, module, Modulo::GAIN_INPUT));
5355
54 addParam(createParam<RoundSmallBlackKnob>(kcenter.plus(Vec(15, 180)), module, Modulo::GAIN_PARAM, -3.0, 3.0, 0.0));
56 addParam(ParamWidget::create<RoundSmallBlackKnob>(kcenter.plus(Vec(15, 180)), module, Modulo::GAIN_PARAM, -3.0, 3.0, 0.0));
5557
56 addOutput(createOutput<PJ301MPort>(center.plus(Vec(0, 265)), module, Modulo::STAIR_OUTPUT));
57 addOutput(createOutput<PJ301MPort>(center.plus(Vec(0, 345)), module, Modulo::WRAP_OUTPUT));
58 addOutput(Port::create<PJ301MPort>(center.plus(Vec(0, 265)), Port::OUTPUT, module, Modulo::STAIR_OUTPUT));
59 addOutput(Port::create<PJ301MPort>(center.plus(Vec(0, 345)), Port::OUTPUT, module, Modulo::WRAP_OUTPUT));
5860 }
61
62 Model *modelModulo = Model::create<Modulo, ModuloWidget>("s-ol", "Modulo", "Modulo", LOGIC_TAG);
3030
3131 void WrapComp::step() {
3232 float input = inputs[SIGNAL_INPUT].value + inputs[OFFSET_INPUT].normalize(0.0) + params[OFFSET_PARAM].value;
33 float width = clampf((inputs[RANGE_INPUT].normalize(0.0) + params[RANGE_PARAM].value) / 2.0, 0.0, 5.0);
33 float width = clamp((inputs[RANGE_INPUT].normalize(0.0f) + params[RANGE_PARAM].value) / 2.0f, 0.0f, 5.0f);
3434
3535 while (input > 5.0)
3636 input -= 5.0;
4545 }
4646
4747
48 WrapCompWidget::WrapCompWidget() {
49 WrapComp *module = new WrapComp();
50 setModule(module);
48 struct WrapCompWidget : ModuleWidget {
49 WrapCompWidget(WrapComp *module);
50 };
51
52 WrapCompWidget::WrapCompWidget(WrapComp *module) : ModuleWidget(module) {
5153 setPanel(SVG::load(assetPlugin(plugin, "res/WrapComp.svg")));
5254
53 addChild(createScrew<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
54 addChild(createScrew<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));
55 addChild(createScrew<ScrewSilver>(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
56 addChild(createScrew<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
55 addChild(Widget::create<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
56 addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));
57 addChild(Widget::create<ScrewSilver>(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
58 addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
5759
5860 PJ301MPort p;
5961 RoundSmallBlackKnob k;
6264 Vec kcenter = Vec(box.size.x, 0).minus(k.box.size).div(2);
6365 Vec lcenter = Vec(box.size.x, 0).minus(l.box.size).div(2);
6466
65 addInput(createInput<PJ301MPort>(center.plus(Vec(0, 70)), module, WrapComp::SIGNAL_INPUT));
67 addInput(Port::create<PJ301MPort>(center.plus(Vec(0, 70)), Port::INPUT, module, WrapComp::SIGNAL_INPUT));
6668
67 addParam(createParam<RoundSmallBlackKnob>(kcenter.plus(Vec(25, 135)), module, WrapComp::OFFSET_PARAM, -5.0, 5.0, 0.0));
68 addInput(createInput<PJ301MPort>(center.plus(Vec(-25, 135)), module, WrapComp::OFFSET_INPUT));
69 addParam(ParamWidget::create<RoundSmallBlackKnob>(kcenter.plus(Vec(25, 135)), module, WrapComp::OFFSET_PARAM, -5.0, 5.0, 0.0));
70 addInput(Port::create<PJ301MPort>(center.plus(Vec(-25, 135)), Port::INPUT, module, WrapComp::OFFSET_INPUT));
6971
70 addParam(createParam<RoundSmallBlackKnob>(kcenter.plus(Vec(25, 210)), module, WrapComp::RANGE_PARAM, -5.0, 5.0, 0.0));
71 addInput(createInput<PJ301MPort>(center.plus(Vec(-25, 210)), module, WrapComp::RANGE_INPUT));
72 addParam(ParamWidget::create<RoundSmallBlackKnob>(kcenter.plus(Vec(25, 210)), module, WrapComp::RANGE_PARAM, -5.0, 5.0, 0.0));
73 addInput(Port::create<PJ301MPort>(center.plus(Vec(-25, 210)), Port::INPUT, module, WrapComp::RANGE_INPUT));
7274
73 addChild(createLight<MediumLight<RedLight>>(lcenter.plus(Vec(-15, 255)), module, WrapComp::A_LIGHT));
74 addChild(createLight<MediumLight<RedLight>>(lcenter.plus(Vec( 15, 255)), module, WrapComp::B_LIGHT));
75 addChild(ModuleLightWidget::create<MediumLight<RedLight>>(lcenter.plus(Vec(-15, 255)), module, WrapComp::A_LIGHT));
76 addChild(ModuleLightWidget::create<MediumLight<RedLight>>(lcenter.plus(Vec( 15, 255)), module, WrapComp::B_LIGHT));
7577
76 addParam(createParam<RoundSmallBlackKnob>(kcenter.plus(Vec(-25, 280)), module, WrapComp::A_OUT_PARAM, -8.0, 8.0, 1.0));
77 addParam(createParam<RoundSmallBlackKnob>(kcenter.plus(Vec( 25, 280)), module, WrapComp::B_OUT_PARAM, -8.0, 8.0, 0.0));
78 addParam(ParamWidget::create<RoundSmallBlackKnob>(kcenter.plus(Vec(-25, 280)), module, WrapComp::A_OUT_PARAM, -8.0, 8.0, 1.0));
79 addParam(ParamWidget::create<RoundSmallBlackKnob>(kcenter.plus(Vec( 25, 280)), module, WrapComp::B_OUT_PARAM, -8.0, 8.0, 0.0));
7880
79 addOutput(createOutput<PJ301MPort>(center.plus(Vec(0, 315)), module, WrapComp::MAIN_OUTPUT));
81 addOutput(Port::create<PJ301MPort>(center.plus(Vec(0, 315)), Port::OUTPUT, module, WrapComp::MAIN_OUTPUT));
8082 }
83
84 Model *modelWrapComp = Model::create<WrapComp, WrapCompWidget>("s-ol", "WrapComp", "Wrapping Comparator", LOGIC_TAG);
44 void init(rack::Plugin *p) {
55 plugin = p;
66
7 p->slug = "s-ol";
8 #ifdef VERSION
7 p->slug = TOSTRING(SLUG);
98 p->version = TOSTRING(VERSION);
10 #endif
119 p->website = "https://github.com/s-ol/vcvmods";
1210 p->manual = "https://github.com/s-ol/vcvmods";
1311
14 p->addModel(createModel<CircleVCOWidget>("s-ol", "CircleVCO", "Circle VCO", OSCILLATOR_TAG, VISUAL_TAG));
15 p->addModel(createModel<WrapCompWidget>("s-ol", "WrapComp", "Wrapping Comparator", LOGIC_TAG));
16 p->addModel(createModel<ModuloWidget>("s-ol", "Modulo", "Modulo", LOGIC_TAG));
12 p->addModel(modelCircleVCO);
13 p->addModel(modelWrapComp);
14 p->addModel(modelModulo);
1715 }
22
33 using namespace rack;
44
5
65 extern Plugin *plugin;
76
8 ////////////////////
9 // module widgets
10 ////////////////////
11
12 struct CircleVCOWidget : ModuleWidget {
13 CircleVCOWidget();
14 };
15
16 struct WrapCompWidget : ModuleWidget {
17 WrapCompWidget();
18 };
19
20 struct ModuloWidget : ModuleWidget {
21 ModuloWidget();
22 };
7 extern Model *modelCircleVCO;
8 extern Model *modelWrapComp;
9 extern Model *modelModulo;