Understanding how multiple ducking levels cumulative

It's important to mention that ducking occurs in a cumulative manner. In other words, multiple ducking levels can be applied by the higher priority audio types to a lower priority audio type.

This ensures that the relative ducking levels are correct. To illustrate this concept, here's an example based on the audio policy configuration file shown in the “Example of an audio policy configuration file” section of this chapter. Let's say you have three, active audio streams that match the audio types voice, ringtone and multimedia. Each active audio stream has an initial volume level of 100 before ducking occurs:

voice = 100
ringtone = 100
multimedia = 100

After ducking occurs:

voice = 100
ringtone = 50
multimedia = 10

So what occurred? In this case, the voice audio type's key, duck_lower_prio_percent is set to 50, so this causes the lower priority audio types, ringtone and multimedia to both adjust to 50% of its volume (50), but because the ringtone audio type's key, duck_lower_prio_percent is set to 20, this in turn applies addition ducking to the lower priority audio type, multimedia. In this case, 20% of 50 is a volume level of 10.

Example of an audio policy configuration file

Here's what the audio policy configuration file for ducking looks like:

[audio_type]
name=voice
prio=same
duck_same_prio_policy=last_wins
duck_same_prio_percent=0
duck_lower_prio_percent=50

[audio_type]
name=ringtone
# priority of the audio type is decreased by one from previous audio type
prio=decr
# ducking policy of same priority is last_wins, i.e., the last added
# audio stream can duck previously  added audio streams of same priority
duck_same_prio_policy=last_wins
duck_same_prio_percen=50                
duck_lower_prio_percent=20

[audio_type]
name=nav
prio=decr
duck_same_prio_policy=same
# Channel 0 ducked to 50 percent, Channel 1 remains at 100 percent
duck_same_prio_percent=ch0:50,ch1:100
# Ducking values will default to 100 (no ducking) for channels not listed
duck_lower_prio_percent=ch0:50,ch1:100

[audio_type]
name=tts_front
prio=decr
duck_same_prio_policy=last_wins
duck_same_prio_percent=50
duck_lower_prio_percent=50

[audio_type]
name=tts_back
prio=same
duck_same_prio_policy=last_wins
duck_same_prio_percent=50
duck_lower_prio_percent=50

[audio_type]
name=multimedia
prio=decr
duck_same_prio_policy=last_wins
duck_same_prio_percent=0
duck_lower_prio_percent=50

[audio_type]
name=default
prio=decr
# Mix audio streams at same priority with the below ducking configuration
duck_same_prio_policy=mix
# 100 percent means that no ducking is performed
duck_same_prio_percent=100
duck_lower_prio_percent=noducking