Update
- This question is purely theoretical and should not account for any psychoacoustic effects, or practical implementations.
- Perhaps the question should be rephrased to "How long will it take to apply the smoothest possible fade, in a single precision system"?
A sine wave is generated within a 32-bit float system, with a sample rate of 44.1 kHz. The task in hand is to fade out this sine with as little digital distortion as possible (this is the meaning of 'properly'), without using dither. The maths below resolves to approximately 6 minutes and 20 seconds to do so. Is this correct?
Axioms
- Digital audio within a 32-bit float system is represented with the values -1.0 to 1.0
- All the values within this range are normalized
- The sine wave peaks at 1.0 and -1.0
- The audio resolution is $2^{25}$, made of 23 bit mantissa + 1 implied (normalized) bit + 1 sign bit.
- The possible gain coefficients are $2^{24}$, with values ranging between 0.0 to 1.0
Fading out
Any fade will create distortion due to quantisation of the gain values.
For instance, a fade from unity gain (1.0) to silence (0.0), if happens between two consecutive samples, is similar to 1-bit reduction (this will generate high and low frequency distortion correlated to the phase of the sine). If the fade is performed over 4 samples, there will be 4 gain steps; 8 samples mean 8 gain steps; and so forth.
It follows that the smoothest fade possible is that where between each sample the gain changes by the minimum possible amount, which is $1/2^{24}$. This gives $2^{24}$ gain steps.
$2^{24} = 16,777,216$
Meaning 16,777,216 samples are needed for the fade. If the system sample rate is 44,100 Hz:
$16,777,216 / 44,100 = ~380.4$ seconds.
Which equals approximately 6 minutes and 20 seconds.
This seems unreasonable. So where is the calculation wrong?
Just to further demonstrate what distortion I am talking about.
The original sine and its frequency analysis:
With a long fade:
With a medium fade (50 samples):
And with a 1-sample fade: