A long time ago I did a patch that was able to keep the same loudness (perceptible) when applying a FX. The most obvious FX was a distortion. I lost the patch and I tried to redo it using env~ but it's not working like before.
So something like that:
[inlet~] | | | [check loudness average] [FX (distortion)] | [apply same loudness as inlet~] | [dac~]
Of course sometimes it's good to have a boost in loudness when applying a distortion, so I will fine-tune this method. Maybe I should consider using a compressor instead?