You are not logged in.

#1 2015-10-14 07:45:45

Snap
Member
Registered: 2015-10-02
Posts: 465

Understanding audio in Linux

The audio infrastructure and its configuration in Linux can be very complex and cryptic. Sometimes hard to deal with. I think that knowing and understanding the parts involved, their roles and how they work and interact, might be a good starting point to get a good view of the whole picture. I'll try to cover it here.

Any operating system needs something to communicate the applications and the system itself with the hardware. These are the drivers. In the particular case of the audio in Linux there are three possible Sound Architectures providing different sets of drivers. They are: ALSA, OSS and FFADO. They can live side by side within a system and don't interfere each other. They are independent. You can use just one or them three depending on your needs.

OSS:

The Open Sound System (OSS) was the original sound architecture in Linux. It was superseded by ALSA years ago. OSS is still around mainly for compatibility. It has good support for old hardware. So if that's your case, OSS might save your day. Though OSS still has its lovers these days, ALSA has a huge and ample hardware support in comparison and also has an ample OSS compatibility.

ALSA:

The Advanced Linux Sound Architecture (ALSA) is the current Linux default kernel component for the audio drivers. ALSA is intended to support a wide variety of audio devices and protocols such as USB, PCI, Bluetooth, Modem, etc... and also being transparent, stable, reliable, widely configurable, It's feature rich, supports up to 8 simultaneous soundcards, multi channel, full duplex, surround... And it certainly is powerful and capable, but it has a major drawback. It's single client. That's why the PulseAudio and Jack sound servers are needed. More on this later.

FFADO:

The lack of Firewire support by OSS and ALSA made the FFADO project to born (formerly FreeBoB) to provide Open Source Free Firewire Audio Drivers for Linux. The Firewire protocol is in the verge of being obsolete. Apple doesn't care about it anymore and it has been always a kind of intruder in the Windows world. So why bothering or care about Firewire sound cards today?

First, this is Linux. Linux is always a good playmate with old and legacy hardware. An aged piece of hardware barely supported by Mac or Win anymore can be a porweful tool to have on Linux.  Something like a legendary ten years old Edirol FA-101 is still a highly valuable and desirable powerful sound card these days still having a long life within a Linux environment.

Second. The best choices for audio sound cards in terms of performance and latency are; first, internal (PCI). And second, Firewire (besides the lack of ALSA support).  Why Firewire is still better than USB?

Firewire:
High badwidth
Low latency
Synchronous data streaming

USB1
Low bandwith
Asynchronous data streaming

USB2
Medium bandwidth
Asynchronous data streaming
No audio device class specification (Hence poor ALSA support)

So the best choice are internal PCI cards supported by ALSA. No doubts. For external cards, the best choice is still Firewire, followed by USB1 and better stay away from USB2 cards if supported. Most are not.

Sound Servers:

The sound servers play the role of that single client feeding ALSA (OSS or FFADO). They are like a kind of proxy in-between the sound applications and the drivers. When they are present in a system, they receive anything being played by the system itself or the different applications, collect and sum the signals together and forward them as a whole to ALSA (OSS or FFADO). In certain way they are headless mixers, or act like the summing buss of a mixer.

PulseAudio:

PulseAudio is intended to expand the capabilities of ALSA (at fisrt instance). It allows the system to be multi-client, transfer sound via ethernet, resampling, altering channel counts, mixing streamings, etc... There are modules (sinks) available to connect to FFADO and OSS too, so it can serve sound for ALSA, OSS and Firewire devices. Most distros include PulseAudio installed by default these days, with the exception of some DAW or multi-media dedicated distros that leave it away on purpose.

All in all PulseAudio sounds like a very good idea. The main drawback is that it doesn't depend on itself. It depends on the application developers. So in many cases, Pulse is a source of troubles. In theory or an ideal case, any application able to produce audio in Linux MUST be able to play through ALSA, and if well designed, it should be able to play through Pulse too. But in the real world this is far from being true. Hence the typical PulseAudio issues and nightmares. Some apps are not even able to play through ALSA, the default Linux Sound drivers, which says poor things about their developers and the apps themselves. When we blame PulseAudio for bad performance and issues many times the culprit is in fact not PulseAudio itself, but a bad designed piece of software not playing right with Pulse. Some applications or types of applications need specific sinks or modules to connect to Pulse, cannot connect directly to it the “standard” way. And many apps just perform poorly. So this is the actual problem of PulseAudio. It's not a self-contained server. There are many bits of Pulse spreading all over a system and many bits are living within the applications. That's what can make of it a real mess deal with.

With well selected applications and a good configuration PulseAudio can perform very well. There is also a good example of a distro, KaOS, which have all their application packages rewritten and modified on purpose to make them work properly with Pulse. In that distro Pulse performs like a charm. You cannot even purge PulseAudio there, because it's fully interleaved and integrated in the system. But sadly KaOS is an exception in the Linux world.

Jack:

The Jack Audio Connection Kit is an ambitious project developed with pro audio in mind. Like PulseAudio it's a sound server but there's way more than that. It's low latency capable and it allows you to connect almost anything to anything else. It can connect to ALSA, OSS, FFADO, PulseAudio, apps to apps, or directly play synchronized Jack apps without even connecting to ALSA.

Jack is so extensive and capable so I won't get deep into it here because it's way beyond the scope of this basic guide, But from my point of view and experience, I can tell for sure it's simply the best choice for Audio in Linux.

image.jpg

Hope all this help someone.

Offline

#2 2015-10-14 09:18:58

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 7,308
Website

Re: Understanding audio in Linux

Snap, many thanks for taking the time to write this.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), idle Twitterings and GitStuff )

Introduction to the Bunsenlabs Lithium Desktop

Offline

#3 2015-10-14 10:46:07

dolly
Miss Mixunderstand
From: /lab1
Registered: 2015-10-03
Posts: 404

Re: Understanding audio in Linux

Great write up, thanks.


Keep BunsenLabs #!yish please.

Offline

#4 2015-10-14 12:13:39

AL13N
Member
Registered: 2015-10-05
Posts: 148

Re: Understanding audio in Linux

An informative post.  Thank You.

Offline

#5 2015-10-14 16:59:45

Sector11
Conky 1.9er Mod Squid
From: Upstairs
Registered: 2015-08-20
Posts: 6,401

Re: Understanding audio in Linux

OH BOY!  Bookmarked - Thanks Snap.


The sun will never set if you keep walking towards it. - my son
Being positive doesn't understand physics.
_______________________________
Debian 10 Buster = SharpBang ♯!

Offline

#6 2015-10-15 01:21:02

zephyr
Member
From: Norman, Oklahoma-USA
Registered: 2015-09-29
Posts: 412
Website

Re: Understanding audio in Linux

@Snap: You are the man with the answers with the sound issue, who hasn't had sound issues? I will need to rethink my sound capabilities,  enjoy audio as much as most. This is an excellent guide to discovering Jack and it's potential for a much better sound system with Debian. Thank you.

@OziTraveller: Thanks for the link mate.

Cheers
zephyr

Offline

#7 2015-10-15 10:44:36

beerstein
New Member
Registered: 2015-10-14
Posts: 4

Re: Understanding audio in Linux

Hi there: I use pulseaudio and pavucontrol to direct the sound card output via alsa
to pulseaudio to the mike input or 3.5mm analog output or even for internal monitoring.
It is a bit tricky, but it works. Pulseaudio must be installed. In many distros it will be
installed wit setup. Then you need the pavucontrol (GUI based mixer like panel)
Here you can do the config of your sound. I plan to do a tutorial on this in the future.

I discovered that certain applications such as iceweasel ond VLC use different priorities
on selecting an output device. So it may happen, that you have sound in VLC but no sound in
Youtube videos. (iceweasel)

If somebody experienced the same problems please contact me.
I did not try pulseaudio for this yet - but it might work - not sure.

Offline

#8 2015-10-15 21:30:48

wagmic
Member
From: Casablanca
Registered: 2015-09-30
Posts: 85

Re: Understanding audio in Linux

Thank you for sharing


La liberté, personne ne peut l’expliquer mais tout le monde peut la comprendre.Cecilia Meireles
Tout ce qui n'est pas donné ou partagé est perdu (proverbe tsigane)

Offline

#9 2015-10-16 10:12:57

Snap
Member
Registered: 2015-10-02
Posts: 465

Re: Understanding audio in Linux

I discovered that certain applications such as iceweasel ond VLC use different priorities
on selecting an output device. So it may happen, that you have sound in VLC but no sound in
Youtube videos. (iceweasel)

Different audio/player apps have different deafults. Some are set to pulse, some to alsa, some to jack if detected. You often need (depending on the particular apps) to switch the audio default manually in many of them.

Regarding browsers, that's a mess. The tendency to make them swiss-army knives able to do it all on their own is a PITA. Our browsing would be way simpler and smoother if they just browse and leave the other tasks to the system/user defaults. But it won't happen. Competition is huge amongst them and devs add more and more crap to their browsers making the bulkiest and often the more resource hog apps in any system. Audio suffers from this too. Sound from browsers not coming through is a common issue.

I stopped using pulse a long time ago. My systems always have Cadence (jack & ALSA plus the included bridges) on board. Not the lightest approach and surely not for everyone, but the best one I've found. I never save resources or cut corners for audio. It takes whatever is needed for the best quality, performance and versatility. I want the best possible setup, and in Linux it's called Cadence by falkTX (KXStudio).

Last edited by Snap (2015-10-16 10:26:00)

Offline

Board footer

Powered by FluxBB