Home > asr > labRead2.m

labRead2

PURPOSE ^

labRead: Read a *.lab file

SYNOPSIS ^

function output=labRead(labFile)

DESCRIPTION ^

 labRead: Read a *.lab file

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function output=labRead(labFile)
0002 % labRead: Read a *.lab file
0003 
0004 %    Roger Jang, 20051127
0005 
0006 if nargin<1, selfdemo; return; end
0007 
0008 labFile='drum.lab';
0009 contents = textread(labFile,'%s','delimiter','\n','whitespace','');
0010 output=[];
0011 for i=1:length(contents)
0012 %    fprintf('%d/%d\n', i, length(contents));
0013     line=contents{i};
0014     items=split(line, 9);
0015     drumName=items{1};
0016 %    segment=eval(['[ ', items{2}, ' ];']);
0017     timePoint=split(items{2}, 32);
0018     segmentNum=length(timePoint)/2;
0019     temp=[];
0020     for j=1:segmentNum
0021         temp.segment(j).begin=eval(timePoint{2*j-1});
0022         temp.segment(j).end=eval(timePoint{2*j});
0023     end
0024     output=setfield(output, {1}, drumName, {1}, temp);
0025 end
0026 
0027 % ====== Self demo
0028 function selfdemo
0029 labFile='drum.lab';
0030 output=feval(mfilename, labFile);
0031 disp(output);

Generated on Tue 01-Jun-2010 09:50:19 by m2html © 2003