I have a UI display with setBufferedToImage(true) and I would like to only repaint when actually necessary. It’s a filter response display that should react whenever one of my EQ parameters changes. My editor is a listener to all of these parameters and sets a flag “eqDisplayChanged” when one of them changes. Then in the timer callback, the display is repainted.
The problem is that the parameter changes are not reflected in this callback. I sort of expected this because the documentation does mention that I’m supposed to use the “newValue” to see the updated value. But I thought that in the Timer thread I could expect the updated value. I’m kind of at a loss how I could update the display properly if I have no way of knowing when the parameter has actually been updated. I could manually keep track of every EQ parameter but that’s a really ugly solution. I could blindly repaint every Timer tick but I’d like to avoid that.
Are you sure? For getRawParamter value the docs say
Returns a pointer to a floating point representation of a particular parameter which a realtime process can read to find out its current value.
Note that calling this method from within AudioProcessorValueTreeState::Listener::parameterChanged() is not guaranteed to return an up-to-date value for the parameter.
Right now, I’m trying to just store separate variables in the Component that reflect the more up to date value, but it’s really not such a nice solution…
Same result for me unfortunately. apvts.getParameterAsValue().getValue() was not returning the same thing as the newValue passed into parameterChanged. Either way, do they not use the same underlying logic?
IIRC, I used the same method in a wave-shapper and it did work. I am not sure why it does not work in your case. According to the documentation, getRawParameterValue() should return the up-to-date value outside the parameterChanged().
By the way, why not using juce::AsyncUpdater to trigger the repaint()? Since you only need to repaint when the filter changes, it is more intuitive.
I have it working with the solution I mentioned but still not sure why getRawParameterValue isn’t working… I’ll look into it if I run into the problem again on another component.
I suppose I could use AsyncUpdater but doesn’t repaint just notify the UI thread (or whatever handles it) anyways?