.TH GLITCH 1carl CARL
.SH NAME
glitch - one sample error detection
.SH SYNOPSIS
\fBglitch\fR [-Nnumber] < floatsams > error_histogram
.SH DESCRIPTION
\fBglitch\fR
reads floatsams (32-bit binary floating point samples) on its
standard input and when the input is exhausted,
prints a histogram of the N likeliest samples
to produce a click in playback. (The default is N=22).
.PP
\fBglitch\fR
works by taking the slope of two samples to predict by linear
extrapolation where the next
one ought to lie.  Since musical signals are
generally not linear, the estimate will have some error.  The magnitude of
this error is compared to previous errors, and the 22
largest errors and their sample indicies are saved and reported.  The errors
are reported in decreasing order of magnitude except that some effort is
made to group together errors with adjacent indicies.
.PP
Some insight into the glitch detection algorithm can be gained by considering
several idealized kinds of clicks and noting that the algorithm is simply
looking for large differences in slope.  
.PP
The first case to consider is that
of a sudden change in slope such as might result from butting two signals
together in such a way that the instantaneous levels are matched, but not
the slopes; this would show up as a single large error value with the index
being the sample number at which the change in slope occurred.  
.PP
A second
case which also  might result from butting two signals together is a
sudden change in actual value from one sample to the next; this would
show up as two adjacent error values, one positive and the other negative.
.PP
A third case is that of a single erroneous sample value amidst a stream of
correct values; this would produce three large error values in succession,
with one positive and the other two negative or vise versa.
.PP
In practice, some care is necessary in order that the algorithm produce
useful results.  First, the user should be sure that the signal under
examination is monaural - a stereo file will hopelessly confuse things!
Second, the user should narrow down the region to be examined as much
as possible (e.g., by using interactive play). This is particularly true
when trying to detect more than one glitch in a single soundfile; small
glitches will almost always be hidden by larger ones if the algorithm
is applied to the entire file at once.
.PP
It is important to remember that it is the
.I error
signal that is being reported, not sample amplitudes.
The error signal is the difference between the expected and observed samples.
.PP
\fBglitch\fR
also prints the simple average of the error signal measured
for each sample.  Comparing the maximum error to the average helps
estimate what is reasonable, and what is out of line.
.SH BUGS
.SH AUTHOR
Gareth Loy and Mark Dolson.
