adjust max possible volume in pulseaudio

Somtimes some sound/movie/music on my Ubuntu_12.04 system is at a very low volume by itself.
Henceforth I increase the volume of the sound output. I can use the following setting (see screenshot)
enter image description here

It seems therefore that pulseaudio is able to increase the volume beyond the maximum that appears possible by merely using the “increase-volume” buttons of the machine.
My questions is how I can adjust Pulseaudio to allow a greater range or a higher max volume increasing???

Especially with some audio material that is at a very low volume to start with it would be nice to be able to swiftly increase the output volume (powerup) to a higher setting than maybe necessary to other -already quite loud- material.

Asked By: humanityANDpeace

||

The maximal possible volume level we can obtain from sliding the volume control to more than 100% is approx. 153% above the normal peak limit. Provided we had set the ALSA volume with alsamixer to 100 these 100% are the level above which audio will be clipped or distorted. This also will happen when amplifying to 153% with the slider.

Nevertheless is is possible to further increase this level by setting the sink level using the follwing command in a terminal:

pacmd set-sink-volume <sink> <value>

Replace <sink> with your sink name or sink index as given from:

pacmd list-sinks

The lower limit for <value> obviously is 0, a linear volume of 100% is a value of 65536, anything higher will be further amplified. A value of 512000 will thus lead to an overamplification of 781%.

This is a very crude method to amplify sound output of varying level as overamplifying will lead not only to clipping and ugly distortion but may also damage your speakers.

Therefore it would be a better way to normalize your audio output. See the following question on how to do this with pulseaudio:

Answered By: Takkat

I inserted the following line into a shell script and set it to run at startup since my fathers laptop (12.04 32 bit) was not saving the max volume setting.

pacmd set-sink-volume 0 99999

if there is only one sound card it is probably index 0 and then you don’t need to type out the full name. I see above that the value is based on 65536 being 100%. When I used 99999 i was shooting in the dark. 153% would actually be 100270 achieving the same result as using the gui.

I tried this command:

pactl set-sink-volume alsa_output.pci-0000_00_1b.0.analog-stereo 150%

and it was very helpful. One can change the 150% to any value.

Answered By: whahmad

Video Demonstration


I use

pactl set-sink-volume 0 100%

Where 100% is the default unboosted volume and 0 is the Sink # from pacmd list-sinks or the index: from pactl list sinks (if you don’t have/like pacmd). You can enter values above 100% to get audio boost (200% for example).

Example of retrieving your Sink number/index:

$ pactl list sinks | grep -iE '(^sink|name:|index:|alsa.(name|card_name))'
Sink #3
    Name: alsa_output.usb-0c76_USB_PnP_Audio_Device-00.analog-stereo
        alsa.name = "USB Audio"
        alsa.card_name = "USB PnP Audio Device"
Sink #4
    Name: alsa_output.pci-0000_00_1f.3.analog-stereo
        alsa.name = "ALC257 Analog"
        alsa.card_name = "HDA Intel PCH"
$ pacmd list-sinks | grep -iE '(^sink|name:|index:|alsa.(name|card_name))'
  * index: 3
    name: <alsa_output.usb-0c76_USB_PnP_Audio_Device-00.analog-stereo>
        alsa.name = "USB Audio"
        alsa.card_name = "USB PnP Audio Device"
    index: 4
    name: <alsa_output.pci-0000_00_1f.3.analog-stereo>
        alsa.name = "ALC257 Analog"
        alsa.card_name = "HDA Intel PCH"
Answered By: Mina Michael

Here is a little script to do the calculation and set volume for you (just pass the volume as an argument). For example: vol 105 will set the volume to 105%.

  • Create file

    $> file=/usr/bin/vol;sudo touch $file && 
    sudo chmod u+x $file && sudo chown $USER:$USER $file && 
    gedit $file
    
  • Copy and paste:

    #!/bin/bash
    SetPacmdSinkVol()
    {
        #default index of 0 - can be changed
        local mySinkIndex=0
        #if you want to ignore pacmd output
        local ignoreOutput=true
        local num=$1
        local vol=$((num * 655)); 
        vol=$((num * 36 / 100 + vol));
        echo -e "33[0;32mVol - ${num}:${vol}33[0;m"
        if $ignoreOutput; then
            pacmd set-sink-volume $mySinkIndex $vol > /dev/null
        else
            pacmd set-sink-volume $mySinkIndex $vol
        fi
    }
    SetPacmdSinkVol $@
    
Answered By: Sparkida
#!/bin/bash

FILE=/tmp/currentVolume

interval=15
minVolume=10
maxVolume=140

if [ -f "$FILE" ];
then
   CurrentVolume=$(cat $FILE )
else
   CurrentVolume=50
fi

        if [ $CurrentVolume -lt 60 ]; then
            interval=3
        elif [ $CurrentVolume -lt 80 ]; then
            interval=5
        elif [ $CurrentVolume -lt 110 ]; then
            interval=10
        else
            interval=15
        fi

if [ "$1" == "UP" ] 
then
    CurrentVolume=$(echo "$CurrentVolume + $interval" | bc)
    if (( $(echo "$maxVolume < $CurrentVolume" | bc -l) ))
    then
        CurrentVolume=$maxVolume
    fi  
else
    CurrentVolume=$(echo "$CurrentVolume - $interval" | bc)
    if (( $(echo "$minVolume > $CurrentVolume" | bc -l) ))
    then
        CurrentVolume=$minVolume
    fi
fi

echo "CurrentVolume:" $CurrentVolume >> /tmp/currentVolume.log
echo $CurrentVolume > $FILE


for i in {1..20}
do
   pactl -- set-sink-volume $i $(echo $CurrentVolume)%
done
Answered By: MarkL