How to Cast SynthesiserSound to SamplerSound and set ADSR? [SOLVED]

Synthesiser mSampler;
...
mSampler.addSound(new SamplerSound("Sample", *mFormatReader, range, 60, 0.0, 0.1, 10.0));
...
auto sound = mSampler.getSound(0);
auto samplerSound = dynamic_cast<SamplerSound*>(sound); // ???
samplerSound.setEnvelopeParameters(new ADSR::Parameters(...)) // ???

BtW why is Juce using Synthesiser instead of Synthesizer ?

Found the Solution:

auto sound = dynamic_cast<SamplerSound*>(mSampler.getSound(0).get());
ADSR::Parameters release;
release.release = 10.0;
sound->setEnvelopeParameters(release);
1 Like