I am running into a few design headache's / queries regarding custom voice classes derived from JUCE's SynthVoice class.
Most of my issues have been solved by creating the various components of my Synth as AudioProcessors and hooking them up into an AudioProcessorGraph.
So dealing with things like filter cutoff parameters and delay parameters is becoming much more flexible.
However, I am still having the issue that my WaveTableOscillator class is being implemented as a member of my derived SynthVoice class. The various functions within the voice class for rendering the voice and noteOn call the oscillators output to fill the buffer and also in turn set it's frequency.
I need access to a few paramters of my oscillator within my derived SynthVoice's (fine tune etc. for modulation and GUI param changes). The getVoices() function returns a SynthVoice and the only way i can call my derived voices functions/access their member variables is to perform a dynamic cast.
I'm wondering whether dynamic casting in this instance really is the best / only option or not (this seems to be the suggested solution in most threads touching on this issue) ? It's working but is it an ugly work around ? I'm working through the various Meyers texts and think im getting a reasonable understanding of the consequences of dynamic casts.
My alternative ideas were:
1.Pass a reference/pointer to the "Owning" synth object in the Voices constructor and access member variables of the synth(which could be controlled by param changes in the audio processor) to set my oscillator values. However i suspect I'll run into some threading disasters here ?
2.Set up a broadcast/listener method or some sort of asynchronous messaging from the synth to the synthVoices with a callback that updates my custom synthVoice class parameters.
Does anyone have any advice in regards to this ?
Any help for a still "in learning" C++ programmer would be most appreciated