Skip to content

nih_plug_vizia: Timer and events #239

@polygon

Description

@polygon

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions