nih-plug
nih-plug copied to clipboard
nih_plug_vizia: Timer and events
My Plugin is centered around a View struct that visualizes MIDI data in a custom draw function. Since the visualization is time dependent (Like a time-stepped simulation, I cannot just pass t_now into draw and recalculate everything), I need to regularly modify some values of the View which is where my troubles begin and I am looking for advice.
- I can't do it in the
drawfunction since it is&selfnot&mut self - I tried using
add_timerandstart_timerwhich is available in the build-context ofView::buildbut this flat out does not work. The function passed toadd_timernever gets called. - I could try to misuse a parameter and somehow update it from
process, but the value I want to mutate are not parameters and should not show up in the DAW. - In the end, I used
cx.spawnand made a small thread thatemits messages back the component. This works, but feels like it's not the way this should be done.
Is there an idiomatic way to do this?