function varargout=spec_smooth(varargin)

%%% Spectra smoothing procedure

for i=1:nargin-1
    spec(i,:)=varargin{i};
end;

Freq=varargin{nargin-1};
C=varargin{nargin};
n=length(spec(1,:));

jx=1;
dx=1;
ix=1;
inx=1;
while jx < n,
   	dx=(dx*exp(C));
   	
   	ac=zeros(nargin-1,1); 
    af=0;
   	k=0;
   	for jx=ix:ix+floor(dx)-1;
        if jx==n
            break
        end;
        for i=1:nargin-1
            ac(i) = ac(i)+spec(i,jx);
        end;
        af=af+Freq(jx);
      	k=k+1;
   	end;    
    for i=1:nargin-1
   	  spec1(:,inx) = ac./k;
    end;
    dfs(inx)=Freq(jx)-Freq(ix)+Freq(2);
 
   	ix=jx+1;
   	inx=inx+1; 
end;

for i=1:nargin-1
  varargout{i}=spec1(i,:);
end;
varargout{i+1}=dfs;


