[SOLVED] SamplerVoice Parameters

Hi guys,

I created a new set of classes (my_Synthesiser, my_SamplerVoice, my_SamplerSound) derived from the original one.

I've added an envelope generator that works on the SamplerVoice class, but now I can't find a proper way to pass the parameters (all are AudioProcessorParameters*) from PluginProcessor. I tried by passing an AudioProcessor pointer

my_SamplerVoice(AudioProcessor* p);


 AudioProcessor* owner

my_SamplerVoice::my_SamplerVoice(AudioProcessor* p)
 : owner(p)
  .... //stuff

and then using the pointer 'this' when I add new voices:

synth.addVoice(new my_SamplerVoice(this));

Unfortunately it doesn't seems to work, since I can't access the parameters. If I try to include PluginProcessor.h to the file where I have my new classes, XCode returns an error saying that it can't find my_Synthesiser class and suggests to replace it with the base class.

Any hints on a proper way to access the parameter values?

Thanks in advance!

I found a way to get this done by accessing the voices in PluginProcessor. I created a dedicated new member:

void MyPluginProcessor::setEnvelope()
  for(int i = 0; i < MAX_VOICES; i++)
    my_SamplerVoice *v = dynamic_cast<my_SamplerVoice*>(synth.getVoice(i));
    v->setEnvelope(atk->getValue(), dec->getValue(), sus->getValue(), rel->getValue();

Hopefully this would help whoever will face my same issue :)

1 Like