function findpeakmanage(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.                                                                      



% monoedit=findobj('tag','monoedit');
% monostring=get(monoedit,'string');
% mono=str2num(monostring);

if mode==0
   modefehler
   return


% directory mode   
elseif mode==11
	cd (filepath);
	filelist=dir(filepath);
    filelistsize=size(filelist);
    [targetfilename,targetfilepath]=uiputfile('*.*','Ergebnisdatei benennen:');
    targetfile=[targetfilepath,targetfilename];
    targetfile
    pause
    fid=fopen(targetfile,'wt');
    fprintf(fid,'File\tpeak\n\n');
	% Schleife für Files
    for filezaehler=3:filelistsize(1)
      [audiosignal,audiofs,audiobits]=wavread(filelist(filezaehler).name);
      audiomonosignal=audiosignal(:,1);
      peaks=findpeaks(audiomonosignal)
      fprintf(fid,[filelist(filezaehler).name,'\t',num2str(peaks),'\n']);
      
      
   end
    fclose(fid);
   ok
   
% batchfile mode   
elseif mode==12
   filemat=batchfiletomat(filename,filepath);
   filematgroessevec=size(filemat);
   filematgroesse=filematgroessevec(2);
   for l=1:filematgroesse
      [audiosignal,audiofs,audiobits]=wavread(filemat{l});
 
   end

      
% single file mode   
elseif mode==2
    file=[filepath filename];
   [audiosignal,audiofs,audiobits]=wavread(file);
   audiomonosignal=audiosignal(:,1);
   peaks=findpeaks(audiomonosignal);
   pause
   ok
  
end

return
