I’m trying to bring a module from vcvrack over to metamodule, and am running into an odd issue. I have a bank of 128 SmallLight<RedGreenBlueLight>
objects, and when I try to cycle through them one at a time, some of them get skipped over, and some of them light up with the wrong color at the wrong time. See here for a simplified version of the module, to highlight the issue.
The relevant code is as follows:
in the module struct we have
enum LightId {
/* all the other lights... */
ENUMS(STATE_LIGHT, 384), // 32 * 4 * 3
LIGHTS_LEN
};
Which are turned on one at a time like so:
for (int i = 0; i < 32 * 4; ++i) {
if (step == i) {
// white
lights[STATE_LIGHT + i * 3 + 0].setBrightnessSmooth(1.f, args.sampleTime);
lights[STATE_LIGHT + i * 3 + 1].setBrightnessSmooth(1.f, args.sampleTime);
lights[STATE_LIGHT + i * 3 + 2].setBrightnessSmooth(1.f, args.sampleTime);
} else {
lights[STATE_LIGHT + i * 3 + 0].setBrightnessSmooth(0.f, args.sampleTime);
lights[STATE_LIGHT + i * 3 + 1].setBrightnessSmooth(0.f, args.sampleTime);
lights[STATE_LIGHT + i * 3 + 2].setBrightnessSmooth(0.f, args.sampleTime);
}
}
In the modulewidget constructor, I create the lights like so:
for (int i = 0; i < 4 * 32; ++i) {
auto row = i % 32;
auto col = i / 32;
auto x = stateX + lightAreaMargin + col * xStep;
auto y = stateY + lightAreaMargin + row * yStep;
auto lightIndex = Pascal::STATE_LIGHT + i * 3;
addChild(createLightCentered<SmallLight<RedGreenBlueLight>>(mm2px(Vec(x, y)), module, lightIndex));
}
The module compiles fine, and runs as expected in vcvrack. But I’ve tried it on both metamodule 1.6.9 and 2.0.0 and it has this bug.