I'm going to try to keep this guide as distribution agnostic as I can, I'm sure that all of these packages are available for all of the major Linux distributions so I leave it up to you to get them and install them.
Jack AudioI'm using Jack version 0.116.2
Start by installing jack on your computer. :)
The beautiful thing about jack is its super low latency real-time support, but in order to realize its full potential you will likely need to do a bit of tweaking to your system first.
Fortunately there is a perl script called the "Realtime Config Quickscan" for Jack which you can download and run in order to see what has already been setup on your system and what still needs to be fixed, I highly suggest getting and running that script as the first order of business.
When I run the script on my system the output looks like this:
A couple of things may stand out when you look at that, first you may notice that I'm not running a real-time kernel, surprise! Actually you don't need to be running a real-time kernel in order to get real-time audio with Jack as long as you are running a reasonably recent version of Linux.
Quite frankly compiling your own kernel can take a lot of time especially if you make a mistake, and time is my most precious resource so I prefer to run the standard issue kernels which come with my distribution and I just always make sure they are as up to date as possible.
So here is a list of the bare minimum needed to get real time audio in Linux.
First make sure you are in the audio group, this can be done from the command line like so:
$ sudo gpasswd -a <USER> audio
Change <USER> to your user name.
Next edit the file /etc/security/limits.conf
In that file you should see two lines that look like this:
Move those two lines to the very end of the file, and right above them add the following information:
It should look like this when you are done:
Next, check if you have a shared memory file system mounted on /dev/shm by running this command:
$ mount | grep shm
If you see output then you're good to go, otherwise add this text to the /etc/fstab file:
While you are there messing with your /etc/fstab make sure that all of your major file systems such as /boot, /, and /home, as well as /dev/dvd and /dvd/cdrom and any external hard drives all have "noatime" listed among their options, this can significantly increase file system performance and it will make the Quickscan script happy.
The last thing to do is to set your max_user_watches, open the file /etc/sysctl.conf and add this to the end:
fs.inotify.max_user_watches = 524288
Next restart your computer, yes I know, we all hate to reboot, but sometimes it is necessary and this is one of those times.
After the reboot, as a regular user start jack from the command line:
jackd -R -P89 -s -dalsa -dhw:0 -r48000 -p256 -n3
If all goes well your system now has real time audio capabilities. You will now need to start jack as a regular user (not root) every time you login with the command listed above, I leave it up to you to figure out the best way to do this on your system, personally I just add a little shell script to my users startup applications.
Connecting GStreamer to JackHaving realtime capability is only great if your applications actually know about it. So lets connect GStreamer to Jack so that Gnome desktop apps like Rhythmbox, or whatever, have access to your new cool sound system.
I am using GStreamer Core Library version 0.10.26
First of all you will need to install the Jack plugin for GStreamer, this can be found in a package called gstreamer-0.10-bad-plugins (I've also seen it called gstreamer-0.10-plugins-bad).
After installing the plugin make sure that you have both jackaudiosink and jackaudiosrc by running this command:
$ gst-inspect-0.10 | grep jack
If you see output for both jackaudiosink and jackaudiosrc then you are good to go. If you are missing jackaudiosrc then you are running an old version of gstreamer and I strongly suggest that you upgrade it. You can still continue onward with this guide but you will be unable to record audio input from a microphone, so if using a microphone with a GStreamer app is important to you then you are out of luck unless you upgrade.
Next, on the command line, launch the program called gstreamer-properties and change the audio settings so that they look like this:
That wasn't so hard, was it.
Rhythmbox and other Gnome audio applications that use GStreamer should work as expected now.
(Some old Gnome audio applications may still not work right, for example gnome-audio-recorder does not work for me, but its not exactly essential so I don't really care. If you need to record audio through your microphone then I suggest using Audacity anyway.)
Introducing libflashsupport-jackSometime in the near future Flash may be put out to pasture by newer and better technologies such as html5 but for now most people need it.
I've never had an easier time hooking Jack to Flash than with libflashsupport-jack by Torben Hohn, actually, I've never hooked Jack to Flash at all until now.
You can download it from git, or if you are using Archlinux and packer then you probably don't need me to say anymore ;)
Dear sweet VLCOK, we all know VLC is great but when it comes to Jack some might have an issue because of VLC's rather silly setting defaults.
I am using VLC version 1.0.5
Open VLC, go to Tools -> Preferences, then click Audio, then change the output type to "JACK audio output". Done? Nope!
Notice that down in the lower left hand corner there is a toggle option button, it is set to Simple by default, change this to All instead.
Then in the "Advanced Preferences" window go to Audio -> Output Modules -> JACK and put a check in the check-box which says "Automatically connect to writable clients." It should look like this:
I have no idea why this isn't enabled by default, or at the very least over in the "Simple" preferences, but anyway thats what you need to do to get VLC to connect automatically to Jack.
I hope you've found this helpful and I hope you have fun using real time audio on Linux!