function cutwavto6smanage(filename,filepath,mode)
%   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.                                                                      


if mode==0
   modefehler
   return
faktor=1;

% directory mode   
elseif mode==11
	cd (filepath);
	filelist=dir(filepath);
   filelistsize=size(filelist);
      
	% Schleife für Files
   for filezaehler=3:filelistsize(1)
      [audio.signal,audio.fs,audio.bits]=wavread(filelist(filezaehler).name);
      audio.modsignal=cutwavto6s(audio.signal);
      targetfilename=strrep(filelist(filezaehler).name, '.wav','6s.wav');
      wavwrite(audio.modsignal,audio.fs,audio.bits,targetfilename);
   end
   ok
   
% batchfile mode   
elseif mode==12
   filemat=batchfiletomat(filename,filepath);
   filematgroessevec=size(filemat);
   filematgroesse=filematgroessevec(2);
   for l=1:filematgroesse
       
      [audio.signal,audio.fs,audio.bits]=wavread(filemat{l});
      audio.modsignal = audio.signal;
     if mono==0
            audio.modsignal (:,2)=0;
            targetfilename=strrep(filelist(filezaehler).name, '.wav','ml.wav');
        elseif mono==1
            audio.modsignal (:,1)=0;
            targetfilename=strrep(filelist(filezaehler).name, '.wav','mr.wav');
        elseif mono==2
            typ=size(audio.signal); 
            if typ(2)==1
                audio.modsignal=[audio.modsignal audio.modsignal];
                targetfilename=strrep(filelist(filezaehler).name, '.wav','st.wav');
            end
        end
        % modifiziertes Signal abspeichern
        wavwrite(audio.modsignal,audio.fs,audio.bits,targetfilename);
   end
   return
      
% single file mode   
elseif mode==2
   [audiosignal,audiofs,audiobits]=wavread(filename);
    if mono==0
            audio.modsignal (:,2)=0;
            targetfilename=strrep(filelist(filezaehler).name, '.wav','ml.wav');
        elseif mono==1
            audio.modsignal (:,1)=0;
            targetfilename=strrep(filelist(filezaehler).name, '.wav','mr.wav');
        elseif mono==2
            typ=size(audio.signal); 
            if typ(2)==1
                audio.modsignal=[audio.modsignal audio.modsignal];
                targetfilename=strrep(filelist(filezaehler).name, '.wav','st.wav');
            end
        end
        % modifiziertes Signal abspeichern
        wavwrite(audio.modsignal,audio.fs,audio.bits,targetfilename);
	ok
  
end
balancefenster=findobj('tag','balancefenster');
close(figure(balancefenster));
return