[Android] New AudioMixerAndroid in 4.17p1 results in crackling audio

Philosophically I’d prefer not to add even this clamp since MAX_VOLUME, being 4.0, isn’t any real protection against clipping. The reason I kept this is that, unfortunately, it’s common practice to add volume-scalers greater than 1.0 in many gain stages in UE4 and people do check in non-normalized source. A source playing at, for example, 2.0 volume scale, won’t actually clip if the content in it is not normalized. This is all too common a (bad) practice since not only does it not take advantage of the full bit-depth of the source file (often the same people complaining about wanting 24/32 bit audio are using non-normalized source!).

In general, it’s a bad idea to do mixing with volume value greater than 1.0 because at some point, due to the nature of digital audio, you’re eventually going to get some kind of clamp. You either clamp to 1.0 in the output, or you clamp via clipping. You can also clamp via dynamic range DSP compressor, but even then it can make reasoning about your mixes difficult.

This is because, when you clamp, you’re creating a non-linearity between your gain stage input and gain stage output. Non-linearity means that if you change your mix (adding a new sound class mix, change the volume of a sound source), it may or may not have a predictable effect on the final volumes of sources. Inputs do not map linearly to outputs.

We’re planning on developing better tools to help you debug your gain stages, but in the meantime, I’d recommend looking over your implementation to make sure you’re not adding too much volume scaling.

Note that the audio mixer actually has support for a master dynamic range compressor. You can create a dynamics processor preset in the editor, set it to be a “limiter”, and then add it to the master submix in BP. It defaults to not being added currently since the old audio engine didn’t have support for a master compressor.