Using ALSA's speaker-test utility
Note: If you just copy and paste the text in the code boxes, you will be doing yourself a great disservice. Please attempt to read this entire page before doing anything, because once you're done you should actually understand enough to be able to simply type in the right command and you'll know it's the right command.
Configuring a new sound card (particularly when there's no drivers from the vendor) is a task that can be called "trying" even on the best of days. Sound card manufacturers seem to delight in making their products just slightly different from everyone else who licensed the exact same technology, just to try and distinguish themselves from their competition. This leads to multiple variations of the same sound card, all with their outputs wired physically differently but still identifying to the CPU with the same PCI ID (which according to standards means they should behave identically). Add to this that some hardware is poorly documented, or incorrectly documented, or not documented at all and forces the ALSA developers to reverse-engineer every step of the way. Many sound chipsets, in addition to having multiple speaker outputs, also support multiple output mechanisms like SPDI/F in addition to "mere speakers". Some sound chipsets allow some of their input ports to be virtually rewired as output ports to drive even more speakers at the expense of losing line-level or microphone inputs. Once you put all these factors together, it starts to become essental that there be a relatively simple way to test your configuration to be certain that all your speakers are actually functioning and emitting the sounds they should before you start pestering application developers with complaints that their software doesn't work.
Thankfully, this is exactly what the speaker-test binary is meant to do... to send some sample output that will uniquely identify each speaker channel in an unmistakable way. The user merely needs to specify how many channels of sound, and to which device the test output be sent. Optionally the user may also specify what type of output sounds will be sent for more detailed testing. When you run speaker-test, provided things work even a little bit, you'll hear some noise (and I do mean pink noise) from one of your speakers and see the following appear in that terminal:
root@mythtv:~# speaker-test speaker-test 1.0.14 Playback device is default Stream parameters are 48000Hz, S16_LE, 1 channels Using 16 octaves of pink noise Rate set to 48000Hz (requested 48000Hz) Buffer size range from 2048 to 16384 Period size range from 1024 to 1024 Using max buffer size 16384 Periods = 4 was set period_size = 1024 was set buffer_size = 16384 0 - Front Left Time per period = 2.664952 0 - Front Left Time per period = 2.986672 0 - Front Left Time per period = 2.986775 0 - Front Left
Setting the number of speakers
speaker-test -c 6
Invoked with no arguments, speaker-test will only ever attempt to test the left front speaker with an output of pink noise (which is similar enough to white noise that it makes no difference). This leads us directly to the first argument you'll need to pass to speaker-test, which is how to tell it you want more than one speaker tested so that you can determine if the rest of your speakers are working as well. For this, you pass the -c argument followed by the number of speakers (counting the subwoofer or LFE if it exists). If you have a simple two-channel stereo setup, you'll want -c 2. If you have a more complex setup with two front speakers and two rear speakers for a total of four, you'll want -c 4. If you bought something promoted as a "home theater kit" which came with two front speakers, two rear speakers, a surround speaker and a subwoofer (also called an LFE on some obscure islands) then you've got a total of six speakers and should use -c 6.
Selecting the output test sounds
Pink noise isn't for everyone, and unless you like being forced to sit and watch a screen while you perhaps move a bunch of speaker connections around you'll want something a bit more complex to test with, like a sine wave, or a human voice that perhaps tells you which speaker you should be hearing things from so don't need to watch the terminal anymore and can walk around the room if you need to. The type of test speaker-test performs is controlled by the -t option followed by a required argument.
Pink Noise Test
The time to use pink noise is when you want a sound from a speaker, but you're not really concerned about what that sound is. The advantage to pink noise is that since it's a broad-spectrum sound, it should usually be audible coming from your subwoofer (LFE) which may have a lowpass filter in the way preventing sounds above 100Hz or so from ever making it through to the speaker. Pink noise is generally what speaker-test will use by default, but if you'd like to explicitly specify this you can use the -t pink argument.
Sine Wave Test
The sine wave test is a little more subtle in that it generates a pure tone at a specific frequency (which by default is 440Hz or, second-octave A if I remember correctly) that you should be able to hear clearly. Selecting the sine wave test is done with the -t sine argument. You can set the output frequency using the -f argument as well, so if you'd like to generate a 2600Hz (for no particular reason at all) tone to test with, simply pass -f 2600 as well. The advantage to the sine wave test is that if there's something so misconfigured or malfunctioning in your sound card or external amplifier as to cause overdriving or distortion to the eventual output, it will be very easy for your ears to detect.
The voice test is probably the most common test for people to use because as each speaker is tested a human female voice says "Left Front", "Right Front", "Left Rear" and so on, allowing one to move around the room and verify that sounds are coming from the appropriate speaker and only the appropriate speaker for each channel. Due to the aforementioned lowpass filter issue (and subwoofer design) what one hears from the subwoofer may sound like an unintelligible "mumble-murfle". This is normal. Specify the voice test using the -t wav argument.
Selecting the proper output device
There's more to a speaker setup than merely telling speaker-test the number of speakers you have. You will need to specify a speaker configuration for anything more complex than a simple two-speaker stereo output, and this is most easily done through a number of pseudo-devices which ALSA now defines for you (they didn't used to be). Note that if you specify a number of sound channels other than what the output device you select has, speaker-test will cough up an error message and exit. You can find out about the existence of these pseudo-devices using the command aplay -L which will give output like the following:
root@mythtv:/usr/share/alsa# aplay -L default:CARD=NVidia HDA NVidia, ALC662 Analog Default Audio Device front:CARD=NVidia,DEV=0 HDA NVidia, ALC662 Analog Front speakers surround40:CARD=NVidia,DEV=0 HDA NVidia, ALC662 Analog 4.0 Surround output to Front and Rear speakers surround41:CARD=NVidia,DEV=0 HDA NVidia, ALC662 Analog 4.1 Surround output to Front, Rear and Subwoofer speakers surround50:CARD=NVidia,DEV=0 HDA NVidia, ALC662 Analog 5.0 Surround output to Front, Center and Rear speakers surround51:CARD=NVidia,DEV=0 HDA NVidia, ALC662 Analog 5.1 Surround output to Front, Center, Rear and Subwoofer speakers surround71:CARD=NVidia,DEV=0 HDA NVidia, ALC662 Analog 7.1 Surround output to Front, Center, Side, Rear and Woofer speakers iec958:CARD=NVidia,DEV=0 HDA NVidia, ALC662 Digital IEC958 (S/PDIF) Digital Audio Output hdmi:CARD=NVidia,DEV=0 HDA NVidia HDMI Audio Output null Discard all samples (playback) or generate zero samples (capture)
Judging from the above, the ALSA driver is aware of the possibility of a 5.1 surround system configuration, so one could perform a connection test to make sure sound is going to the proper speakers in 5.1 configuration by selecting -c6 and -Dplug:surround51. If your card supports spdif output, then -Dplug:iec958 or -Dplug:spdif should also work.
Should the test fail
Should the test fail for any reason--sound coming out of the wrong speakers, sound only coming out of some of the speakers, etc--you should search elsewhere on the wiki after checking your connections carefully (and attempting to simply swap some wires around) as the scope of this page is merely to tell you how to test your new configuration, not how to fix the hundreds of things which could potentially go wrong with it.