Mercurial > hg > ape
view listeningTest/readTestFile.m @ 15:24be5e9ce25b tip
Update README
author | Brecht De Man <brecht.deman@bcu.ac.uk> |
---|---|
date | Thu, 20 Sep 2018 12:23:20 +0200 |
parents | 4fd284285159 |
children |
line wrap: on
line source
function testDat=readTestFile(testFile) fid=fopen(testFile,'r'); testDat.sndRef=[]; while ~feof(fid) lin=fgetl(fid); [word1,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin,'%s',1); if (~COUNT | ~strcmp(word1,'%')) switch upper(word1) case 'NAME' testDat.name=fgetl(fid); case 'COMBINATIONS:' [nbComb,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin(NEXTINDEX:end),'%d',1); testDat.nbComb=nbComb; %% testDat.posComb=[]; for noComb=1:nbComb lin=fgetl(fid); if ~isempty(lin) if lin(1)~='%' [comb,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin,'%d',2); testDat.comb(noComb,:)=comb; %% % Read the reference DATAS if COUNT==1 lin=lin(NEXTINDEX:end); [stri,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin,'%s',1); if findstr(lower(stri),'ref') testDat.sndRef(end+1)=comb(1); lin=lin(NEXTINDEX:end); [stri,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin,'%s',1); end if findstr(lower(stri),'pos') lin=lin(NEXTINDEX:end); end % read the sounds default position [posComb,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin,'%f',inf); % position must be specified for each scale!! if ~isempty(posComb) testDat.posComb(noComb,:)=posComb'; end end end end end % tricky here! try to satisfy both comp1d and 2d % requirements of default position of icons % may be should decompose each case... posComb=testDat.posComb; [nbComb1,nbPos]=size(posComb); if isempty(nbComb1) nbComb1=1; end if exist('nbScale') nbPos=nbScale; end if nbComb1<nbComb testDat.posComb(nbComb,nbPos)=0; end indx=find(testDat.posComb==0); testDat.posComb(indx)=nan; % mark the combinations with unknown position case 'NBSCALES:' [nbScale,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin(NEXTINDEX:end),'%d',1); testDat.nbScale=nbScale; % check posRef length nbRef=length(testDat.sndRef); for noRef=1:nbRef if length(testDat.posComb(:,testDat.sndRef(noRef)))~=nbScale fprintf(1,'Watch out, the position of reference %d are not specified for all scale',noRef); end end for noScale=1:nbScale while ~feof(fid) lin=fgetl(fid); [header,COUNT,ERRMSG,NEXTINDEX] = sscanf(lin,'%s',1); switch firstWord(header) case 'SCALE:' lin=lin(NEXTINDEX:end); name=lin; %% case 'min' lin=lin(NEXTINDEX:end); [minn,COUNT,ERRMSG,NEXTINDEX]=sscanf(lin,'%d',1); %% level{1}=lin(NEXTINDEX:end); %% case 'max' lin=lin(NEXTINDEX:end); [maxx,COUNT,ERRMSG,NEXTINDEX]=sscanf(lin,'%d',1); %% level{3}=lin(NEXTINDEX:end); %% case 'step' lin=lin(NEXTINDEX:end); [stepp,COUNT,ERRMSG,NEXTINDEX]=sscanf(lin,'%d',1); %% level{2}=lin(NEXTINDEX:end); %% break end end testDat.scale(noScale).name=name; testDat.scale(noScale).maxx=maxx; testDat.scale(noScale).minn=minn; testDat.scale(noScale).stepp=stepp; testDat.scale(noScale).level=level; end end end end fclose(fid); function word=firstWord(word) if ~isempty(word) if word(1)=='%' word=[]; end else word=[]; end