To enable the audio normalization, you should set "audio.gain_normalization" property to "true" for your source object with the PropsSet method, and enable LUFS measurement.
MPlatform
mySourceObject.PropsSet("object::audio.gain_normalization", "true");
mySourceObject.PropsSet("object::audio.lufs", "true");
MFormats
mySourceObject.PropsSet("audio.gain_normalization", "true");
mySourceObject.PropsSet("audio.lufs", "true");
Loudness normalization for files
For proper audio normalization, it is required to analyze at least 3 seconds of audio data. In the case of files, you can pre-read a specified amount of audio to make the normalization real-time, i.e. along with the files playback.
For this, you should enable the following registry settings:
MPlatform
HKEY_CURRENT_USER\Software\Medialooks\MPlatform\MFile\MFileFFM
audio.rms_forward_time = 3
experimental.mfcodecs = true
MFormats
HKEY_CURRENT_USER\Software\Medialooks\MFormats\MFReader
audio.rms_forward_time = 3
experimental.mfcodecs = true
The "audio.rms_forward_time" sets a duration of pre-read audio data. The recommended value is "3".
Loudness normalization for live sources
When there is no way to pre-read audio data, the normalization uses previous data for the loudness changes. So there could be audio peaks if the gain is changed significantly on the source. By default, it uses RMS data for the algorithm, but it can be modified.
Loudness normalization parameters
There are other parameters you can set with the PropsSet method or in the registry to tune the normalization algorithm.
"gain_normalization.loudness_type"
There are options that you can use to normalize the audio gain in real-time:
- Normalize by a momentary RMS - set "rms" as a value of the property.
Pros:
- Correct processing even in case of sharp volume changes.
Cons:
- Compression is too heavy because momentary values of RMS are used (volume fader moves over 40 times per second to compensate gain). - Normalize by M/S value of LUFS meters - set "m" or "s" as a value of the property.
Pros:
- A lot softer compression compared to the momentary RMS.
Cons:
- Sharp volume changes are not being automated immediately. Momentary loudness takes 400 ms (or 3000 ms in case of S value) to calculate so it's really natural that we will have really loud audio on a transition between less and more louder files (400 ms minimal or 3000 ms in case of S value). - Normalize by I value of LUFS meters - use "i" as a value of the property.
Pros:
- The softest compression. The wave shape stays almost the same.
Cons:
- It takes really long for the fader to move after sharp loudness changes.
Since in real-time we don't have any look-ahead, any loudness normalization algorithm will vary from precise but too heavily compressed to softer compressed but with incorrectly processed transitions.
"gain_normalization.gating"
It sets some threshold (in dBLUFS) for applying gating automation. Everything below this threshold is not being automated. By default, it is set to "-100".
"gain_normalization.target_i"
According to the standard, a target loudness is -23. But if you need to set the loudness to a different value, you should set the property to the target level in dB.