changeset 12:c8b0cf96ea44 jabuilder_int

Supply dirname and filename separately (use dirname for temp files too)
author Chris Cannam
date Fri, 28 Feb 2014 13:41:31 +0000
parents 894f57cf9962
children f0e00c212071
files simulateBinauralSignals.m
diffstat 1 files changed, 14 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/simulateBinauralSignals.m	Fri Feb 28 11:26:12 2014 +0000
+++ b/simulateBinauralSignals.m	Fri Feb 28 13:41:31 2014 +0000
@@ -12,9 +12,10 @@
 % emission path to the echo path (i.e. due to directivity focus in the frontal direction of the source, the emission
 % which is directed upwards and backwards in our specific geometry is significantly attenuated, typically by factor in
 % the vicinity of 0.2)
-% .outfile (5th input argument) must be the filename in which the wave file
+% .outdir (5th input argument) must be the directory in which the wave file
 % is to be written. It may be an absolute path, or relative to the current
-% directory.
+% directory. Temporary files will be written in the same directory.
+% .outname (6th input argument) must be the name of the wave file to write, within the outdir, without the .wav suffix (which will be added).
 % 
 
 %% Internal workings description
@@ -110,14 +111,16 @@
 azim = inputstruct.azim;
 orient = inputstruct.orient;
 dirweight = inputstruct.dirweight;
-outfile = inputstruct.outfile;
+outdir = inputstruct.outdir;
+outname = inputstruct.outname;
 
 %% Validate attributes
 validateattributes(dist,{'double'},{'scalar','>',0})
 validateattributes(azim,{'double'},{'scalar','<=',90,'>=',-90})
 validateattributes(orient,{'char'},{'nonempty'})
 validateattributes(dirweight,{'double'},{'scalar','>',0})
-validateattributes(outfile,{'char'},{'nonempty'})
+validateattributes(outdir,{'char'},{'nonempty'})
+validateattributes(outname,{'char'},{'nonempty'})
 
 %% Computation parameters (Some fixed, some taken from input arguments)
 params.board_size_x = .55;
@@ -151,7 +154,7 @@
 params.dirweight = dirweight;
 
 params.horz_disamb = 'BSPC2011';
-params.wavfilename = outfile;
+params.wavfilename = [outdir filesep outname '.wav']
 
 %% Compute free field (no head) IRs
 
@@ -362,9 +365,10 @@
 %
 
 %% 1
-temp_filename=['a' num2str(now*1e12,'%-24.0f')];
+temp_filename=[outdir filesep 'a' num2str(now*1e12,'%-24.0f')];
+cad_filename=[temp_filename '.cad']
 
-fid=fopen([temp_filename '.cad'],'w');
+fid=fopen(cad_filename,'w');
 % TODO add onCleanup to fclose this file
 fprintf(fid,'%%CORNERS\n\n');
 fprintf(fid,'%.0f %9.6f %9.6f %9.6f\n',...
@@ -386,7 +390,7 @@
 fprintf(fid,'\n%%EOF');
 fclose(fid);
 
-setup_filename = [cd filesep temp_filename '_setup.m']
+setup_filename = [temp_filename '_setup.m']
 
 fid=fopen(setup_filename,'wt');
 % TODO add onCleanup to fclose this file
@@ -431,8 +435,8 @@
 
 [~, ir_matrix]=myver_edtb(setup_filename);
 
-delete([temp_filename '.cad']);
-delete([temp_filename '_setup.m']);
+delete([cad_filename]);
+delete([setup_filename]);
 
 function [ir,varargout]=myver_edtb(EDsetupfile)
 % implements the computation of EDToolbox (by Peter Svensson) with a front-end