Code: Select all
float operator()(float value)
{
switch(state)
{
case State::ATTACK:
value+=(1.0f - value)/A;
if(std::abs(1.0f - value) < threshold)
{state=State::DECAY;}
return value;
case State::DECAY:
value+=(S-value)/D;
if(std::abs(S - value) < threshold)
{state=State::SUSTAIN;}
return value;
case State::SUSTAIN:
return S;
case State::RELEASE:
value+=(-value)/R;
return value;
}
return 0.0f;
}
The problem here is that it tends to introduce audible rumble when it is used from the pattern generator. I guess it is the attack phase that is the problem. One way of "solving" the problem is to add a high pass filter before the output, but it is better if the rumble is not introduced at all.
Due to Heissenberg, the wider spectrum is necessary, but is it possible to avoid the LF rumble.