49

I might not be understanding the core concept, in which case correct me if I'm wrong.

Ubuntu comes with two different audio rendering servers, pulse and alsa. Is Alsa an intermediary layer to pulse? Essentially I need to know which one I'm using.

The reason I need to know is that I am attempting to switch from unity to i3-wm. While setting up i3 I found I had no audio and came upon this thread. It specifies various options for binding my laptop volume up and down keys to their functionality and after I tinkered with a few of the options I got very scratchy audio, which is why (I assume) I need to know which I'm actually using.

78

Ubuntu uses both ALSA, and Pulseaudio for controlling sound input and output.

ALSA

ALSA serves as a kernel based system to connect your sound hardware to the operating system. All sound cards in your system will controlled using drivers and card specific settings. Most of this is done under the hood with no need for users to interfere.

In addition ALSA offers libraries and tools to control our sound system. The tool most of us may have come across may be the alsamixer, a semi-graphical terminal application to control sound volume, and mute state of all cards and profiles in our system.

We can give out sound to our soundcard simply by using ALSA without the need of PulseAudio ore anyother sound server.

Pulse Audio

On top of the ALSA base the PulseAudio sound server provides further tools to better control our sound system. This is done with modules to define volume levels, audio card profiles, output sinks, or input sources, and more for easy access from most Ubuntu applications.

Like ALSA, PulseAudio is also designed to run with as few user interactions as possible. Whenever we need to change volume, balance, or input/output devices it is a PulseAudio module or application we or our application call.

A professional alternative to PulseAudio is the JACK audio server with more options to interact with our sound hardware and a better low latency support. Only few music production applications expect to have JACK running, which can be done in parallel to PulseAudio.

Application/Desktop integration

The Ubuntu sound system can further be controlled from applications that run from the Unity/GNOME desktop, such as a volume control applet.

Where any given application makes use of sound control will be up to the application developers. Some applications will only use ALSA, some need PulseAudio, some need JACK.

Therefore whenever we install another desktop manager on top of Ubuntu we may lose the desktop specific applications to control sound but still, ALSA and PulseAudio will run in the background for sound control.

We may have to install additional packages like e.g. pavucontrol Install pavucontrol, the pulseaudio GTK-based volume control application.

Is any of ALSA or PulseAudio running?

Both ALSA and PulseAudio come with command line appliciations to print out the state of our sound system.

  • PulseAudio:

    pactl list
    
  • ALSA:

    aplay -l
    

Both will give an error if the sound system is not running. ALSA will be loaded with the kernel, PulseAudio will be started later. If this was not the case we can start PulseAudio manually from the terminal with:

pulseaudio [options]  ## option -D starts the daemon

In case we have audio issues I recommend reading the post written by David Henningsson on things we should not do befor we go further to debug our audio issue.

  • 1
    @Takkat amazing explanation, thanks a lot. I have been for quite a long time trying to get the basic understanding of the audio system in Linux and Ubuntu. – AlexN Apr 17 '16 at 21:02
  • In my raspberry pi system, "pactl list" returns "Connection refused", but "pactl --server 127.0.0.1 list" works. exporting the environment variable "PULSE_SERVER=127.0.0.1" allows pulseaudio clients to correctly connect. Any ideas what i'm missing ? This is on a raspberry pi. – Joao Costa Jun 19 '16 at 3:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.