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:
- A percentage of the duration specified (expressed as a percentage value between 1 and 100) based on a configured number of samples (duration of time).
- A percentage of the overall volume delta to increase the volume. This is a linear increase in volume for the segment. The volume delta is the difference between the current volume level and the volume level before the subchannel was muted or paused.
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
- 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()orsnd_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.
