.TH OLDSPECT 1carl CARL
.SH NAME
oldspect - apply FFT to floatsam stream
.SH SYNOPSIS
.B oldspect 
[
.B flags
] < floatsams > output
.sp
.nf
flags:	(defaults in parenthesis)
	-p	output power spectrum as floatsams
	-m	output magnitude (amplitude) spectrum as floatsams
	-d	output power spectrum in dB as floatsams
	-m	output phase (range: [-pi,+pi]) spectrum as floatsams
	-c	output complex spectrum as floatsams
	-a	output average power spectrum (over -n iterations) in dB 
		(if none of above, a crude CRT plot of the spectrum is written)
	-RN	set sample rate to N (default is read from stdin)
	-bN	begin at time N (0)
	-wN	window duration for FFT set to N seconds (1024S) 
	-nN	number of iterations: FFT N successive windows of input data (1)
	-sN	skip window by N seconds between successive FFT's (-w / 2)
	-lM	use M pole linear prediction estimate of input (autocorrelate)
	-kM	use M pole linear prediction estimate of input (covariance)
	-r	rectangular window: suppresses default hamming window
	-u	un-normalize: suppresses default normalization of FFT to 0 dB
	-f	filter evaluation: input is filter impulse response
.br
or
.br
.fi
.B oldspect 
[-p, -c] 
.B sample_offset 
.B window_size 
.B N_windows 
< floatsams > output
.br
where
.B sample_offset 
corresponds to -s,
.B window_size 
corresponds to -w, and
.B N_windows 
corresponds to -r.
.SH DESCRIPTION
(THIS PROGRAM HAS BEEN SUPERCEDED BY THE SPECT PROGRAM, WHICH SHOULD BE
USED FOR NEW APPLICATIONS.  WHEN THE REMAINDER OF THIS MAN PAGE REFERS
TO ``SPECT'', THE READER SHOULD READ ``OLDSPECT'').
.br
.I spect 
reads floatsams (32-bit binary floating point samples) on its
standard input and 
takes (possibly) successive FFTs of the signal.
.PP
There are two modes of usage, with flags, or with fixed arguments.
If you use fixed arguments, all three arguments must be supplied in
the order specified in the second usage description given above.
On the other hand, flags may be given in any order, and any omitted
will be given default values as shown.  One possible source of 
confusion is that the fixed arguments refer to durations in terms
of number of samples while the flags refer to duration in terms
of number of seconds (unless the postop "S" is used).  This
discrepancy exists for historical reasons; the flags are very
strongly preferred.
.PP
There are two distinct formats that
.I spect
produces.
By default,
the output is a crude crt graphics plot of the power spectrum
plotted from 0 to the Nyquist rate (i.e., half the sample rate). 
If the
-p
flag is given,
the power spectrum only is output as a floatsam stream.
If the
-c
flag is given,
the complex spectrum is written as floatsam pairs,
real, then imaginary in sample interleaved form.
If the
-d
flag is given,
the power spectrum only is output as a floatsam stream, but in decibels.
This form is highly suited for piping to the standard UNIX graphics
filters.  For example: 
.IP
sndin file | spect -d [flags]
| btoa -s | graph -y -100 0 |
v550
.PP
If the 
-a
flag is given,
the power spectrum only is output as a floatsam stream in decibels, but
only after all n iterations have been completed and the n indiviual 
spectra are all averaged together.  This is extremely helpful when looking
at noisy inputs.  If the skip is set to half the window size (the default),
then the classical periodogram method for power spectrum estimation results.
(See the helpfile for \fIpmpse\fR.)
.PP
If the
-l
or 
-k
flag is specified, then
.I spect
displays the spectrum of the linear prediction estimate of the input
instead of the true spectrum.  The linear prediction spectrum tends
to be more like a plot of the spectral envelope than the actual spectrum.
This means that individual harmonics do not show up in the display; only
broad resonances are visible.  There are two different methods of linear
prediction which may be specified: the
-l
flag calls for the autocorrelation method, and the
-k
flag calls for the covariance method.  For very short windows, the
covariance method is preferred, but for windows greater than 256 samples
the results are nearly identical for each.  Both the
-l
and 
-k
flags must be followed by a number which specifies the number of
filter coefficients to be used in the linear prediction model.  A value
of 16 is suggested for speech. (See the helpfile for \fIlpc\fR.)
.PP
The remaining flags are intended to be fairly obvious.  The most critical
is -w because the FFT size ( and spectral resolution ) will be directly
proportional to the duration of the window.  On the one hand, the window
should not be so long that the signal changes its character within the
duration of the window.  On the other hand, the window must be long
enough to provide adequate frequency resolution.  For example, if the
sample rate is 16KHz and the input signal has a pitch of 64Hz, then -w
will probably have to be at least 2048S (this gives a frequency
resolution of 16KHz / 2K = 8Hz) in order to clearly see the peaks
of each separate harmonic.  The default window is a
hamming window ( w(i) = .54 + .46 * cos(2 * pi * i / (n/2-1)) where i
ranges between plus and minus n/2 - 1).  The -r flag can be specified
to force the use of a rectangular window.  
.PP
The output spectrum is normalized so that the peak value is at 0dB.
This automatic normalization can be suppressed with -u (un-normalize)
flag.  In this case a sine wave of amplitude 1. will appear as a
spectral peak of -6dB (as it should!).  The -f flag is a combination
of -r , -u , and an additional gain factor so that the spectrum of
a filter impulse response can be accurately calculated.
.SH AUTHOR
F. R. Moore & Mark Dolson
.SH DIAGNOSTICS
If the window size would exceed 32K samples, the diagnostic
"You gotta be kidding!" is printed on your screen and the program
exits.
