Hi!
I’m trying to build a widget on my module that graphically shows some parameters. First, I want to get the number of polyphony channels, but when I do this, I get a segmentation fault. I think I followed the example of the fundamental ADSR module: Fundamental/src/ADSR.cpp at v2 · VCVRack/Fundamental · GitHub
Could someone help me out?
Cheers!
struct Ad : Module {
...
int nChannels = 1;
...
Ad() {
...
void process(const ProcessArgs &args) override {
nChannels = max(inputs[VPOCT_INPUT].getChannels(), 1);
...
}
};
struct SpectrumWidget : Widget {
Ad* module;
void drawLayer(const DrawArgs& args, int layer) override {
if (layer == 1) {
if (module) {
int nChannels module->nChannels;
}
}
Widget::drawLayer(args, layer);
}
};
struct AdWidget : ModuleWidget {
AdWidget(Ad* module) {
...
SpectrumWidget* spectrumWidget
= createWidget<SpectrumWidget>(mm2px(Vec(.5*HP, 10.)));
spectrumWidget->setSize(mm2px(Vec(PANELWIDTH-1.*HP,15.)));
addChild(spectrumWidget);
}
};
Model* modelAd = createModel<Ad, AdWidget>("Ad");