I thought this might be helpful simple (imho) way to implement getControlParameterIndex
I’ve made a utility class to simplify linking betwen parameters and components.
It uses JUCEs own powerful ValueTree based elements. It encapsulates attachments from AudioProcessorValueTreeState to add property for each component.
Feel free if you got any feedback. (The nullptr boilerplate was added after initial tests showed it’s possible to get there with no valid pointer).
I’m not sure to understand well, but from you say I think I misspoke. In the setupAttachment(String parameterId) method, the parameterId used is unique for each component. In fact I use a Constant class where I put all my parameterID for the different component.
Thanks for sharing this code, @DEADBEEF. There’s a lot implied in this snippet of code that I want to be sure I’m clear in parsing.
Your class “MyClass” is a Component, right? And you’re using the convention of adding an underscore to all of the MyClass member variables?
This is the part that surprised me the most - that the attachment class here for the Component is a member of the Component itself. The APVTS tutorial shows the attachment classes being (private) members of the Editor, and I had assumed that was the necessary scope in which they needed to live.
Related: is the attachment_ member variable of MyClass in the public or private scope?