Hi all,
I’m building a “loading” widget: a simple svg image that will rotate in the time:
struct Loading : TransparentWidget {
int mStep;
std::shared_ptr<rack::Svg> pImage;
Loading() : mStep(0) {
pImage = APP->window->loadSvg(gPluginPath + "res/Loading.svg");
box.size.x = pImage->handle->width;
box.size.y = pImage->handle->height;
}
void setup(Vec pos) {
box.pos = pos;
}
void draw(const DrawArgs &args) override {
float angle = ((float)mStep / 50.0f) * g2PI;
nvgSave(args.vg);
// rotate stuff
svgDraw(args.vg, pImage->handle);
nvgRestore(args.vg);
mStep++;
}
};
But I’ve simply mStep / 50.0f
. What if I’d like to do a whole rotation in (let say) 2 seconds? And keep this time absolute between machines/sample rates?
I think the only way is to sync the gui thread (widget) with samplerate, right? Is there any guaranted ratio between the two?
I wish to keep the Widget indipendent, separated from Audio part of the plugin, without having to create a mStep variable on audio thread and ++ it at every sample.
Thanks