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