Hi I am coding a synth in the Juce framework.
When my adsr is running I need to override isVoiceActive() and set it to true from inside the voice. This is a public member function of the SynthesiserVoice class.
virtual bool SynthesiserVoice::isVoiceActive ( ) const
Returns true if this voice is currently busy playing a sound.
By default this just checks the getCurrentlyPlayingNote() value, but can be overridden for more advanced checking.
So in the voice I have another member function virtual void renderNextBlock()
and from inside it I want to override isVoiceActive
class SynthVoice : public SynthesiserVoice
{
public:
void renderNextBlock (AudioBuffer <float> &outputBuffer, int startSample, int numSamples) override
{
for (int sample = startSample; sample < (startSample + numSamples); ++sample)
{
float env_value = adsr.getNextSample();
if(env_value > 0)
isVoiceActive = true; //???????
...
you cannot do this because isVoiceActive is not an attribute it's a function, you can use your isVoiceActive as a data member and not as a function member so you can assign it true or false. or if you want to work with function then you have to add '&' so you can assign to that function a value (if you don't use '&' then you cannot do what you want to do. you have 2 choices:
1/ to use isVoiceActivat as a data member and you can do like this:
2/ to do the following:
Now you have to implement this to suit your functions and data.
Hope it's clear and helpful