Wednesday, April 23, 2014

Shoot the Trouble -- USB Audio Interfaces


With all the very interesting Raspberry Pis and other ARM devices around, Linux becomes more and more interesting for many people. Great audio transports can be build at 100$.
Not to forget. Tablet and Phones are mainly Androids and that is just another Linux, using the same soundlayer (Alsa) then all other Linuxes.

Manufacturers usually still do not commit to support Linux or Android properly.
Which is insane. The vast majority of mobile device out there are Androids.

However. Many devices work or partially work under Linux, because manufacturers comply to general USB Audio Standards (UAC1/UAC2). Meanwhile even Pro Audio companies like RME offer a "Class Compliant" mode for their newest generation of USB devices. (In the RME case they do officially focus on OSX though.)

Anyhow. Even though things are getting better, there are still plenty of  cases where you'll experience NO SOUND.

That doesn't necessarily mean that your device won't work under Linux.

This article outlines a little guideline for troubleshooting your USB audio interface under Linux.
It should give you certain hints what to look for.

However. Just to make it clear from the very beginning.

I won't support anybody, who got issues with his interface!!! Checkout Google or the community.

If you have comments for improving the article please let me know.





 Many people do have very limited Linux knowledge and give up very quickly if their interface doesn't
 work after turning on the Linux  machine.

Let's start.

Checkout following points.



1. Clarify if your device is UAC2 or UAC1 compatible.
    Ask your dealer, the manufacturer, the community.
    If it is not UAC compatible, you'll need a dedicated Alsa driver. Alsa is the Linux soundlayer.
    Check if there is a dedicated driver for Linux or Android available.
    If this is not the case you won't get the interface up'n running.

    Beware:
    E.g. The Audioquest Dragonfly pages do not talk about Linux support. They wouldn't ever do so.
    However. The device is working under Linux quite well.

    Advice: If you intend to purchase a device. Make sure it is at least UAC2 compatible.
    Don't let you fool by the feature list or forum feedback about great sound or similar.
    Get an interface that works on all platforms.


2. Use the latest Linux distribution you can find. Ubuntu is usually your best bet.
    The community and community support is huge.
    Key is that you've got a pretty up2date kernel installed, which usually delivers the newest audio driver.
    Ubuntu is usually half a year behind the generic kernel development. It's not that bad.
    ArchLinux, another distribution, usually comes with the most up2date SW.
    But  ArchLinux is not recommended for users without in-depth Linux knowledge.
 
   You might install Ubuntu on a stick, just to test if your device gets recognized.




3. Now I'll post some commands, that you issue in a Linux Terminal. Please open a terminal (usually
  the shortcut  "CTRL-ALT-t" should do)


3.1 List all recognized audio devices:

(type commands without #)

# aplay -l


or


# cat /proc/asound/cards


3.2 Check all recognized USB devices

# lsusb

or more in-depth

# lsusb -vv


3.3 Check if the kernel module (which is the driver) is loaded

# lsmod | grep snd_usb

You should see "snd_usb_audio" listed 


You might get a long list. Scroll back. You might find your device listed.


If you can't find your interface at this point. It is most probably not supported.

If you can see it. You might face a setup issue. Continue.


3.3 Check alsamixer settings

Some soundcard controls are set to 0 by default (e.g. Dragongfly onboard volume control).


First find out your soundcard number:

# cat /proc/asound/cards

All listed audio interfaces are indexed, starting with 0 and continue with 1,2,3,4.
Memorize the index that belongs to your interface.

Now we open alsamixer. Replace "INDEX" with your index  number.

# alsamixer -c INDEX


Use the arrow keys to navigate. ESC to exit alsamixer.




4. Soundcheck


There is nice little Alsa utility called speaker-test. It just generates noise.
That's sufficient for testing purposes. Just run

speaker-test -D plughw:1,0 -c 2

Replace "1" with your card index.  -c 2 stands for two channel test. You'll experience a continuous switching left/right channel noise.

Note: Turn your volume control down before you start this test!!






Still no sound...

....let me know.


5. Dropouts, Pops, Clicks, Xruns,.....

There are many setups where users experience nasty XRUNS.
Usually these are caused by buffer underruns.
That means your DAC requires more data then your PC is willing or able to deliver. That's usually caused by competing processes on the same machine.

The first measure is to increase your Alsa output buffer sizes. Usually you'll find
a parameter in the settings menu of your preferred app.

If we take squeezelite as example you'll have 20ms buffer by default.

You might try to increase this setting by adding

-a 40:4::1

or larger

-a 80:4::1

or larger....

As a 2. measure you can try to increase the task priority.

With squeezelite that would be using option -p e.g.

-p 85

Note: 99 is max. The higher you get, the higher the chance that you lock up the system.


Still XRUNS??? ..

....Let me know

To be continued...















3 comments:

  1. Hi, do you have a kernel patch for NAD M51?

    ReplyDelete
  2. Try this one ( I havn't written it myself - lost the link reference):

    #####################

    --- ./sound/usb/mixer.c 2014-01-29 12:10:03.335082952 +0100
    +++ ./sound/usb/mixer.c.b 2014-01-29 12:19:14.079038021 +0100
    @@ -1341,7 +1341,7 @@ static int parse_audio_feature_unit(stru
    snd_printk(KERN_ERR "usbaudio: unit %u: "
    "invalid UAC_FEATURE_UNIT descriptor\n",
    unitid);
    - return -EINVAL;
    + return 0;
    }
    } else {
    struct uac2_feature_unit_descriptor *ftr = _ftr;
    @@ -1352,7 +1352,7 @@ static int parse_audio_feature_unit(stru
    snd_printk(KERN_ERR "usbaudio: unit %u: "
    "invalid UAC_FEATURE_UNIT descriptor\n",
    unitid);
    - return -EINVAL;
    + return 0;
    }
    }


    #####################

    ReplyDelete
  3. Great article - Many Thanks Sir. Helped me reduce XRUNS on A20 using multichannel recording input.

    ReplyDelete