To Use Dynamic Range Control
The dynamic range of a piece of audio content is basically the difference between the lowest volume and the maximum volume. If the dynamic range of the content is too high, users may find themselves adjusting the volume repeatedly during playback. For example, movies frequently have a high dynamic range. Often, when the volume is adjusted so that dialog can be understood during quiet scenes, other parts of the movie with music or sound effects are louder than desired.
The Windows Media Audio 9 Professional and Windows Media Audio 9 Lossless codecs support a feature called dynamic range control. At encode time, the codec calculates the peak and average amplitude values in the content, and the writer object stores these values in the metadata for the stream when encoding is finished. Optionally, an application can also write "target" values as metadata that player applications and the decoder can use as hints when playing back the file. At playback time, an application can specify the level of dynamic range control to apply to the audio stream.
Windows Media Player implements dynamic range control as the Quiet Mode feature.
Dynamic range control can alter the sound of the content. For that reason, you should not configure your application to use dynamic range control automatically. Instead, provide users with the ability to turn dynamic range control on or off as needed.
At playback time, dynamic range control is activated using the output setting g_wszDynamicRangeControl. Use IWMReaderAdvanced2::SetOutputSetting to configure the setting. A value of zero (the default) indicates that the dynamic range should not be altered. A value of 1 or 2 signals the codec to perform dynamic range control, where 1 is a moderate level of dynamic range compression, and 2 is a high level of dynamic range compression.
At encoding time or playback time, you can give the codec target PCM values for the peak and average levels by setting the WM/WMADRCPeakTarget and WM/WMADRCAverageTarget attributes, respectively. These values are stored as metadata attributes and should be accessed using the methods of the IWMHeaderInfo3 interface. When you encode an audio stream using the professional or lossless codec, the WM/WMADRCPeakReference and WM/WMADRCAverageReference attributes are set automatically to the peak and average levels of the original content. The target values are set to the same values as the references by default.
The decoder at playback time calculates the dynamic range based on the selected level of dynamic range control and the target values (if any are specified). The possible ranges are shown in the following table.
|Settings||Range of delivered audio|
|g_wszDynamicRangeControl = 0 (Any target values)||Same range as the original content.|
|g_wszDynamicRangeControl = 1 (Target values equal to reference values)||Average level is maintained and peaks are confined to the average +12 dB.|
|g_wszDynamicRangeControl = 2 (Target values equal to reference values)||Average level is maintained and peaks are confined to the average +6 dB.|
|g_wszDynamicRangeControl = 1 (Target values specified)||Average level set to the target average value and peaks confined to the target peak value.|
|g_wszDynamicRangeControl = 2 (Target values specified)||Average level set to the target average value and peaks confined to the median of the target average and target peak values.|
Note that dynamic range control is a feature of decoding only and exists only as metadata in the file itself. These settings have no effect on the content stored in the file unless you specifically instruct the decoder to use them. The Windows Media Format SDK provides no methods for modifying the dynamic range of the audio data at encoding time.