Products > Computers

I think I just solved audio on Linux.

(1/4) > >>

I apologize is this is old news to anyone else, but I've always wanted a truly dynamic audio subsystem to exist on my computer, allowing me dynamically route audio between programs and sound cards.

If you're a Linux user, you no doubt know how complicated sound gets. We have ALSA, which is the direct driver interface to the hardware, but doesn't have good means to mix multiple programs at once, or do complicated mixing, routing, or anything of the like. This is where sound servers like JACK and PulseAudio come in (the two most popular ones on the platform). The issue is that these systems are very much mutually incompatible.

If you're a Linux user, and do not do professional audio, you more than likely use PulseAudio. For most uses, this is fine, it has similar capabilities to the default Windows sound system, and has some flexibility, but a lot of it is hidden under a very complicated and annoying to deal with set of command line config programs, using terms and concepts that, at least to me, are about as intuitive as trying to construct a kit car via instructions you found off the back of a cereal box.

JACK is (there are more, but not that widely used), the other option for having a sound server, and it's honestly beautiful. It provides a simple interface for realtime/low latency audio, with a plethora of high polish tools and configuration options with means to do highly dynamic audio and even MIDI device routing. It's my idea of a perfect sound solution, and besides a somewhat unfriendly process (for new users) to set up, is how I wish all sound on all computers worked.

The issue is, since this is Linux, they are two standards, and programs written for PulseAudio do not work on JACK, and vice-versa. You also cannot forget ALSA-native programs, which often need to be supported inline on both solutions. Ever since these two sound servers have existed, people have tried to make them work together, but guides on exactly /how/ to do that in a way one would really want are complicated and scarce. If this looks like something you'd want to do, but you can't figure out how I did it, I can write a guide, just let me know.

This is a screenshot of what I've come up with, and while I need to polish it for myself, move some stuff around and things, this is exactly what I always wanted. What you are seeing here are two PulseAudio programs (chromium and VLC) playing audio (music). If you see the qjackctl graph you can see that there are two clients, named PulseAudio JACK Sink and PulseAudio JACK Sink-01. In this configuration, chromium is running on 01 and VLC is running on the other one, separately, and independently. I can treat them just like I would any normal JACK client, except they're PulseAudio.

The implications for exactly /why/ I'd want this are vast. I do YouTube streaming, but might be doing something that I'd rather listen to music with, but otherwise couldn't since i need to monitor the sound of what I'm doing too, and do not want to stream the music. With this, I can record one program, but monitor the audio from two. There's more applications than just streaming, and I could end up adding things like multiple sound cards, do neat mixing between them, the works.

The tl;dr of how I did this is by using pulseaudio-jack to connect pulseaudio to JACK as a client, instead of using ALSA, via loading the module module-jack-sink (another one also exists for inputs). To get multiple programs to route, I just loaded it twice, giving me two sinks I can direct different programs to.

I've yet to automate this, as this has a lot of manual configuration nonsense, but that shouldn't be too hard. I just felt like I needed to show this to people who, like me, might have always hated sound on Linux, and would be happy that at least someone figure out how to do it right, with support for everything.

Back in the day you had to recompile the Linux kernel to add support for a sound card.  In my cause it was a Gravis Ultra Sound.  It was a whole lot of messing, the end result did not work properly, which is why I gave up using Linux!

I am also routing Jack with Pulse, I documented how I did it a while back here:

Well, this is not old news, but not particularly fresh news either. ;D

Anyway, it all depends on what you want to achieve... on Linux there are just many ways to solve one problem.

I personally use Pulseaudio for the mundane audio tasks (because I'm mostly on Gnome, where it's default), and pure ALSA (obviously through a different sound card) for more pro audio playback and recording. So both uses are separate and handled differently.

One thing to know is that Pulseaudio eats up more CPU than we would think, and I believe Jack is not that frugal either... it doesn't matter much on a modern desktop computer, but it tends to shorten battery life significantly on laptops...

I just use plain ALSA since bit perfect playback is what I prefer. I'm not very into gaming, but the few games I do play work just fine without Pulseaudio. I also don't do live streaming, so no real need for complex audio routing.

Not sure why Pulseaudio was created in the first place. The JACK GUI looks to be just as intuitive to use for routing signals as physical audio hardware.


[0] Message Index

[#] Next page

There was an error while thanking
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod