Skip to content

Commit 5ac5fd7

Browse files
committed
Added clock sync
1 parent 6f2aff8 commit 5ac5fd7

5 files changed

Lines changed: 218 additions & 161 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/build
22
/dist
3+
/dep
34
/*.so
45
/*.dylib
56
/*.dll

res/matrix-sequencer.svg

Lines changed: 1 addition & 1 deletion
Loading

src/matrix-sequencer.cpp

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
#include "matrix-sequencer.hpp"
2+
3+
4+
Matrix_sequencer::Matrix_sequencer()
5+
{
6+
{
7+
config(PARAMS_LEN, INPUTS_LEN, OUTPUTS_LEN, LIGHTS_LEN);
8+
configParam(X1_Y1_KNOB_PARAM, -10.f, 10.f, 0.f, "(1; 1)", "V");
9+
configParam(X2_Y1_KNOB_PARAM, -10.f, 10.f, 0.f, "(2; 1)", "V");
10+
configParam(X3_Y1_KNOB_PARAM, -10.f, 10.f, 0.f, "(3; 1)", "V");
11+
configParam(X4_Y1_KNOB_PARAM, -10.f, 10.f, 0.f, "(4; 1)", "V");
12+
configParam(X1_Y2_KNOB_PARAM, -10.f, 10.f, 0.f, "(1; 2)", "V");
13+
configParam(X2_Y2_KNOB_PARAM, -10.f, 10.f, 0.f, "(2; 2)", "V");
14+
configParam(X3_Y2_KNOB_PARAM, -10.f, 10.f, 0.f, "(3; 2)", "V");
15+
configParam(X4_Y2_KNOB_PARAM, -10.f, 10.f, 0.f, "(4; 2)", "V");
16+
configParam(X1_Y3_KNOB_PARAM, -10.f, 10.f, 0.f, "(1; 3)", "V");
17+
configParam(X2_Y3_KNOB_PARAM, -10.f, 10.f, 0.f, "(2; 3)", "V");
18+
configParam(X3_Y3_KNOB_PARAM, -10.f, 10.f, 0.f, "(3; 3)", "V");
19+
configParam(X4_Y3_KNOB_PARAM, -10.f, 10.f, 0.f, "(4; 3)", "V");
20+
configParam(X1_Y4_KNOB_PARAM, -10.f, 10.f, 0.f, "(1; 4)", "V");
21+
configParam(X2_Y4_KNOB_PARAM, -10.f, 10.f, 0.f, "(2; 4)", "V");
22+
configParam(X3_Y4_KNOB_PARAM, -10.f, 10.f, 0.f, "(3; 4)", "V");
23+
configParam(X4_Y4_KNOB_PARAM, -10.f, 10.f, 0.f, "(4; 4)", "V");
24+
configInput(CLOCK_IN_INPUT, "Clock");
25+
configInput(RUN_IN_INPUT, "Start sequence");
26+
configInput(RESET_IN_INPUT, "Reset sequence");
27+
configOutput(Y1_OUT_OUTPUT, "Out Y:1");
28+
configOutput(Y2_OUT_OUTPUT, "Out Y:2");
29+
configOutput(Y3_OUT_OUTPUT, "Out Y:3");
30+
configOutput(Y4_OUT_OUTPUT, "Out Y:4");
31+
configOutput(X1_OUT_OUTPUT, "Out X:1");
32+
configOutput(X2_OUT_OUTPUT, "Out X:2");
33+
configOutput(X3_OUT_OUTPUT, "Out X:3");
34+
configOutput(X4_OUT_OUTPUT, "Out X:4");
35+
configOutput(TOTAL_PITCH_OUT_OUTPUT, "Sequence output");
36+
}
37+
38+
_run = false;
39+
_reset = false;
40+
_current_step = X4_Y4_LIGHT_LIGHT;
41+
}
42+
43+
void Matrix_sequencer::process(const ProcessArgs& args)
44+
{
45+
if (inputs[RUN_IN_INPUT].getVoltage())
46+
_run = !_run;
47+
48+
// Reset sequencer
49+
if (inputs[RESET_IN_INPUT].getVoltage())
50+
{
51+
lights[_current_step].setBrightness(0);
52+
_current_step = X4_Y4_LIGHT_LIGHT;
53+
}
54+
55+
// Process trigger clock
56+
if (clockTrigger.process(inputs[CLOCK_IN_INPUT].getVoltage()))
57+
{
58+
// Turn off current light
59+
lights[_current_step].setBrightness(0);
60+
61+
// Switch light
62+
_current_step++ ;
63+
_current_step %= LIGHTS_LEN;
64+
65+
// Turn on new light
66+
lights[_current_step].setBrightness(1);
67+
}
68+
}
69+
70+
71+
Matrix_sequencerWidget::Matrix_sequencerWidget(Matrix_sequencer* module) {
72+
setModule(module);
73+
setPanel(createPanel(asset::plugin(pluginInstance, "res/matrix-sequencer.svg")));
74+
75+
addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
76+
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));
77+
addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
78+
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
79+
80+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(35.56, 20.32)), module, Matrix_sequencer::X1_Y1_KNOB_PARAM));
81+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(63.5, 20.32)), module, Matrix_sequencer::X2_Y1_KNOB_PARAM));
82+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(91.44, 20.32)), module, Matrix_sequencer::X3_Y1_KNOB_PARAM));
83+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(119.38, 20.32)), module, Matrix_sequencer::X4_Y1_KNOB_PARAM));
84+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(35.56, 43.18)), module, Matrix_sequencer::X1_Y2_KNOB_PARAM));
85+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(63.5, 43.18)), module, Matrix_sequencer::X2_Y2_KNOB_PARAM));
86+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(91.44, 43.18)), module, Matrix_sequencer::X3_Y2_KNOB_PARAM));
87+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(119.38, 43.18)), module, Matrix_sequencer::X4_Y2_KNOB_PARAM));
88+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(35.56, 66.04)), module, Matrix_sequencer::X1_Y3_KNOB_PARAM));
89+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(63.5, 66.04)), module, Matrix_sequencer::X2_Y3_KNOB_PARAM));
90+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(91.44, 66.04)), module, Matrix_sequencer::X3_Y3_KNOB_PARAM));
91+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(119.38, 66.04)), module, Matrix_sequencer::X4_Y3_KNOB_PARAM));
92+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(35.56, 88.9)), module, Matrix_sequencer::X1_Y4_KNOB_PARAM));
93+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(63.5, 88.9)), module, Matrix_sequencer::X2_Y4_KNOB_PARAM));
94+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(91.44, 88.9)), module, Matrix_sequencer::X3_Y4_KNOB_PARAM));
95+
addParam(createParamCentered<RoundBlackKnob>(mm2px(Vec(119.38, 88.9)), module, Matrix_sequencer::X4_Y4_KNOB_PARAM));
96+
97+
addInput(createInputCentered<PJ301MPort>(mm2px(Vec(12.7, 25.4)), module, Matrix_sequencer::CLOCK_IN_INPUT));
98+
addInput(createInputCentered<PJ301MPort>(mm2px(Vec(12.7, 43.18)), module, Matrix_sequencer::RUN_IN_INPUT));
99+
addInput(createInputCentered<PJ301MPort>(mm2px(Vec(12.7, 60.96)), module, Matrix_sequencer::RESET_IN_INPUT));
100+
101+
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(137.16, 20.32)), module, Matrix_sequencer::Y1_OUT_OUTPUT));
102+
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(137.16, 43.18)), module, Matrix_sequencer::Y2_OUT_OUTPUT));
103+
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(137.16, 66.04)), module, Matrix_sequencer::Y3_OUT_OUTPUT));
104+
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(137.16, 88.9)), module, Matrix_sequencer::Y4_OUT_OUTPUT));
105+
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(35.56, 119.38)), module, Matrix_sequencer::X1_OUT_OUTPUT));
106+
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(63.5, 119.38)), module, Matrix_sequencer::X2_OUT_OUTPUT));
107+
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(91.44, 119.38)), module, Matrix_sequencer::X3_OUT_OUTPUT));
108+
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(119.38, 119.38)), module, Matrix_sequencer::X4_OUT_OUTPUT));
109+
addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(137.16, 119.38)), module, Matrix_sequencer::TOTAL_PITCH_OUT_OUTPUT));
110+
111+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(35.56, 31.75)), module, Matrix_sequencer::X1_Y1_LIGHT_LIGHT));
112+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(63.5, 31.75)), module, Matrix_sequencer::X2_Y1_LIGHT_LIGHT));
113+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(91.44, 31.75)), module, Matrix_sequencer::X3_Y1_LIGHT_LIGHT));
114+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(119.38, 31.75)), module, Matrix_sequencer::X4_Y1_LIGHT_LIGHT));
115+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(35.56, 54.61)), module, Matrix_sequencer::X1_Y2_LIGHT_LIGHT));
116+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(63.5, 54.61)), module, Matrix_sequencer::X2_Y2_LIGHT_LIGHT));
117+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(91.44, 54.61)), module, Matrix_sequencer::X3_Y2_LIGHT_LIGHT));
118+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(119.38, 54.61)), module, Matrix_sequencer::X4_Y2_LIGHT_LIGHT));
119+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(35.56, 77.47)), module, Matrix_sequencer::X1_Y3_LIGHT_LIGHT));
120+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(63.5, 77.47)), module, Matrix_sequencer::X2_Y3_LIGHT_LIGHT));
121+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(91.44, 77.47)), module, Matrix_sequencer::X3_Y3_LIGHT_LIGHT));
122+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(119.38, 77.47)), module, Matrix_sequencer::X4_Y3_LIGHT_LIGHT));
123+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(35.56, 100.33)), module, Matrix_sequencer::X1_Y4_LIGHT_LIGHT));
124+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(63.5, 100.33)), module, Matrix_sequencer::X2_Y4_LIGHT_LIGHT));
125+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(91.44, 100.33)), module, Matrix_sequencer::X3_Y4_LIGHT_LIGHT));
126+
addChild(createLightCentered<MediumLight<GreenLight>>(mm2px(Vec(119.38, 100.33)), module, Matrix_sequencer::X4_Y4_LIGHT_LIGHT));
127+
}
128+
129+
130+
131+
Model* modelMatrix_sequencer = createModel<Matrix_sequencer, Matrix_sequencerWidget>("matrix-sequencer");

src/matrix-sequencer.hpp

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#ifndef MATRIX_SEQUNCER
2+
#define MATRIX_SEQUNCER
3+
4+
#include "plugin.hpp"
5+
6+
struct Matrix_sequencer : Module {
7+
enum ParamId {
8+
X1_Y1_KNOB_PARAM,
9+
X2_Y1_KNOB_PARAM,
10+
X3_Y1_KNOB_PARAM,
11+
X4_Y1_KNOB_PARAM,
12+
X1_Y2_KNOB_PARAM,
13+
X2_Y2_KNOB_PARAM,
14+
X3_Y2_KNOB_PARAM,
15+
X4_Y2_KNOB_PARAM,
16+
X1_Y3_KNOB_PARAM,
17+
X2_Y3_KNOB_PARAM,
18+
X3_Y3_KNOB_PARAM,
19+
X4_Y3_KNOB_PARAM,
20+
X1_Y4_KNOB_PARAM,
21+
X2_Y4_KNOB_PARAM,
22+
X3_Y4_KNOB_PARAM,
23+
X4_Y4_KNOB_PARAM,
24+
PARAMS_LEN
25+
};
26+
27+
enum InputId {
28+
CLOCK_IN_INPUT,
29+
RUN_IN_INPUT,
30+
RESET_IN_INPUT,
31+
INPUTS_LEN
32+
};
33+
34+
enum OutputId {
35+
Y1_OUT_OUTPUT,
36+
Y2_OUT_OUTPUT,
37+
Y3_OUT_OUTPUT,
38+
Y4_OUT_OUTPUT,
39+
X1_OUT_OUTPUT,
40+
X2_OUT_OUTPUT,
41+
X3_OUT_OUTPUT,
42+
X4_OUT_OUTPUT,
43+
TOTAL_PITCH_OUT_OUTPUT,
44+
OUTPUTS_LEN
45+
};
46+
47+
enum LightId {
48+
X1_Y1_LIGHT_LIGHT,
49+
X2_Y1_LIGHT_LIGHT,
50+
X3_Y1_LIGHT_LIGHT,
51+
X4_Y1_LIGHT_LIGHT,
52+
X1_Y2_LIGHT_LIGHT,
53+
X2_Y2_LIGHT_LIGHT,
54+
X3_Y2_LIGHT_LIGHT,
55+
X4_Y2_LIGHT_LIGHT,
56+
X1_Y3_LIGHT_LIGHT,
57+
X2_Y3_LIGHT_LIGHT,
58+
X3_Y3_LIGHT_LIGHT,
59+
X4_Y3_LIGHT_LIGHT,
60+
X1_Y4_LIGHT_LIGHT,
61+
X2_Y4_LIGHT_LIGHT,
62+
X3_Y4_LIGHT_LIGHT,
63+
X4_Y4_LIGHT_LIGHT,
64+
LIGHTS_LEN
65+
};
66+
67+
Matrix_sequencer();
68+
69+
void process(const ProcessArgs& args) override;
70+
71+
void updateSequence();
72+
73+
private:
74+
bool _run;
75+
bool _reset;
76+
uint8_t _current_step;
77+
dsp::SchmittTrigger clockTrigger;
78+
};
79+
80+
struct Matrix_sequencerWidget : ModuleWidget
81+
{
82+
Matrix_sequencerWidget(Matrix_sequencer* module);
83+
};
84+
85+
#endif

src/matrix-sequncer.cpp

Lines changed: 0 additions & 160 deletions
This file was deleted.

0 commit comments

Comments
 (0)