Envelope follower not smooth enough
You are already just low-pass filtering the magnitude of the input signal. Right now, your envelope detection "circuit" is just a single-pole filter. Let $f[n]$ be the input to your system and, for simplicity sake, assume that attack_coef $=$ release_coef $ = a_1$. Then we can express the output $y$ of your system as follows:

$$y[n] = a_1 \left(y[n-1] - |f[n]|\ \right) + |f[n]|$$

Which we can rearrange as a transfer function $h$ as follows:
$$y = a_1 \left(y\,z^{-1} - |f|\right) + f$$
$$h = \frac{y}{|f|} = \frac{1 - a_1}{1 - a_1 z^{-1}}$$

You can use this information to either adjust your coefficients to get the desired cutoff frequency, or you could add another pole if you want a steeper roll-off.