Understanding volume ramping

Volume ramping (or simply ramping) allows you to control volume changes.

Using volume ramping alleviates artifacts, such as clicks or pop sounds, that typically occur when a change in volume is too great over a short period of time. You can also use volume ramping to gradually change the volume to get a “fade in” or “fade out” effect. For example, if you have a voice subchannel that ducks the music that's playing on another subchannel, you may want to use volume ramping so that when the voice call completes, rather than starting the audio so that it plays almost immediately at its original volume, you may want to gradually increase the volume.

You can use multiple segments for your volume ramping ramp so that you can build a curve for the ramp. If you choose to use one segment, the volume ramps is linear. Each volume segment defines two values, delimited by a colon; while each segment is delimited by a comma:

You can define multiple segments, and the percentages that provide for the time to increase the volume and the amount to increase the volume by must total 100. Or you can define one segment, which specifies a liner ramp in volume.

The ramp duration is the time in milliseconds for the entire ramp, or the total number of ramp segments. It is a configured value that you provide in the audio policy configuration file. For more information, see the [vol_ramp] subsection in the Syntax of the audio policy configuration file section of this chapter.

Volume ramping types

You can control the volume ramp for various audio concurrency management scenarios using the [vol_ramp] section in the audio policy configuration file. These are the scenarios that you can apply volume ramp to:
Note: If you don't specify a volume ramp, the default for each of the scenarios is 20 milliseconds and the profile is a linear ramp (i.e., 100:100).
ducking
The volume ramp corresponds to any ducking-related volume changes made by audio concurrency management.
pause_resume
The volume ramp corresponds to pause and resume requests made using the snd_pcm_*_pause() or snd_pcm_*_resume() calls.
volume_mute
The volume ramp corresponds to volume or mute requests made using APIs. This value is used only if a duration isn't specified during a volume change request. For example, volume changes can be made by calling snd_mixer_group_write(), and the duration can be specified at that time.