XSNDTEST-Sound Card Test for Linux

The program xsndtest (version .17) designed for testing and finding the optimum settings for your sound card. Unfortunately it at present works automatically with the oss (emulation) /dev/dsp sound card port, and will only test at 16 bits resolution-- it can be used to test 24 bit card performance and alsa drivers as well with slightly more work. See the section Alsa below.

The program works in its simplest form by playing out the output port of the sound card, while at the same time recording the same signal through the input port of the card. Thus the card needs to be capable of full duplex (record and play) operation for this simplest procedure to work. However, it can also be used just as the source for the desired test signal to be delivered out the output port to another system, or as the recorder of such a signal from another computer or sound source.

The program generates a waveform which consists of 100 frequencies spread across the spectrum from 16Hz to 16KHz, with ten equally spaced pitches equal in each octave and with equal amplitude. (the lowest frequency and the number of octaves covered by the test signal can be adjusted.)

Spectrum of signal delivered to soundcard

This sound is played for two seconds out the /dev/dsp sound port (The oss driver under Linux) , and recorded at the same time through the same device. The resultant recorded sound is analysed for the 1 second period from .75 sec to 1.75 sec (This is to eliminate any "startup" noise in the recording)

The recorded sound is analysed, both to see if the soundcard has preserved the amplitudes of these frequencies, and to see if it has introduced any extra sounds (noise or distortion). This is a relatively severe test of the card, much more severe that the usual harmonic and IM distortion tests, but also comes closer to the structure of real music, and the distortions and noise introduced by the card into real music.

The key limitation is that the system must operate in loopback configuration, so that it tests a combination of the output DAC and amplifier and the input ADC and amplifier combined. Thus a great output could be hidden behind a poor performance of the recording section of the card.

Of course if you have two cards, one of which is fantastic, it can be used as the source of the signal, to test the input behaviour of the card under test, and as the test of the output of the card under test.

Many sound cards seem to direct the input coming into either Line In or Microphone directly back into the output. This will cause feedback in this test. On the two cards I have tested, this can be eliminated by an appropriate setting of the mixer controls (eg in aumix or alsamixer). If you are using the Line input, choose the Line as the input (ie red dot) in aumix, but pull the Line slider all the way to zero. This slider seems to control only the sound level delivered directly from the input to the output, and not the sound level delivered to the /dev/dsp input. Control the input volume to /dev/dsp with the IGain slider.
You can get an idea both the input and output of the sound card by watching what happens to the noise figures as the amplitude sliders (eg using aumix) are adjusted. Pull down the output slider (ie the PCM slider) to about the half way mark. Adjust the input IGain slider to find the lowest value of the total distortion. Now turn up the output (PGM) until the distortion suddenly rises. (Make sure that the Max value of the signal never reaches 1 or -1-- the signal level slider will turn red. Pull down the IGain if necessary to keep it below clipping). This value of PGM is the clipping level of the output. Do not ever have it higher than that level. Now, with the output (PCM) below that clipping level, turn up the input (IGain) until again the distortion begins to rise significantly (again making sure that Max is less than 1.0-- decrease the PCM slider if necessary) . Again, you should never have the input higher than this.

xsndtest controls and layout

This is the layout of the window of the program. On the left are the controls, and on the right are the spectral displays of the response and the noise/distortion of the card.




To test a soundcard with the alsa sound drivers, rather than the oss drivers, or to test a 24 bit card, download the file sndcard-outputs.tar.gz (Warning it is 10MB in size). To unpack this make sure that you have tar installed and run
tar -xzf sndcard-output.tar.gz
. This will create four files. One is designed for 16 bit, 44100Hz soundcard, one for 16 bit 48000Hz, and two are for the 24 bit 44100Hz soundcard. The L and H refer to the way the bytes are packed into the 32 bits (see

These files each represent 16 seconds of sound output. Choose the file which corresponds to your soundcard's abilities or the property you want to test. Now use aplay and arecord, the alsa utilities to play and record the files. Run a connection from the output to the input of your soundcard. Set up your mixer output ( alsamixer, or amixer) to allow it to both play and record and then play the file and record it at the same time. For example, lets say you want to test your card at 44100Hz 16 bit (or 48000Hz, 16 bit) Do

aplay -f cd -t raw output-16-44100.raw&
( or aplay -f dat -t raw output-16-48000.raw)
Then during the 32 seconds that that playing is going on, also run
arecord -f cd -t raw -d 4 /tmp/input-16-44100.raw
(or arecord -f dat -t raw -d 4 input-16-48000.raw)

These will record 4 seconds worth of the sound being piped out the output and into the input which you can then analyse with xsndtest. Just select 16 bits, speed=44100 ( or speed of 48000 for the -f dat case) and use the "record from file" feature, where you select the filename to be /tmp/input-16-44100.raw (or whatever you named it). You can use the small slider under the filename to select the portion of the file you want to analyse. The program will now analyse one second's worth of the sound in the file for you.

Making your own output file

You can make your own output files as above.
Select the Record from file feature of the program. As the file to be analysed just select some file. This analysis will be irrelevant. Now select the "Save Play output" option and enter the name under which you want it saved. Choose the speed, the bits, the Initial Freq and Octaves you want in your file and press start. The analysis will be garbage, but one second worth of test sound will have been saved to the file you specified in the Save Play output. You can amplify this to larger amounts using cat
cat file1 file1 >file2
will concatenate two copies of file1 into file2. If file1 is your saved play output, then file2 will contain double the time worth of output. You should make sure that you have at least 8 sec worth of material to play.
Copyright W. G. Unruh 2003,2004,2005. Please send any comments to . This document may be reproduced as long as the author's name is not removed, and as long as any changes to the document are clearly marked as such and are sent to the author.