Understanding audio ducking

When audio ducking is enabled, all audio streams adhere to an audio ducking policy that's defined in the audio policy configuration file.

Each audio stream on the system should match an audio type that's defined in the audio policy configuration file. Calls to snd_pcm_*_params() with an audio type that does not match a defined audio type will fail with EINVAL. If you call snd_pcm_*_params() without providing an audio type then the default type is assigned. Each audio type is prioritized based on the order it appears in the configuration file. The highest priority is assigned to the first audio type that's defined at the top of the file, and the lowest priority audio type is assigned to last audio type defined in the file.

If multiple audio streams are played concurrently, the higher priority audio type listed in the audio policy configuration file applies ducking, which forces the lower priority audio type to be ducked (or lowered in volume). For example, if you have a voice call occur while music is playing, and the voice call is defined as having a higher priority than the music audio type, then music is ducked (or lowered in volume) so that the voice call is heard more clearly. In this case, the voice call is performing ducking and the music is ducked.

If you have subchannels in the same PCM group and one channel is playing, when the other stream in the group plays, the other stream has audio ducking applied to it so that the second stream in the PCM can play.

Tip: If you Audio component BuildID 237—June 29, 2017 (7.0.237.S201706290957) or a later update installed, the following applies:

Previously, the audio management polices weren't correctly applied to subchannels that were grouped together. Subchannels in the same PCM link group caused audio management polices to be applied on one another. For example, if you had two subchannels grouped together and one of those streams was playing, but then you played the second stream in that group (which is the same audio type), incorrect audio ducking occurred where the first stream would have audio ducking applied to it so that the second stream could play.

This update applies audio management policies so that grouped subchannels are treated as a single audio stream rather individual streams.

Using audio ducking

You must create an audio policy configuration file that follows the rules defined in the “Syntax of the audio policy configuration file.” section in this chapter. If the specified audio ducking file isn't specified (or doesn't exist), audio ducking won't be used.
Note: If you disable the software mixer (specify disable_sw_mixer option when you run io-audio) ducking isn't available, regardless of whether audio policy configuration file. For information, see the disable_sw_mixer option in the io_audio chapter of the Neutrino Utilities Reference.
There are two ways to configure the audio policy configuration file with io-audio so that you can use ducking. The first way is to specify the audio ducking configuration (e.g., audioducking.conf) as an option when you run io-audio using the -o option. For example:
io-audio -o policy_conf=/etc/system/config/audio/audioducking.conf

The second way is to specify the audio policy configuration file is to use the audio configuration file, and then run io-audio using the -c option to point to the audio configuration file (e.g., audio.conf). For example:

io-audio -c /etc/system/config/audio/audio.conf
Then in the audio configuration file, you should have the location of the audio policy configuration file specified in the [global] section as follows:
...
[global]
policy_conf=/etc/system/config/audio/audioducking.conf
...

For more information about the audio configuration file used for the io-audio command, see the “Configuration file” section in the io_audio chapter of the Neutrino Utilities Reference.