Browse Source

Clean up new poly modules for v1 release.

tags/v1.0.1
Andrew Belt 6 years ago
parent
commit
fc9d634646
4 changed files with 35 additions and 39 deletions
  1. +4
    -6
      src/Merge.cpp
  2. +5
    -4
      src/Split.cpp
  3. +0
    -1
      src/Sum.cpp
  4. +26
    -28
      src/Viz.cpp

+ 4
- 6
src/Merge.cpp View File

@@ -18,10 +18,11 @@ struct Merge : Module {
NUM_LIGHTS
};

int lightFrame = 0;
dsp::Counter lightCounter;

Merge() {
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
lightCounter.setPeriod(512);
}

void process(const ProcessArgs &args) override {
@@ -32,16 +33,13 @@ struct Merge : Module {
float v = inputs[MONO_INPUTS + c].getVoltage();
outputs[POLY_OUTPUT].setVoltage(v, c);
}
else {
outputs[POLY_OUTPUT].setVoltage(0.f, c);
}
}

// This also sets higher channels to 0V if the number of channels shrinks.
outputs[POLY_OUTPUT].setChannels(lastChannel + 1);

// Set channel lights infrequently
if (++lightFrame >= 512) {
lightFrame = 0;
if (lightCounter.process()) {
for (int c = 0; c < 16; c++) {
bool active = (c < outputs[POLY_OUTPUT].getChannels());
lights[CHANNEL_LIGHTS + c].setBrightness(active);


+ 5
- 4
src/Split.cpp View File

@@ -18,21 +18,22 @@ struct Split : Module {
NUM_LIGHTS
};

dsp::Counter lightCounter;

Split() {
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
lightCounter.setPeriod(512);
}

int lightFrame = 0;

void process(const ProcessArgs &args) override {
for (int c = 0; c < 16; c++) {
float v = inputs[POLY_INPUT].getVoltage(c);
// To allow users to debug buggy modules, don't assume that undefined channels are 0V.
outputs[MONO_OUTPUTS + c].setVoltage(v);
}

// Set channel lights infrequently
if (++lightFrame >= 512) {
lightFrame = 0;
if (lightCounter.process()) {
for (int c = 0; c < 16; c++) {
bool active = (c < inputs[POLY_INPUT].getChannels());
lights[CHANNEL_LIGHTS + c].setBrightness(active);


+ 0
- 1
src/Sum.cpp View File

@@ -20,7 +20,6 @@ struct Sum : Module {
NUM_LIGHTS
};

int frame = 0;
dsp::VuMeter2 vuMeter;
dsp::Counter vuCounter;
dsp::Counter lightCounter;


+ 26
- 28
src/Viz.cpp View File

@@ -13,29 +13,27 @@ struct Viz : Module {
NUM_OUTPUTS
};
enum LightIds {
ENUMS(VU_LIGHTS, 16*2),
ENUMS(VU_LIGHTS, 16 * 2),
NUM_LIGHTS
};

int channels = 0;
int frame = 0;
dsp::Counter counter;
int lastChannels = 0;
dsp::Counter lightCounter;

Viz() {
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);

counter.period = 16;
lightCounter.setPeriod(16);
}

void process(const ProcessArgs &args) override {
if (counter.process()) {
channels = inputs[POLY_INPUT].getChannels();
float deltaTime = args.sampleTime * counter.period;
if (lightCounter.process()) {
lastChannels = inputs[POLY_INPUT].getChannels();
float deltaTime = args.sampleTime * lightCounter.period;

for (int c = 0; c < 16; c++) {
float v = inputs[POLY_INPUT].getVoltage(c) / 10.f;
lights[VU_LIGHTS + c*2 + 0].setSmoothBrightness(v, deltaTime * counter.period);
lights[VU_LIGHTS + c*2 + 1].setSmoothBrightness(-v, deltaTime * counter.period);
lights[VU_LIGHTS + c * 2 + 0].setSmoothBrightness(v, deltaTime);
lights[VU_LIGHTS + c * 2 + 1].setSmoothBrightness(-v, deltaTime);
}
}
}
@@ -60,7 +58,7 @@ struct VizDisplay : Widget {
nvgFontSize(args.vg, 11);
nvgTextLetterSpacing(args.vg, 0.0);
nvgTextAlign(args.vg, NVG_ALIGN_CENTER | NVG_ALIGN_BASELINE);
if (module && c < module->channels)
if (module && c < module->lastChannels)
nvgFillColor(args.vg, nvgRGB(255, 255, 255));
else
nvgFillColor(args.vg, nvgRGB(99, 99, 99));
@@ -82,22 +80,22 @@ struct VizWidget : ModuleWidget {

addInput(createInputCentered<PJ301MPort>(mm2px(Vec(7.619, 21.346)), module, Viz::POLY_INPUT));

addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 33.626)), module, Viz::VU_LIGHTS + 0*2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 38.916)), module, Viz::VU_LIGHTS + 1*2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 44.205)), module, Viz::VU_LIGHTS + 2*2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 49.496)), module, Viz::VU_LIGHTS + 3*2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 54.785)), module, Viz::VU_LIGHTS + 4*2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 60.075)), module, Viz::VU_LIGHTS + 5*2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 65.364)), module, Viz::VU_LIGHTS + 6*2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 70.654)), module, Viz::VU_LIGHTS + 7*2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 75.943)), module, Viz::VU_LIGHTS + 8*2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 81.233)), module, Viz::VU_LIGHTS + 9*2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 86.522)), module, Viz::VU_LIGHTS + 10*2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 91.812)), module, Viz::VU_LIGHTS + 11*2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 97.101)), module, Viz::VU_LIGHTS + 12*2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 102.392)), module, Viz::VU_LIGHTS + 13*2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 107.681)), module, Viz::VU_LIGHTS + 14*2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 112.971)), module, Viz::VU_LIGHTS + 15*2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 33.626)), module, Viz::VU_LIGHTS + 0 * 2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 38.916)), module, Viz::VU_LIGHTS + 1 * 2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 44.205)), module, Viz::VU_LIGHTS + 2 * 2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 49.496)), module, Viz::VU_LIGHTS + 3 * 2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 54.785)), module, Viz::VU_LIGHTS + 4 * 2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 60.075)), module, Viz::VU_LIGHTS + 5 * 2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 65.364)), module, Viz::VU_LIGHTS + 6 * 2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 70.654)), module, Viz::VU_LIGHTS + 7 * 2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 75.943)), module, Viz::VU_LIGHTS + 8 * 2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 81.233)), module, Viz::VU_LIGHTS + 9 * 2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 86.522)), module, Viz::VU_LIGHTS + 10 * 2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 91.812)), module, Viz::VU_LIGHTS + 11 * 2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 97.101)), module, Viz::VU_LIGHTS + 12 * 2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 102.392)), module, Viz::VU_LIGHTS + 13 * 2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 107.681)), module, Viz::VU_LIGHTS + 14 * 2));
addChild(createLightCentered<SmallLight<GreenRedLight>>(mm2px(Vec(10.854, 112.971)), module, Viz::VU_LIGHTS + 15 * 2));

VizDisplay *vizDisplay = createWidget<VizDisplay>(mm2px(Vec(0.0, 29.235)));
vizDisplay->module = module;


Loading…
Cancel
Save