Volume ramping example

Updated: May 06, 2022

The following shows you the configuration to use in the audio policy configuration file to use volume ramping.

Here's how the [VOL_RAMP] tag is used. The names that you can use are volume_mute, pause_resume, and ducking. The duration you set is in milliseconds. You can use the profile key-value pair to specify multiple sample percentages of the specified duration and volume increments (expressed as percentages) that can be used to curve the volume ramp; otherwise if you don't provide profile, the volume ramp is linear. For more information about the syntax, see Syntax of the audio policy configuration file in this chapter.

...
...
[vol_ramp]
name=volume_mute             # When mixer API calls are made,
                             # such as snd_pcm_mixer_write()
duration=20                  # Ramp in the span of 20 milliseconds
profile=20:10,60:80,20:10    # Defined are three linear segments.
                             # Segment 1 specifies 20% of the duration and increase the
                             # volume by 10% of the volume ramp. Segment 2 specifies
                             # 60% of the duration and 80% of the volume increase, and
                             # segment 3 specifies the remaining 20% duration
                             # and to increase the volume by the remaining 10%

[vol_ramp]
name=pause_resume            # Whenever the user calls snd_pcm_*_resume() or
                             # snd_pcm_*_pause()
duration=30                  # duration of 30 milliseconds
                             # No profile key-value is specified, so
                             # it's a linear ramp

[vol_ramp]
name=ducking                 # When ducking policies and preemption is used
duration=60                  # Ramp time is 60 milliseconds
...
...