Best way of accessing parameters in SynthesiserVoice

I’m currently building my first instrument plugin and I’m setting up my Synthesiser/SynthesiserVoice/SynthesiserSound classes and I’m just wondering what the best method of accessing parameter data from the SynthesiserVoice classes is.

Should I be storing a pointer to each parameter value in every voice instance? Or since the parameters will be the same for every voice, should I create a SharedResourcePointer inside the SynthesiserVoice for a class which stores the pointers to my parameters then each voice accesses them through that. Or should I be doing something else entirely?

Sorry if this is a bit of a noob question, I’m still learning C++ through my JUCE projects.

Nevermind, I’ve come up with a solution that works for me, I made a separate SynthParameters class which holds pointers to all of my parameters, and each voice holds a reference to this class to access its pointers.

2 Likes

FYI, pointers are very small in terms of memory usage: they’re the same size as an int. the cost to have them in your class is negligible.

That’s a good point, the main reason I did it this way is just to keep the parameter pointers together in a simple class along with functions for scaling the parameters from 0 to 1 to usable values. Also some of them will need to be accessed by both the Synthesiser and SynthesiserVoice classes, so this way I don’t need to copy the pointers/functions to two different classes.