Comment by pixelpoet
I'm a bit star-struck to have you reply to my somewhat offhand comment, am aware of your audio player work and really want to be a Zig convert (just missing those vec3 and complex operators, having equal mathematical standing to ints and floats) and your original Zig intro video is IMO one of the best tech presentations of all time, but I digress...
I'm aware of ReplayGain and this processing is important for per-track overall gain, but what I'm getting at is lower level: instead of there being two lossy/rounded stages of dimming and amplification, you want to communicate to the OS a log2 "dimming factor", so that this can be subtracted from a later log2 amplification factor such that we ideally waste no processing time if the sum is zero, and otherwise don't suffer the twice-quantised signal degradation (at most one accurate scaling pass, instead of two arbitrarily precision-reducing ones). It's maybe a minor point / imperceptible as others have noted, but IMO this seems like the Correct (TM) approach.