January 22, 2017

Better Linux Sound Managment With ALSA, Part 2 - page 2

Testing Sound Channels

  • March 6, 2008
  • By Carla Schroder
How do you know what type of output your sound card supports? aplay tells the tale:
$ aplay -L
    VIA 8237, VIA 8237
    Front speakers
    VIA 8237, VIA 8237
    4.0 Surround output to Front and Rear speakers
    VIA 8237, VIA 8237
    4.1 Surround output to Front,
        Rear and Subwoofer speakers
    VIA 8237, VIA 8237
    5.0 Surround output to Front, 
        Center and Rear speakers
    VIA 8237, VIA 8237
    5.1 Surround output to Front, Center, 
       Rear and Subwoofer speakers
    VIA 8237, VIA 8237
    IEC958 (S/PDIF) Digital Audio Output

If you ever need to specify the PCM device, this is where you find it: front, surround40, surround41, and so forth are PCM devices that should have been created automatically at startup. You could test these with aplay, like this:

$ aplay -D front test.wav
Playing WAVE 'test.wav' : Signed 16 bit Little Endian,
 Rate 44100 Hz, Stereo

You may also also test playback by using the card+device numbers. This is sort of a "raw" test, since it doesn't depend on having a correct PCM devices configuration, but uses the card IDs assigned by the kernel. aplay -l shows the "raw" card+device numbers. 0,0 is the first device, 1,0 is the second device, and so on:
$ aplay -D hw:1,0 test.wav
If you have a second sound device, such as a USB headset, you can configure the PCM device names either globally in /etc/asound.conf or per-user in ~.asoundrc. Something as simple as this works just fine:
pcm.v8237 {type hw card V8237}
ctl.v8237 {type hw card V8237}
pcm.headset {type hw card Headset}
ctl.headset {type hw card Headset}

For pcm.v8237, the pcm part is required. The v8237 can be anything you want, and the same goes for the ctl lines. type hw card is required; V8237 and Headset come from the output of aplay -l. You could also use asoundconf:

$ asoundconf list
Names of available sound cards:

Now instead of using aplay -D hw:1,0 test.wav I can use aplay -D headset test.wav. You want to use the names (V8237, Headset) in your configuration file instead of the kernel IDs (0,0- 1,0), because the kernel IDs can change, especially udev devices.

Sitemap | Contact Us