Hi, I’m making a synth plugin using visual studio and juce. It’s still in the early days but I wanted to compile for release and then test it out in ableton. So far I have just been testing within visual studio using “Debug” mode.
However a bug has appeared after I compiled for release that does not appear when compiling for debug.
Basically in my synth I have 4 oscillators with their own envelopes. In Release mode, if I change the sustain level of my oscillator there will be a (very loud)pop once the decay phase is finished. This does not happen for any of my other envelope values and it produces this funny looking waveform:
I am using a look up table for my exponential decay.
Does anyone know what I could do to fix this and why ON EARTH it doesn’t happen when compiling for debug??? I am sure this is not the first bug I will find.
This is my Envelope logic:
float Envelope::process()
{
if (isRelease) //RELEASE PHASE
{
envelopeValue *= releaseRatio;
if (envelopeValue <= 0.001f)
finished = true;
}
else
{
if (totalTime <= attackTime && attackTime != 0)//ATTACK PHASE
{
envelopeValue = totalTime / attackTime;
}
else
{
if (totalTime < attackTime + decayTime) // DECAY PHASE
{
float index = (totalTime - attackTime) * LOOK_UP_TABLE_LENGTH / decayTime;
float x = exponentialDecayTable[(int)index];
float x1 = exponentialDecayTable[(int)index + 1];
float t = index - (int)index;
envelopeValue = (1 - sustainLevel) * lin_interp(x, x1, t) + sustainLevel;
}
else //SUSTAIN PHASE
{
envelopeValue = sustainLevel;
}
}
}
totalTime += timeDelta;
return envelopeValue;
}
totalTime is a variable that shows the time since the note was pressed essentially.
thanks in advance,
Dario