Troubleshooting Linux Audio, Part 3a

At last we reach the final installment of this series, the question & answer stage in which we'll consider some of the common problems encountered with audio and MIDI on Linux, along with some common and perhaps not-so-common solutions to those problems. We've looked at some indispensable items for your Linux system troubleshooting toolkit, now let's see how they are applied.

We start with a list of some of the most often-heard laments, then we'll proceed to some extra tips and general advice. I'll end the series with some notes regarding the system configuration here at Studio Dave.

If/Then: Ailments & Cures

Linux audio problems can occur at any of these stages :

Hardware - Physical connections, power status

Soundcard - ALSA driver and configuration

Software - Virtual connections, JACK status

Problems at these points will likely cause audio distress.

The following "laments list" is of course incomplete. New problems arise as Linux itself evolves, but the difficulties listed here represent the complaints most commonly encountered on the various mail-lists and forums to which I'm subscribed. I encourage readers to send in their own examples to add to the list.

If:"My soundcard doesn't make any sound."

Then: Make sure your audio hardware is supported by your sound system. Check the ALSA Soundcard Matrix to see if your card or chipset is listed. If it is not, your card may not be supported and you will need to purchase a different device. If you know your hardware is supported, double-check all connections to & from the device. Make sure all cables are integral and all connections are firm. Check power sources and ensure that all amplifiers, speakers, and mixers are powered up and appropriately connected. Make sure the right connections have been made: You'll have little success adjusting everything else if your guitar is plugged into a speaker output jack instead of the line-in.

If the hardware is correctly installed and connected, it's time to check things at the ALSA stage. Use the following command to see what's actually installed on your machine :

If nothing is reported and you're certain your device is supported by ALSA, run the alsaconf utility (as the root user) to configure and install the correct device driver for your card. After installing the driver you will need to adjust the soundcard mixer output levels. Open a terminal window and run alsamixer or any similar mixer utility. Set the main output and PCM channels to about 75% of their full output, then use a program such as ALSA's aplay or the excellent AlsaPlayer to play a WAV, OGG, or MP3 file. If the file plays without problems run the alsactl program (again as root) to permanently store your mixer channel settings :

alsactl store

Devices that require firmware may need a specific version of that firmware in order to work under Linux. It may happen that your device is supported but its firmware version is not. This information should be available from the ALSA site, but you may also need to inquire on one of the Linux audio mail-lists.

Check software connections too. If you're using JACK, make sure that I/O ports are correctly connected. The last device in your playback or processing chain must be connected to the alsa_pcm outport, else no audio signal will ever reach your speakers. Under typical circumstances you'll use QJackCtl or a similar program to make your JACK I/O connections, but some programs (e.g Csound5) provide an internal mechanism for connectivity to the outside world. Make sure that your application is correctly configured for operation with JACK (i.e., that the correct input/output ports are selected).

If you still have no sound (after double-checking all steps taken so far), then it's time to call for reinforcements. Search the archives of the Linux Audio Users and the Linux Audio Developers mail-lists. You may want to check the ALSA list archives as well (and it would be a good idea to join those lists). Search Google, starting with a string such as "sblive problem linux" and narrowing your search terms as you proceed (e.g. "sblive irq problem 64studio").

If Google and the archives provide no assistance you'll need to ask directly on the lists and any other available comm lines, including relevant forums, wikis, and IRC channels. At this stage you should be prepared to answer some technical questions, so keep the first two parts of this series handy. The gurus of Linux audio are normally quite willing to help even the newest of newbies, but they can help only as far as you can supply relevant useful information. You will be asked for the output from commands such as lspci and lsmod, but don't worry if you have little or no idea what those reports mean. The gurus know, and they'll need that information to help you with your problems. At least make sure you know the name of your soundcard or audio chipset. You should also run the basic diagnostics with the cat command-string shown above.

Above all, be patient and polite. Gurus and wizards are unpredictable life-forms, and we must approach them with humble sincerity. Actually, most of my contacts have been pleasurable and helpful, but they are always most helpful when I've done my preliminary homework. Remember, they are also busy people, and they're often busy improving the very software you may be complaining about, so when you're asking for help, ask nicely.

If:"I get sound but it's chopped up whenever I play a soundfile."

Then: This problem usually occurs with an IRQ conflict. Your sound device requires an otherwise unoccupied IRQ line (a.k.a. an interrupt), else the devices sharing the interrupt will collide when requesting its services. In fact, devices can successfully share an IRQ address, but at no time should the sharing devices operate simultaneously.

You don't have many possible solutions for this problem. Many modern machines include user-programmable IRQ assignments (APIC: assignable programmable interrupt controller), but failing a software solution you may need to remove your card from its current slot and put it into another one (i.e. the IRQ addresses are hard-wired on the motherboard).

Use this command to determine which devices are using what interrupts :

As you see, my SBLive is indeed sitting on IRQ 22, which was also reported by the earlier use of the cat command. If two devices were listed at that address I would then have to move or otherwise reassign my device to a new IRQ location.

Potentially interrupts 9, 10, 11, 3, 4, 5, 6, 7 are made available to PCI slots on most motherboards. You must look at your specific motherboard to know what's available to you. Many newer boards allow you to change the IRQ settings for the PCI interface in the motherboard's BIOS. This is also useful for USB devices as the USB IRQ generally tags along with one of the PCI slots. So you may be able to change the IRQ for your USB card by adjusting the the BIOS settings for the PCI slots. If you cannot adjust the settings in the BIOS your other option is to open your machine and move the cards around in the available slots.

In my experience all audio cards want to be on IRQ's 9, 10 or 11. It isn't actually that important what IRQ a card is on, but it is important which devices are on the higher IRQs. For instance, if your audio card is on IRQ 11, and nothing is on IRQ 9 or 10, then no problem. But if you insert a PCI graphics adapter on IRQ 9, your audio card could start having trouble because the graphics adapter would have higher performance priority. Assume that any device with a higher priority number gets in the way of devices with lower priorities.

One last thing about non-APIC: Interrupts may be shared. Just because your card is on IRQ 9 doesn't mean that another device isn't sharing IRQ 9. What matters in this case is how many interrupts the other device is going to generate, and how well its driver is written.

Mark's notes apply to both APIC and non-APIC machines. The APIC architecture adds more interrupts to the system, along with programmable assignment. For more information on the subject, see Clement Ladisch's page on Setting Linux Interrupt Priorities.

Stuttering audio may also occur if a system sound daemon such as KDE's artsd or GNOME's esd is installed and running at the same time as the JACK audio server. Remove or disable the daemon to eliminate the problem.

If:"I get sound but it's noisy."

Then: Mute all mixer channels except the main volume output and the PCM channel. If the noise disappears, raise the channel levels one by one to determine which channels are noisy. For example, the CD and mic channels on my SoundBlaster PCI128 must be muted when not in use, else they create an audible and very annoying hiss. For best results, always mute unused mixer channels, especially when recording. Note also that merely bringing levels down to zero may not entirely eliminate channel noise. Mute those unused channels, it's a good rule to follow.

Cable quality can definitely make a difference. Avoid cheap unshielded molded-end plastic cables, and use good-quality connectors. A loose-fitting plug can cause static noise and audio dropout, and the jacks on consumer-grade soundcards are typically not high-quality connectors, so you should ensure that all connections to the card are made firmly, with no "wobble". If necessary, purchase better connectors (I use the gold-plated adapters from Radio Shack).

Alas, computers are inherently noisy devices. Along with the audible sounds from fans and drives, your machine creates RFI (radio frequency interference) noise that can be picked up by sensitive equipment such as your soundcard. Professional audio boards work around the problem by shielding the board hardware and by providing an external break-out box to house the RFI-sensitive ADC/DAC converters. Consumer-grade cards are more prone to noise pollution, and if the problem is serious enough you may need to purchase either a better soundcard or a better motherboard. I considered this issue when I purchased the motherboards for my desktop machines, and I settled on AMD64-based boards from Gigabyte after reading on-line recommendations from other audio enthusiasts.

One further note regarding noise sources: I have a very nice HP Deskjet 6540 printer attached to my 64Studio box, and it is a wonderful device. Alas, when the USB cable is plugged into the printer it causes a thin screeching sound through my speakers that disappears only when the cable is detached from the printer. Even turning off the printer doesn't fully cancel the noise, it just changes its frequency. Fortunately the noise doesn't affect my recordings, it occurs only during playback, and unplugging the cable completely eliminates it.

If:"I'm using JACK, and periodically it creates a crackling noise."

Then: Make sure JACK's sample rate is set to the optimal value for your card and for your purpose. SBLive owners should note that their soundcard is hard-wired to record at 48 kHz, not the CD-standard 44.1 kHz, so JACK's sample rate should be set to 48 kHz. If the problem persists, contact the JACK developers. This problem is well-known, and it is usually the result of a mismatched sample rate.

If:"JACK reports too many xruns."

Then: In JACK-speak, an xrun is a lapse in the audio data stream. Depending on the circumstance and your hardware, an xrun or two may be dismissable, but more than a few usually indicates that something in your system is seriously misconfigured. The two most common solutions for xrun problems are: 1) Your Linux kernel is not optimized for realtime performance, or 2) your JACK settings are incorrect.

Regarding the Linux kernel, I'll cut to the chase: In my opinion, these days the normal user has little or no business mucking about with building and installing a Linux kernel, especially if the kernel is being built for a specific purpose (such as a digital audio workstation). We have so many excellent realtime-optimized distributions available now, in which all (or at least most of) the hard work has been done for you by experienced developers, and it just doesn't make much sense to undertake the task of configuring and installing a specially-tailored kernel. It's not that building a kernel is so difficult, it has simply become unnecessary. Furthermore, a low-latency system is more than just an optimized kernel, it includes many other configuration options that may or may not be obvious to a normal user.

By the way, if you don't know whether your existing kernel is realtime-enabled, you can use the uname command to find out. Here's what it says about my JAD box :

The important item here is the kernel version number 2.6.19-5-rt. The "rt" indicates that this kernel (version 2.6.19) has been compiled with realtime optimizations. If uname reports a kernel without the rt extension then there's a good chance you're running a kernel that may not be a best fit for JACK. If that's the case, I highly recommend installing one of the multimedia-optimized distros. Otherwise, you must configure and install an optimized kernel yourself (see the Low-latency HOWTO for information on building your own realtime kernel).

Figure 1: Conservative settings in JACK

JACK itself has a variety of settings that can affect realtime performance, as you can tell from the Parameters panel in the QJackCtl Setup screenshot seen in Figure 1. Obviously the Realtime option should be checked, especially if you're working with a realtime-enabled kernel. These settings also affect realtime performance :

Then: Check your media audio output configuration. If it's set for 5.1 or other multi-channel output then you must have the appropriate hardware, else some audio channels will not be heard clearly (or at all). Check your player's audio preferences, set them to correspond to your hardware capabilities.

If:"My mixer levels are gone when I reboot my machine."

Then: Set your mixer channels to the desired levels, then run alsactl store. Remember, you must run the command with root privileges, otherwise the settings will not be written. If the problem persists, contact the ALSA developers.

If:"The audio latency in WINE is terrible."

Then: You have at least two possible solutions. You can purchase a faster machine (WINE seems to favor speedy hardware) or/and you can use the wineasio driver. If you choose the wineasio solution, make sure its sample rate matches the value in JACK.

This concludes the Q&A part of Troubleshooting Linux Audio, Part 3. Due to space restrictions I must split this part, so I'll present some MIDI troubleshooting strategies and some final remarks and comments in my next entry.

hi my microphone is not detected on linux-2.6.10..
Can anyone tell
1) how device driver will be selected to the microphone on kernel.
2) what part of linux code will detect the usb devices and loads the device driver.
3) how to know whether the perticular microphone is supported by the kernel.
Thank u..

hi my microphone is not detected on linux-2.6.10..
Can anyone tell
1) how device driver will be selected to the microphone on kernel.
2) what part of linux code will detect the usb devices and loads the device driver.
3) how to know whether the perticular microphone is supported by the kernel.
Thank u..

The Adobe Flash Player uses ALSA (and only ALSA). So you need to make sure ALSA is setup and working properly (like earlier parts of this article discuss). If a sound device is being accessed by a process (program), then it will usually block the next program that attempts to access it.

So check all that (check your mixer settings and run 'alsactl store' as root), then reboot the PC and go straight to youtube and see if you get any sound. I sometimes I have to restart my alsa sound system like this:

Oh yeah... Sound servers suck! PulseAudio is your enemy. If you installed / run Gnome, it's more than highly-likely that it's screwing up your sound. At this time KDE 3.5 seems to be the best trade-off for a nice (feature-rich) desktop environment vs. performance; and you can easily disable the arts sound server (and use ALSA for sound events instead). Debian 5.0 (lenny) includes this version of KDE on the 'kde' iso install image. You might as well crack your knuckles and start-up your favorite websearch engine for "disable pulseaudio" if you got that shaft (there are more than a few places in your system that pulse sticks its ugly head).

I've installed latest alsa drivers for this soundcard and I configured jack server. I hear everything when I play it with any player or when I open a file in Audacity. When I start jack server (which - i think - is configured properly) I can only record, but I can't hear anything when I push Play button (it's playing but there is no sound in my head phones). I can play the exported file and I can hear it using standalone player like totem or mplayer.

I've discovered an odd bug in the system. I'm running Ubuntu on a Toshiba Satellite A100
If I use the internet and play any kind of sound file (youtube, radio, etc...) when I try to play music on rhythmbox, nothing plays. Even after I've closed the internet the sound will not work on anything else until I've restarted.
What's happening?

hi my microphone is not detected on linux-2.6.10..
Can anyone tell
1) how device driver will be selected to the microphone on kernel.
2) what part of linux code will detect the usb devices and loads the device driver.
3) how to know whether the perticular microphone is supported by the kernel.
Thank u..

I recently bought a usb midi cable, which when I plugged in worked first try. I'm still figuring out how to configure everything but eventually got so that I could play a keyboard, and hear a note. :)

The problem occurred the next day. I turned on the computer and there was no alsa sound available. Running alsamixer showed the dreaded "no mixer elems found". I spent many hours googling and trying things out.

The solution turned out to be simple. I had left the usb midi cable plugged in. The computer was finding that, and assigning it to be the first sound source. The second sound source was my regular sound card. If I booted without the midi card plugged in things went back to normal.

Of course it would be better to somehow specify the order of the sound cards so I'm not plugging/unplugging usb cables. If anyone has a gentoo solution I'd be happy to hear it.

Hello
I am using USB<>MIDI cable made by SWISSONIC, but i think all that kind cables should work witout problems. I have Yamaha S-08 (connected via USB), M-audio keyboard controler (connected via USB) and i had no problem wih it. Just conect USB and use.

There's a lot to be said for USB soundcards. A cheap card such as the Behringer 602 only costs about $20, and provides stereo 16-bit in and out. The huge advantage is that the internals of the computer don't interfere with the soundcard, and you get some measure of earth-loop protection too. Obviously this isn't for serious pro use, but for simple stereo playback, it's an extremely good solution. This is what I use, together with 256-kbit/sec Ogg as a replacement for a CD-player.

Although your $20 USB sound box may not be for serious pro work, a nicer one certainly is. I work with some pros who record radio commercials, and they have a USB sound box attached to the PowerMac in the studio.