Trying out AudioProcessorValueTree for the first time using the tutorial and I am having an issue with the value to text function. For some reason when my interface first loads, sliders that are attached to parameters are showing the value of the parameter until they are changed and then it displays the text. This only happens when the value is the lowest value of the parameter (irrespective of what the lowest value is).
e.g. Plugin loads with parameter at lowest value (0.0) but shows the value, slider moves to 1.0 and shows the text. The slider is then moved back to 0.0 and shows the text correctly. When the plugin is loaded with the parameter at a higher value than the minimum the text displays correctly from the start.
What OS are you using?
What plug-in format?
Which host?
Does this happen using the tip of the develop branch? (We’ve made some APVTS changes recently).
I can’t reproduce your problem. Could you provide a working example, perhaps as a PIP?
The code you posted looks a little suspicious in isolation - you mention that you’re using a slider, which implies a continuous range of values, but you have equality checks on floating point numbers…
Will make a simplified example of what I am doing. I have tried with and without the equality checks. It seems odd to me as I have the else return function if none of the values match but yet it still displays a value. It seems as if the function is not being called.
I have a hunch, maybe the textToValue and valueToText methods are contradicting?
I.e. the default value is converted into a text, that when converted back, is a different value?
Also I would avoid == for float values. Especially since you are actually comparing to double values.
It is better to write:
Sorry, tried looking at making a PIP but I couldn’t work out how to do it. Here is a very basic plugin using the standard JUCE template with one parameter that displays the problem I am having. I have replaced the == with Daniel’s suggestion in this example. I’d be really grateful for any further help on this.