

//=====================================================
void autil(mwArray filenamemwArray filepath)
{

mwArray rauschslider;
rauschslider=findobj("tag","rauschslider");

mwArray rauschverhaeltnisroot;
rauschverhaeltnisroot=get(rauschslider,"value");
rauschverhaeltnis=mtimes(rauschverhaeltnisroot,1);
if (isempty(rauschverhaeltnis).ExtractScalar(1)) {
   rauschverhaeltnis=0;
}

 mwArray mode;
if (mode.ExtractScalar(1)==0) {
   modefehler
   return
;
      
// directory mode   
}
 else if ( mode.ExtractScalar(1)==11) {
	cd (filepath);

	mwArray filelist;
	filelist=dir(filepath);

   mwArray filelistsize;
   filelistsize=size(filelist);
      
	// Schleife für Files

    mwArray filezaehler;
   for (int filezaehler=3;filezaehler.ExtractScalar(1)<=filelistsize.ExtractScalar(1)(1;filezaehler++);filezaehler++) {

      mwArray audio.signal;

      mwArray audio.fs;

      mwArray audio.bits;

      mwArray .name;
      mwArray nouse1;
      audio.signal =wavread(&audio.fs,&audio.bits,&nouse1, filelist(filezaehler,empty());

        mwArray audio.modsignal;

        mwArray audio.spektrum;

        mwArray audio.modspektrum;

        mwArray audio.realspektrum;

        mwArray audio.modrealspektrum;

        mwArray audio.imagspektrum;

        mwArray audio.modimagspektrum;

        mwArray audio.mag;

        mwArray audio.modmag;

        mwArray audio.phasen;

        mwArray audio.modphasen;

        mwArray phasenrandvec;
      [audio.modsignal,audio.spektrum,audio.modspektrum,audio.realspektrum,audio.modrealspektrum,audio.imagspektrum,audio.modimagspektrum,audio.mag,audio.modmag,audio.phasen,audio.modphasen,phasenrandvec] = randphase(audio.signal,audio.fs,audio.bits,rauschverhaeltnis);
		audio.modsignal=horzcat(audio.modsignal,audio.modsignal);
		// modifiziertes Signal abspeichern

		 mwArray targetfilename;
		targetfilename=strrep(filelist(filezaehler).name, ".wav","mod.wav");
		wavwrite(audio.modsignal,audio.fs,audio.bits,targetfilename);
   }
   ok
   
// batchfile mode   
}
 else if ( mode.ExtractScalar(1)==12) {

   mwArray filemat;
   filemat=batchfiletomat(filename,filepath);

   mwArray filematgroessevec;
   filematgroessevec=size(filemat);

   mwArray filematgroesse;
   filematgroesse=filematgroessevec(2);

    mwArray l;
   for (int l=1;l.ExtractScalar(1)<=filematgroesse.ExtractScalar(1);l++) {

      mwArray filemat{l};
      mwArray nouse1;
      audio.signal =wavread(&audio.fs,&audio.bits,&nouse1, filemat{l},empty());
      [audio.modsignal,audio.spektrum,audio.modspektrum,audio.realspektrum,audio.modrealspektrum,audio.imagspektrum,audio.modimagspektrum,audio.mag,audio.modmag,audio.phasen,audio.modphasen,phasenrandvec] = randphase(audio.signal,audio.fs,audio.bits,rauschverhaeltnis);
      audio.modsignal=horzcat(audio.modsignal,audio.modsignal);
     	targetfilename=strrep(filemat{l},".wav","mod.wav");
		wavwrite(audio.modsignal,audio.fs,audio.bits,targetfilename);
   }
   return
;
      
// single file mode   
}
 else if ( mode.ExtractScalar(1)==2) {
   mwArray nouse1;
   audio.signal =wavread(&audio.fs,&audio.bits,&nouse1, filename,empty());
   audio.modsignal =randphase(&audio.spektrum,&audio.modspektrum,&audio.realspektrum,&audio.modrealspektrum,&audio.imagspektrum,&audio.modimagspektrum,&audio.mag,&audio.modmag,&audio.phasen,&audio.modphasen,&phasenrandvec, audio.signal, audio.fs, audio.bits, rauschverhaeltnis);
   

//stereo-sound
      audio.modsignal=horzcat(audio.modsignal,audio.modsignal);
   sound(audio.modsignal,audio.fs);
   
   figure(5)
   subplot(2,1,1)
   plot(audio.mag)
   subplot(2,1,2)
   plot(audio.modmag)
   
	// modifiziertes Signal abspeichern
	targetfilename=strrep(filename, ".wav","mod.wav");
	wavwrite(audio.modsignal,audio.fs,audio.bits,targetfilename);
	ok
  
}
autilfenster=findobj("tag","autilfenster");
close(figure(autilfenster));
return
;
}
