4ms / metamodule

MetaModule virtual patch module firmware
Other
7 stars 0 forks source link

Support for minAngle maxAngle for knobs #238

Open hemmer opened 5 months ago

hemmer commented 5 months ago

I'm updating the Befaco modules for recent updates on VCV side. All going well, but for one case, the knob has a custom range for the knob:

auto p = createParamCentered<Davies1900hLargeLightGreyKnob>(mm2px(Vec(15.0, 67.275)), module, Voltio::SEMITONES_PARAM);
p->minAngle = -0.83 * M_PI;
p->maxAngle = M_PI; 
addParam(p);

Is this or can this be supported on the metamodule side? I can try to implement if you point me in the right direction. If not I can make the Befaco metamodule branch remove these lines.

danngreen commented 5 months ago

I think it could be done easily. The minAngle/maxAngle fields of rack::app::Knob could be captured and stored in the MetaModule Element type. Then the element draw/redraw functions would use this instead of their default angles. At least, this is easy in the dynamic_loader branch. The main branch would be a bit more tricky since I'm assuming that bit of code is in the ModuleWidget constructor so we'd need to capture the min/max values in ModuleWidget::addParam.

More specifically:

I think that's all it will take

hemmer commented 5 months ago

Thanks I'll try and take a look

danngreen commented 3 weeks ago

@hemmer Is this still relevant? I was thinking of doing it unless you've made any progress.

Since it would be an API change for plugins, we would need to roll it into SDK API v1.1.

hemmer commented 3 weeks ago

Ah sorry I don't think I still have those changes, and it'll be a little while before I get the chance to look at it properly. It may be easiest (and faster with your understanding) if you do it - sorry I never got round to it!

danngreen commented 1 week ago

Note: while adding fields to Knob, we might want to add snap (boolean), units (string), base, multiplier, and offset to ParamElement.