diff simulateBinauralSignals.m @ 14:fcb75c4045c2 jabuilder_int

Various fixes to handling of specified output dir
author Chris Cannam
date Fri, 28 Feb 2014 15:10:36 +0000
parents f0e00c212071
children ffc4d61e9538
line wrap: on
line diff
--- a/simulateBinauralSignals.m	Fri Feb 28 14:10:17 2014 +0000
+++ b/simulateBinauralSignals.m	Fri Feb 28 15:10:36 2014 +0000
@@ -24,7 +24,7 @@
 % coordinates are as in matlabs sph2cart function (azimuth and elevation are angular displacements from the positive
 % x-axis and from the x-y plane, respectively) with positive x axis taken to be extending to the right of the head from
 % top view, positive y axis to be extending forward of the head in top view and positive z axis to be extending upwards
-% in top view.
+% in top view.http://getpermanent.com/index
 % 
 % Board dimensions are defined as
 % params.board_size_x (width in meters for the 'center' orientation of  Papadopoulos et al. BSPC 2011)
@@ -219,7 +219,7 @@
                 board_coords(:,:,ii,jj,kk) = geom.scatterer_edges;
             end
             
-            FFresp(ii,jj,kk) = edhrir_single_cuboid(geom);
+            FFresp(ii,jj,kk) = edhrir_single_cuboid(outdir, geom);
             
         end
     end 
@@ -329,7 +329,7 @@
     out=conv(in1,in2);
 end
 
-function ir_matrix=edhrir_single_cuboid(geom)
+function ir_matrix=edhrir_single_cuboid(outdir, geom)
 %
 % Matrix of irs for a single cuboid scatterer using EDTB
 %
@@ -398,12 +398,12 @@
 fprintf(fid,['\n FSAMP = ' num2str(geom.Fs) ';']);
 fprintf(fid,['\n CAIR = ' num2str(geom.Cair) ';']);
 fprintf(fid,['\n RHOAIR = ' num2str(geom.Rhoair) ';']);
-fprintf(fid,'\n SHOWTEXT = 0;');
+fprintf(fid,'\n SHOWTEXT = 2;');
 fprintf(fid,'\n SUPPRESSFILES = 0;');
 temp = strrep(outdir,'\','\\');
-fprintf(fid,['\n Filepath=''''''' temp ''''''';']);
+fprintf(fid,['\n Filepath=''' outdir filesep ''';']);
 fprintf(fid,['\n Filestem=''' temp_filename ''';']);
-fprintf(fid,['\n CADfile=''' cad_filename ''';']);
+fprintf(fid,['\n CADfile=''' outdir filesep cad_filename ''';']);
 fprintf(fid,'\n open_or_closed_model = ''open'';');
 fprintf(fid,'\n int_or_ext_model = ''ext'';');
 fprintf(fid,'\n EDcalcmethod = ''n'';');
@@ -433,12 +433,12 @@
 
 pause(1);
 
-[~, ir_matrix]=myver_edtb(setup_filename);
+[~, ir_matrix]=myver_edtb(outdir, [outdir filesep setup_filename]);
 
 delete([outdir filesep cad_filename]);
 delete([outdir filesep setup_filename]);
 
-function [ir,varargout]=myver_edtb(EDsetupfile)
+function [ir,varargout]=myver_edtb(outdir,EDsetupfile)
 % implements the computation of EDToolbox (by Peter Svensson) with a front-end
 % designed for my needs.
 % 
@@ -456,16 +456,16 @@
 % [ir ir_all_data]=myver_edtb(EDsetupfile);
 
 %keep record of files in the current directory before computation
-dir_bef=dir;
+dir_bef=dir(outdir);
 ir=1;
 
-disp(['Will call' EDsetupfile])
+disp(['Will call ' EDsetupfile])
 
 %run computation
 EDB1main(EDsetupfile);
 
 %get files list in the current directory after computation
-dir_aft=dir;
+dir_aft=dir(outdir);
 
 %get all genuine files (excluding other directories) in current directory
 %after computation
@@ -485,6 +485,9 @@
     end
 end
 
+disp(['Names before ' names_bef]);
+disp(['Names after ' names_aft]);
+
 %get irtot for 1st source 1st receiver and delete files created by
 %computation.
 % for n=1:length(names_aft)
@@ -498,15 +501,16 @@
 %     end
 % end
 for n=1:length(names_aft)
+        disp(['name is ' names_aft(n)]);
     if ~strcmp(names_aft(n),names_bef)
         if ~isempty(strfind(names_aft{n},'_1_1_ir.mat'))
-            temp=load(names_aft{n});
+            temp=load([outdir filesep names_aft{n}]);
             ir=full(temp.irtot);
             clear temp
         end
         if nargout>1
             if ~isempty(strfind(names_aft{n},'_ir.mat'))
-                temp=load(names_aft{n});
+                temp=load([outdir filesep names_aft{n}]);
                 temp2=regexp(regexp(names_aft{n},'_\d*_\d*_','match'),'\d*','match');
                 temp3{str2double(temp2{1}(1)),str2double(temp2{1}(2))}(4,:)=full(temp.irtot); %#ok<AGROW>
                 temp3{str2double(temp2{1}(1)),str2double(temp2{1}(2))}(1,:)=full(temp.irdiff); %#ok<AGROW>
@@ -515,7 +519,7 @@
                 clear temp temp2
             end
         end
-        delete(names_aft{n})
+        delete([outdir filesep names_aft{n}])
     end
 end
 if nargout>1