commit 9feb37770b3297c9f10661d03dde7a8752f2c4eb
parent bb5bbfa1c0748d62b2f918e89c15ec42840c25de
Author: Adam M <[email protected]>
Date: Sun, 9 Feb 2020 18:32:02 -0600
Patrix workz
Diffstat:
1 file changed, 36 insertions(+), 25 deletions(-)
diff --git a/src/ComputerscareMolyPatrix.cpp b/src/ComputerscareMolyPatrix.cpp
@@ -3,13 +3,14 @@
struct ComputerscareMolyPatrix;
const int numKnobs = 256;
-const int numRows =16;
-const int numColumns=16;
+const int numRows = 16;
+const int numColumns = 16;
const int numOutputs = 1;
struct ComputerscareMolyPatrix : Module {
int counter = 0;
+ int numInputChannels = 0;
ComputerscareSVGPanel* panelRef;
enum ParamIds {
KNOB,
@@ -17,7 +18,7 @@ struct ComputerscareMolyPatrix : Module {
};
enum InputIds {
- CHANNEL_INPUT,
+ POLY_INPUT,
NUM_INPUTS
};
enum OutputIds {
@@ -32,14 +33,14 @@ struct ComputerscareMolyPatrix : Module {
ComputerscareMolyPatrix() {
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
- for(int n = 0; n < numKnobs; n++) {
+ /*for(int n = 0; n < numKnobs; n++) {
configParam(KNOB+n,-1.f,1.f,0.f);
- }
- /* for (int i = 0; i < numRows; i++) {
- for(int j = 0; j < numColumns; j++) {
- configParam(KNOB + i*16+j, -10.f, 10.f, 0.f);
- }
}*/
+ for (int i = 0; i < numRows; i++) {
+ for (int j = 0; j < numColumns; j++) {
+ configParam(KNOB + i * 16 + j, -2.f, 2.f, i == j ? 1.f : 0.f, "i:" + std::to_string(i) + ",j:" + std::to_string(j));
+ }
+ }
}
void process(const ProcessArgs &args) override {
@@ -50,9 +51,14 @@ struct ComputerscareMolyPatrix : Module {
//rect4032
//south facing high wall
}
+ numInputChannels = inputs[POLY_INPUT].getChannels();
outputs[POLY_OUTPUT].setChannels(16);
- for (int i = 0; i < 16; i++) {
- outputs[POLY_OUTPUT].setVoltage(params[KNOB + i].getValue(), i);
+ for (int j = 0; j < numRows; j++) {
+ float out = 0.f;
+ for (int i = 0; i < numColumns; i++) {
+ out += params[KNOB + j * 16 + i].getValue() * inputs[POLY_INPUT].getVoltage(i);
+ }
+ outputs[POLY_OUTPUT].setVoltage(out, j);
}
}
@@ -63,7 +69,7 @@ struct ComputerscareMolyPatrixWidget : ModuleWidget {
setModule(module);
//setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/ComputerscareMolyPatrixPanel.svg")));
- box.size = Vec(12 * 15, 380);
+ box.size = Vec(24 * 15, 380);
{
ComputerscareSVGPanel *panel = new ComputerscareSVGPanel();
panel->box.size = box.size;
@@ -76,32 +82,37 @@ struct ComputerscareMolyPatrixWidget : ModuleWidget {
}
float xx;
float yy;
+ float x0 = 6;
+ float dx = 22;
+ float y0 = 40;
+ float dy = 21;
for (int i = 0; i < numRows; i++) {
- for(int j = 0; j < numColumns; j++) {
- xx = 10+j*10;
- yy = 10+i*10;
- addLabeledKnob(std::to_string(i + 1), xx, yy, module, i*16+j, 0, 0);
- }
+ for (int j = 0; j < numColumns; j++) {
+ xx = x0 + j * dx;
+ yy = y0 + i * dy;
+ addLabeledKnob(std::to_string(i + 1), xx, yy, module, i * 16 + j, 0, 0);
+ }
}
+ addInput(createInput<PointingUpPentagonPort>(Vec(18, 4), module, ComputerscareMolyPatrix::POLY_INPUT));
- addOutput(createOutput<PointingUpPentagonPort>(Vec(28, 24), module, ComputerscareMolyPatrix::POLY_OUTPUT));
+ addOutput(createOutput<PointingUpPentagonPort>(Vec(298, 4), module, ComputerscareMolyPatrix::POLY_OUTPUT));
}
void addLabeledKnob(std::string label, int x, int y, ComputerscareMolyPatrix *module, int index, float labelDx, float labelDy) {
- smallLetterDisplay = new SmallLetterDisplay();
- smallLetterDisplay->box.size = Vec(5, 10);
- smallLetterDisplay->fontSize = 16;
- smallLetterDisplay->value = label;
- smallLetterDisplay->textAlign = 1;
+ /* smallLetterDisplay = new SmallLetterDisplay();
+ smallLetterDisplay->box.size = Vec(5, 10);
+ smallLetterDisplay->fontSize = 16;
+ smallLetterDisplay->value = label;
+ smallLetterDisplay->textAlign = 1;*/
addParam(createParam<ComputerscareDotKnob>(Vec(x, y), module, ComputerscareMolyPatrix::KNOB + index));
- smallLetterDisplay->box.pos = Vec(x + labelDx, y - 12 + labelDy);
+ //smallLetterDisplay->box.pos = Vec(x + labelDx, y - 12 + labelDy);
- addChild(smallLetterDisplay);
+// addChild(smallLetterDisplay);
}
SmallLetterDisplay* smallLetterDisplay;