christopherh@1: christopherh@1: % merge contiguous repeated chord labels in a labfile christopherh@1: christopherh@1: function [t1,t2,s] = merge_repeats(labfile, outputlabfile) christopherh@1: christopherh@1: writefile = 1; christopherh@1: christopherh@1: if nargin<2 christopherh@1: % if no output labfile name is given then don't write output to a file christopherh@1: writefile=0; christopherh@1: end christopherh@1: christopherh@1: t1 = []; christopherh@1: t2 = []; christopherh@1: s = {}; christopherh@1: christopherh@1: [in_t1,in_t2,in_s] = labread(labfile); christopherh@1: christopherh@1: current = in_s{1}; christopherh@1: temp1 = in_t1(1); christopherh@1: christopherh@1: for i=1:length(in_s)-1 christopherh@1: christopherh@1: next = in_s{i+1}; christopherh@1: christopherh@1: % if current is the same as next christopherh@1: if ~strcmp(current,next) christopherh@1: t1 = [t1; temp1]; christopherh@1: t2 = [t2; in_t2(i)]; christopherh@1: s = [s; {current}]; christopherh@1: current = next; christopherh@1: temp1 = in_t1(i+1); christopherh@1: end christopherh@1: christopherh@1: if i==length(in_s)-1 christopherh@1: t1 = [t1; temp1]; christopherh@1: t2 = [t2; in_t2(i+1)]; christopherh@1: s = [s; {current}]; christopherh@1: end christopherh@1: christopherh@1: end christopherh@1: christopherh@1: if writefile christopherh@1: christopherh@1: labwrite(t1,t2,s,outputlabfile); christopherh@1: end