adjust max possible volume in pulseaudio

77,534

Solution 1

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:

Solution 2

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.

Solution 3

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"

Solution 4

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 "\033[0;32mVol - ${num}:${vol}\033[0;m"
        if $ignoreOutput; then
            pacmd set-sink-volume $mySinkIndex $vol > /dev/null
        else
            pacmd set-sink-volume $mySinkIndex $vol
        fi
    }
    SetPacmdSinkVol $@
    

Solution 5

#!/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
Share:
77,534

Related videos on Youtube

humanityANDpeace
Author by

humanityANDpeace

Lucky those who have knowledge to help and assist others :)

Updated on September 18, 2022

Comments

  • humanityANDpeace
    humanityANDpeace almost 2 years

    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.

  • humanityANDpeace
    humanityANDpeace over 11 years
    I have used pactl set-sink-volume alsa_output.pci-0000_00_1b.0.analog-stereo 150% - since I could not succeed yet with pacmd. Anyhow the idea already helped a lot. In this way it is possible to increase the output level to more than the 100% or 153% which the GUI allows, thank you.
  • humanityANDpeace
    humanityANDpeace over 11 years
    Your great answer allowed to set the volume to greater values (like 781% amplification) which is great. Part of my question is also how to change the scale originally used so that it is not from 0% to 100% (via GUI) but from 0% to 781%. Any additional infor how to achieve this, maybe? it would be additionally great! thank you
  • panzi
    panzi about 8 years
    Does not work: A program can still make it 100% even if I set it to 12% that way.
  • Henning Kockerbeck
    Henning Kockerbeck over 7 years
    Thank you for your answer. If possible, could you edit your answer to elaborate a bit more about it? It's always helpful for people to know why a solution is supposed to work, instead of just blindly copy'n'pasting code they don't understand. That also helps to adapt solutions to different problems.
  • Garri Sumalapao Farol
    Garri Sumalapao Farol over 6 years
    You should mention that it disables volume control.
  • Garri Sumalapao Farol
    Garri Sumalapao Farol over 6 years
    it disables volume control.
  • Mina Michael
    Mina Michael over 6 years
    why? no it doesn't. I just tried it and it's fine. The thing is that it raises the volume above the maximum volume that the volume bar can reach. A full bar would probably be about 150% maybe, so 200% cannot be done with the bar. @Green
  • brett
    brett almost 5 years
    I had my laptop speakers destroyed by using the volume at the 150% also allows. I had to replace them. Be advised that the possible damage warning is justified.
  • Allexj
    Allexj over 2 years
    IT WORKS!!! If you want to do this and you use Pipewire, you can get the sink number with "pactl list sinks" and then you can use the command above without problems.
  • Allexj
    Allexj over 2 years
    IT WORKS!!! If you want to do this and you use Pipewire, you can get the sink id with "pactl list sinks" and then you can use the command above without problems.
  • Allexj
    Allexj over 2 years
    IT WORKS!!! If you want to do this and you use Pipewire, you can get the sink id with "pactl list sinks" and then you can use the command above without problems.