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" );
0 commit comments