nih-plug icon indicating copy to clipboard operation
nih-plug copied to clipboard

nih_plug_vizia: Timer and events

Open polygon opened this issue 1 month ago • 0 comments

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.

  1. I can't do it in the draw function since it is &self not &mut self
  2. I tried using add_timer and start_timer which is available in the build-context of View::build but this flat out does not work. The function passed to add_timer never gets called.
  3. 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.
  4. In the end, I used cx.spawn and made a small thread that emits 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?

polygon avatar Nov 21 '25 12:11 polygon