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
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
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
the amplitudes of these frequencies, and to see if it has introduced
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
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
happens to the noise figures as the amplitude sliders (eg using
are adjusted. Pull down the output slider (ie the PCM slider) to
half way mark. Adjust the input IGain slider to find the lowest value of the
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
Now, with the output (PCM) below that clipping level, turn up the
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
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.
- Freq slider--This determines the lowest frequency of the signal
sent to the card. This is one of the discrete values corresponding to
the 100 discrete frequencies produced (ie 10 equally spaced pitches per
octave, and 10 octaves). If this is adjusted the octave slider is always
also adjusted to ensure that the top frequency never exceeds 20KHz.
- Octave slider--This slider determines the number of octaves (1-10)
of pitches covered by the test tones. This is always a whole number and
is always adjusted to that the maximum frequency never exceeds 20KHz.
For most purposes these two sliders can simply be left in their
This button determines whether a signal is sent out by the
program to the soundcard. If it is blue, does send out a signal.
- Record-- This determines whether the program records a signal,
either from the soundcard or from a file, and analyses that signal.
The analysis proceeds by the program taking 1 second worth of
material and performing a Fourier analysis of that material. At each of
the frequencies as determined by the Initial Freq and the Octaves
sliders (ie 100 frequencies by default) the power in the recorded signal
is determined and plotted in the top graph on the right. The power at
the other frequencies, which is a combination of the noise and
distortion is plotted for the right and left channels on the lower two
graphs on the right.
- Start-- This starts the test and sends out the signal, records the
signal and analyses it depending on the other settings. It will remain
depressed during the course of the test. The test lasts for two seconds
plus whatever the analysis and plotting time take.
- Exit-- Exit the program
- Record from file-- This button determines whether or not the program
records and analyses the sound from the soundcard or the sound stored in
a file. The file is assumed to be a raw stereo file, with the speed and
the bits per sample as determined by the selectors described below. (The
24L and 24H selectors are assumed to be 24 bit samples packed into 32
bits, with either the bits packed into the lower or higher bytes of the
32 bits. The highest or lowest byte is assumed to be zero.
The name of the file must be typed into the input region.
If the file is longer than 2 sec of data, the slider below the file name
input region can be used to select from which part of the file the 1 sec
sample will be taken.
Note that when this option is selected, the Play option is
canceled, since it makes no sense to play through the soundcard while
reading and analysing from a file.
- Dump Recorded Sound.-- Two seconds of the recorded input is dumped,
as a raw file at the speed and bits format selected, to the file
/tmp/record. This could be done to save some particular piece of unusual
analysed result. This must be pressed after the Start button is pressed
with a sample in memory to be saved. It is rarely of much use.
- Save Noise-- And ascii file containing the values plotted in the
noise spectra is printed out to the file in the box (/tmp/noise by
default). This must be pressed before the Start button is pressed for the
saving to take place.
- Save spectrum-- And ascii file of the levels of the recorded signal
at each of the selected frequencies is saved, together with a rough
estimate of the noise in each channel. Again the file used is typed in
by the user, with /tmp/spectrum as the default. This button must be
pressed before the start button to be effective.
- Save Play output-- A raw sound file of the signal which is sent out
to the soundcard is placed in the selected file. This is a raw, stereo
file, with the format selected by the Speed and Bits buttons.Again it
must be selected before the Start button is pressed. (The Play button
must also be selected)
- Output Amplitude-- This changes the amplitude of the signal created
for sending to the soundcard. Usually the signal is the maximum possible
value, so that one of the samples has a value of 2^15 or 2^23 depending
on the bits selected. Sliding these sliders to the left reduces this
maximum value. Note that this is not the same as a volume control as the
digitisation level changes when this slider is used. Eg, if these are
slid to the halfway point, then only 15 bits would be used in the
digitized signal rather than all 16, increasing the digitization noise
in the output.
However these can be used to for example send a signal only out the
left or right channel of the soundcard to look for crosstalk between the
- Speed-- This allows one to choose one of the three speeds-- 44100
Hz( the standard for CDs), 48000Hz (a common soundcard frequency--
Creative labs soundcards tend to support only this speed) and 96000Hz,
the high resolution speed, used on DVD sound.
- Bits-- This allows the choice of how many bits each sample is
encoded in. 16 bits corresponds to two bytes per sample, and is the CD
standard. The two 24 bit options correspond to the two ways of packing
the 24 bits into 32 bits (4 bytes.) The 24L corresponds to packing them
into the lower three bytes with the highest byte being zero. This is the
format that ALSA uses to pack 24 bits into 4 bytes by default (eg, the
S24_LE format). The 24H corresponds to packing the bits into the higher
24 bits of the 32, and corresponds to what sox produces when asked to
convert say 16 bits to 32 bits.
Spectrum-- This plots the energy contained in the selected
discrete frequencies created by the program in the test signal.
Both the right and left channels are plotted. The scale is
adapted to the L or R channel depending on the state of the LR
The left channel is plotted in blue, the right in brown.
Note that if the two are identical, the brown colour will
- Total Power-- The total power in the left and right channel
signals is plotted. In both cases the 0dB level corresponds to
the power in a square wave signal of amplitude of exactly one
bit out of 16. Ie, the maximum power would be for a square wave
signal of maximum amplitude of plus or minus (2^15) would be about 90dB. Because
of the rich mixture in the signal, the maximum amplitude of our
signal is about 76dB.
This same scaling and plotting are used for the 24 bit signal as
well, although there the digitization noise is way off the
bottom of the scale (total of about -58dB below the "one bit"
- LR button--This determines
whether the y axis limits are determined by the left or right channel.
- Noise Left and Right.-- These graphs present the total noise
between each of the designated frequencies. Because the
frequencies which fit the 1 second sample time are all of the
integer frequencies, the number of noise frequencies increase as
one goes higher in frequencies.
The black crosses indicate the expected noise levels in each of
these intervals if there were a constant 1 bit (out of 16)
random noise in
each time interval.
Note that the discretization noise for the 16 bit level is down by about 10dB from
The noise levels at the left represent the total noise
across the whole spectrum referenced to either the total signal,
and to the 1 bit signal level.
- Expand Noise-- If a noise bar in either the left or right
channels is selected by the mouse (and the light blue cursor
lines) pressing this button graphs the noise at each frequency
in that band in a small graph to the left over the control area.
Pressing this button again removes that graph. The graph appears
only if there is at least one noise frequency in the interval,
and if the frequencies lie between 16Hz and 20KHz. The graph is
a bar graph for frequencies below 1KHz and regular graphs over
- Left Minus Right Clicking on the "Noise" button changes the
the graphs to give the amplitude difference in eD between the right
and left channel, and gives the phase difference between the two
channels (in degrees).
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
These files each represent 16 seconds of sound output. Choose the file
which corresponds to your soundcard's abilities or the property you want
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)
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
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.