function alignmanage(filename,filepath,mode)

%   alignmanage

%   This software is protected by german copyright and international treaties.             
%   Copyright 2004 Markus Junghöfer & Peter Peyk. All Rights Reserved.                     
%                                                                                          
%   THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE        
%   NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO,    
%   WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE    
%   OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
%   TRADEMARKS OR OTHER RIGHTS. COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT,       
%   INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE      
%   OR DOCUMENTATION. 

filezaehler=0;

if mode==0
   modefehler
   return
   
   
% directory mode   
elseif mode==11
	cd (filepath);
	filelist=dir(filepath);
   filelistsize=size(filelist);
      
	% Schleife für Files
   for filezaehler=3:filelistsize(1)
      filename=filelist(filezaehler).name;
      align(filename,filepath);
   end
   ok
     
% batchfile mode   
elseif mode==12
   return
      
% single file mode   
elseif mode==2
   [audiosignal,audiomodsignal]=align(filename,filepath);
   
   %stereo-sound
   %audio.modsignal=[audio.modsignal audio.modsignal];
   %sound(audio.modsignal,audio.fs);
   
   % Abbildung
   figure
   subplot(2,1,1);
	plot(audiosignal);
	subplot(2,1,2);
   plot(audiomodsignal);
   hold on
   y=linspace(-1,1,1000);
   
   % Segmente grafisch durch Linien teilen
   segmentedit=findobj('tag','segmentedit');
   anzahlsegmente=str2num(get(segmentedit,'string'));
   fftsizevec=size(audiomodsignal);
   segmentgroesse=fftsizevec(1)/anzahlsegmente;
   for t=1:(anzahlsegmente)
      x=t*segmentgroesse*ones(1,1000);
      a=line(x,y);
      set(a,'color',[1 0 0]);
   end
	ok
  
end

ralignfenster=findobj('tag','ralignfenster');
close(figure(ralignfenster));

return