How to Configure Per Application Sound Volume in Ubuntu

29/12/2020
Most Linux distributions ship with PulseAudio sound server that acts as a bridge between your audio hardware and running apps. Working on top of ALSA (a kernel driven API for sound card drivers), PulseAudio provides an interface to better control sound output on your system.

Default system settings configuration utility in Ubuntu offers a plethora of options to configure PulseAudio sound settings. Usually when applications are not playing any sound, only a couple of control sliders are present:

Once you launch an app that starts playing sound, for example Firefox playing a YouTube video, a new bar appears that allows you to configure per app volume:

Ideally the new volume slider visible in the screenshot above should allow you to control volume of Firefox without affecting master volume or sound level of other running apps. This doesn’t work as expected however. Notice below how main system volume also increases when you move Firefox slider to the right:

This particular issue of master volume syncing with volume levels of individual applications can be narrowed down to “flat-volumes” behavior enabled in Ubuntu by default. So what is this “flat-volumes” option in PulseAudio?

Flat-volumes increases overall system volume with the volume of the loudest application. In our case, raising Firefox volume has raised master volume as well, with added side effect of indirectly increasing volume of VLC player. When you switch to VLC and resume playback, sound will be now played at new raised master volume level instead of earlier lower level. This can be a huge issue and it has the potential to ruin your eardrums, especially when using headphones.

As annoying as this behavior may be, flat-volumes can be completely disabled in Ubuntu. Once done, each application will have true separate volume level that doesn’t mess with master volume at all. Configured per app volume level will be remembered in existing or new instance of the application and it will persist through reboots as well.

To disable flat-volumes in Ubuntu, you will need to add a line to PulseAudio daemon.conf file. Run command below to create the required directory:

mkdir -p ~/.pulse

Use the command below to create a new or open existing daemon.conf file. You can replace nano with command of your favorite text editor:

nano ~/.pulse/daemon.conf

Paste the following line in the opened file and then save by pressing CTRL+O in nano:

flat-volumes = no

Once you have saved the file, restart PulseAudio server by running command:

pulseaudio -k

You will need to close and relaunch running apps for this to take full effect. Flat-volumes setting is now disabled, lets see how per application volume works now:

Notice that per application volume levels are now fully decoupled from master volume.

Upstream PulseAudio keeps flat-volumes enabled by default. Following suit, Debian, Ubuntu and its derivatives also ship this feature by default. The good news however is that a new commit has been merged recently in Debian that finally disables flat-volumes and there is a good chance it will trickle down to Ubuntu as well (most probably in 20.04 LTS version). Arch Linux has always made a sensible choice of disabling flat-volumes by default.

Why I am making a big deal of this flat-volumes thing? Because it protects you from sudden sound spikes throughout the system and makes volume levels above 100% less annoying and easier to manage. VLC player includes an option for raising volume above 100% which is quite useful when audio quality is less than optimal.

Do note that raising volume above allowed threshold or over-amplification can result in hearing loss, crackling audio or damage to speakers. The next part of this tutorial explains how to increase volume above 100% but you should use it at your own discretion and must absolutely have flat-volumes disabled.

To increase master volume above allowed levels, you can just use over-amplification toggle in system sound settings. For individual apps, you will need to install Pavucontrol app from package manager (some distributions ship this utility by default). To install, run command:

sudo apt install pavucontrol

Launch “PulseAudio Volume Control” from application launcher and go to playback tab to configure volume for running apps (up to 153% ~ 11.00dB):

To further increase volume levels above 153% (read warning above in bold words), you will need to execute certain commands in terminal.

With an app running with audio playback, run the following command in the terminal (use ALT+TAB if using any full-screen application or game):

pactl list sink-inputs

You will see some detailed output about currently playing sound channels. Note down sink input id of the app that you want to raise the volume level for, as shown in the screenshot below:

Then run command below by replacing “sink_input_id” with the input id you found above. You can replace 200% with your own choice.

pactl set-sink-input-volume "sink_input_id" 200%

For the example shown in the screenshot above, final command would be:

pactl set-sink-input-volume 11 200%

Run command “pactl list sink-inputs” again to see volume level raised to 200%. Note that you have to run these commands only once. Next time when you launch Firefox, it will be already at 200%.

This concludes the tutorial. Any changes made on your system after following this guide can be reverted by deleting hidden “.pulse” folder in your home directory (visible after pressing CTRL+H).

Lastly a bonus, here is a link to an excellent guide by Sytem76 about troubleshooting sound issues on your system.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Top 10 Ubuntu Network Tools

Ubuntu is the most popular choice for underlying Operating System due to its ease of use and powerful shell system. Due...
29/12/2020

How To Upgrade To Ubuntu 17.04 From Ubuntu 16.04LTS

Introduction to Ubuntu 17.04 Following the release of Ubuntu 17.04 (Zesty Zapus) on April 13, 2017, people want to know...
12/02/2020

Install Swift 3.0.2 iOS Programing Language on Ubuntu

Swift 3.0.2 most recent release, is an interactive, fun general-purpose programming language built using a modern approach...
28/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

SỰ KHÁC BIỆT GIỮA RESIDENTIAL PROXY VÀ PROXY DATACENTER
17/02/2024

Mua Proxy v6 US Private chạy PRE, Face, Insta, Gmail
07/01/2024

Mua shadowsocks và hướng dẫn sữ dụng trên window
05/01/2024

Tại sao Proxy Socks lại được ưa chuộng hơn Proxy HTTP?
04/01/2024

Mua thuê proxy v4 nuôi zalo chất lượng cao, kinh nghiệm tránh quét tài khoản zalo
02/01/2024