On Tue, May 28, 2019 at 20:25:33 +0300, Andreas Gustafsson wrote: > On May 23, Valery Ushakov wrote: > > This feels inverted. The mathematically correct operation required > > here is symmetric division (that rounds towards zero). > > Rounding towards zero is absolutely the wrong thing to do for audio, > because it introduces a discontinuity, which in turn causes > unnecessary distortion of the audio. > > For example, if your original signal is a linear ramp > > ... -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5 ... > > and you divide it by two rounding towards zero, you get > > ... -2, -2, -1, -1, 0, 0, 0, 1, 1, 2, 2 ... > > where every value is repeated twice, except that the value zero occurs > three times, so the ramp is no longer linear - it now has a visible > and audible kink in the middle. And this kink is in the worst > possible place of the amplitude scale, at zero where it will affect > even the weakest signals, distorting every zero crossing. > > The proper way to do audio scaling is using dither, but failing that, > at least the values should be consistently rounded either up or down, > which will at worst introduce a small DC offset which you can't hear, > but no crossover distortion.
Thanks a lot for the explanation! Now, you omit the most critical bit: what would you name the thing? :) >From "the proper way to do audio scaling" I infer that AUDIO_SCALEDOWN (or however that was spelled) should be ok, shouldn't it? -uwe