I have a knob that starts a compute-intensive calculation (in the audio thread).
If I turn the knob, say going from 0 to 100, this calculation is done for most in-between
values, which is too often, I only need to do it for the last value (100).
What is a good way to “wait” until there are no more changes in the knob value?
Use a timer? Or is there a better way to handle this?
The Slider class has two (effectively equivalent) ways to do this:
- If you are using a
Slider::Listener, override the sliderDragEnded() method and kick off the computation there.
- you can pass a lambda to the slider that will be called when the drag operation ends, like:
juce::Slider s;
// config, etc omitted
s.onDragEnd = [this](juce::Slider* s) { startExpensiveCalculation (s->getValue ()); }
Understood, but I am using parameter attachments and parameter listeners.
Looks like I need to change the code in my custom control (e.g. mouse-up event),
I still want to see all the in-between values in the editor, but only want to update the valuetree after mouse-up…