Add --nloops option and fix manpage

- Added --nloops option to specify the number of loops
- Fixed man page of speaker-test
This commit is contained in:
Takashi Iwai 2006-03-06 19:42:23 +00:00
parent 8e6170206d
commit 69c5beb106
2 changed files with 39 additions and 37 deletions

View file

@ -15,28 +15,7 @@
.SH NAME
speaker\-test \- command-line speaker test tone generator for ALSA
.SH SYNOPSIS
.B speaker\-test
.BR "" [ \-D | \-\-device
.IR NAME ]
.BR "" [ \-r | \-\-rate
.IR RATE ]
.BR "" [ \-c | \-\-channels
.IR NUM ]
.BR "" [ \-f | \-\-frequency
.IR FREQ ]
.BR "" [ \-p | \-\-period
.IR TIME ]
.BR "" [ \-n | \-\-noise
.IR TIME ]
.BR "" [ \-s | \-\-speaker
.IR TYPE ]
.BR "" [ \-w | \-\-wavfile
.IR FILE ]
.BR "" [ \-W | \-\-wavdir
.IR DIR ]
.P
.B speaker\-test
.B \-\-help
.B speaker\-test [\-options]
.SH DESCRIPTION
\fBspeaker\-test\fP generates a tone that can be used to test the speakers of a computer.
@ -68,20 +47,33 @@ period size of \fITIME\fP microseconds
stream of \fIRATE\fP Hz
.TP
\fB\-s\fP | \fB\-\-speaker\fP \fBpink\fP|\fBsine\fP|\fBwav\fP
-tpink means use pink noise (default).
\fB\-t\fP | \fB\-\-test\fP \fBpink\fP|\fBsine\fP|\fBwav\fP
\fB\-t pink\fP means use pink noise (default).
Pink noise is perceptually uniform noise - that is, it sounds like every frequency at once. If you can hear any tone it may indicate resonances in your speaker system or room.
Pink noise is perceptually uniform noise -- that is, it sounds like every frequency at once. If you can hear any tone it may indicate resonances in your speaker system or room.
-tsine means use sine wave.
\fB\-t sine\fP means to use sine wave.
-twav means to play WAV files, either pre-defined files or given via -w option.
\fB\-t wav\fP means to play WAV files, either pre-defined files or given via \fB\-w\fP option.
You can pass the number from 1 to 3 as a backward compatibility.
.TP
\fB\-s\fP | \fB\-\-speaker\fP \fBpink\fP|\fBsine\fP|\fBwav\fP
Test speaker 1 or speaker 2 only, rather than both
\fB\-l\fP | \fB\-\-nloops\fP \fBCOUNT\fP
Specifies the number of loops. Zero means to run inifintely.
When \fB\-s\fP option below with a valid channel is given, \fBspeaker\-test\fP will perform
always a single-shot without looping.
.TP
\fB\-s\fP | \fB\-\-speaker\fP \fBCHANNEL\fP
Do a single-shot speaker test for the given channel. The channel number starts from 1.
The channel number orresponds to left, right, rear-left, rear-right, center, LFE,
side-left, side-right, and so on.
For example, when 1 is passed, it tests the left channel only once rather than both channels
with looping.
.TP
\fB\-w\fP | \fB\-\-wavfile\fP
@ -90,6 +82,7 @@ Use the given WAV file for the playback instead of pre-defined WAV files.
.TP
\fB\-W\fP | \fB\-\-wavdir\fP
Specify the directory containing WAV files for playback.
The default path is \fI/usr/share/sounds/alsa\fP.
.SH USAGE EXAMPLES
@ -117,3 +110,4 @@ To send a nice low 75Hz tone to the Woofer and then exit without touching any ot
.SH AUTHOR
The speaker-test program was written by James Courtier-Dutton.
Pink noise support was added by Nathan Hurst.
Further extensions by Takashi Iwai.

View file

@ -706,7 +706,8 @@ static void help(void)
"-b,--buffer ring buffer size in us\n"
"-p,--period period size in us\n"
"-t,--test pink=use pink noise, sine=use sine wave, wav=WAV file\n"
"-s,--speaker single speaker test. Values 1=Left or 2=right\n"
"-n,--nloops specify number of loops to test, 0 = infinite\n"
"-s,--speaker single speaker test. Values 1=Left, 2=right, etc\n"
"-w,--wavfile Use the given WAV file as a test sound\n"
"-W,--wavdir Specify the directory containing WAV files\n"
"\n"));
@ -731,6 +732,7 @@ int main(int argc, char *argv[]) {
uint8_t *frames;
int chn;
double time1,time2,time3;
unsigned int n, nloops;
struct timeval tv1,tv2;
struct option long_option[] = {
@ -743,6 +745,7 @@ int main(int argc, char *argv[]) {
{"buffer", 1, NULL, 'b'},
{"period", 1, NULL, 'p'},
{"test", 1, NULL, 't'},
{"nloops", 1, NULL, 'l'},
{"speaker", 1, NULL, 's'},
{"wavfile", 1, NULL, 'w'},
{"wavdir", 1, NULL, 'W'},
@ -757,13 +760,14 @@ int main(int argc, char *argv[]) {
snd_pcm_hw_params_alloca(&hwparams);
snd_pcm_sw_params_alloca(&swparams);
nloops = 0;
morehelp = 0;
printf("\nspeaker-test %s\n\n", SND_UTIL_VERSION_STR);
while (1) {
int c;
if ((c = getopt_long(argc, argv, "hD:r:c:f:F:b:p:t:s:w:W:", long_option, NULL)) < 0)
if ((c = getopt_long(argc, argv, "hD:r:c:f:F:b:p:t:l:s:w:W:", long_option, NULL)) < 0)
break;
switch (c) {
@ -819,6 +823,9 @@ int main(int argc, char *argv[]) {
exit(1);
}
break;
case 'l':
nloops = atoi(optarg);
break;
case 's':
speaker = atoi(optarg);
speaker = speaker < 1 ? 0 : speaker;
@ -898,14 +905,15 @@ loop:
exit(EXIT_FAILURE);
}
if (speaker==0) {
while (1) {
if (test_type == TEST_WAV) {
for (chn = 0; chn < channels; chn++) {
if (setup_wav_file(chn) < 0)
exit(EXIT_FAILURE);
}
if (test_type == TEST_WAV) {
for (chn = 0; chn < channels; chn++) {
if (setup_wav_file(chn) < 0)
exit(EXIT_FAILURE);
}
}
for (n = 0; ! nloops || n < nloops; n++) {
gettimeofday(&tv1, NULL);
for(chn = 0; chn < channels; chn++) {