function y=stripnoise(y,clip)
%STRIPNOISE: Remove noise from start and end of sampled sound.
%
%	STRIPNOISE(y) removes any data from start and end of y that
%	contains values close to 0, namely within 5% of the largest
%	y value.
%
%	STRIPNOISE(y,0.01) does the same but removes 1% noise.

% Author:
%   Alexander Russell Perlis
%   SouthWest Regional Institute in the Mathematical Sciences
%   c/o Department of Mathematics
%   The University of Arizona
%   Tucson, AZ 85721
%   (520) 621-2137
%   aprl@math.arizona.edu
%
% Obtain the latest version of this software from:
%   http://www.math.arizona.edu/~rims/workshops/fourier/softwareMATLAB
%
% Bugs/problems/ideas:
%   None.
%
% Change history:
%   May 1997  Original version


if nargin<2
  clip=0.05;
end
clip=clip*max(abs(y));
k=min(find(abs(y)>clip));
if k>1,
  y(1:k-1) = [];
end
k=max(find(abs(y)>clip));
s=size(y(:),1);
if k<s,
  y(k+1:s) = [];
end

% [eof]
