matthiasm@8: function bc = synchronisechroma(chromag, beats, frame_t) matthiasm@8: matthiasm@8: % assigning beats to frames matthiasm@8: nBeat = size(beats,1); matthiasm@8: nFrame = size(chromag, 2); matthiasm@8: matthiasm@8: bc = ones(nBeat,size(chromag,1)); matthiasm@8: chromag(:,isnan(sum(chromag))) = 1; matthiasm@8: matthiasm@8: if size(beats,2) < 2 matthiasm@8: for iBeat = 1:nBeat-1 matthiasm@8: currind = find(frame_t >= beats(iBeat) & frame_t < beats(iBeat+1)); matthiasm@8: bc(iBeat,:) = median(chromag(:,currind),2); matthiasm@8: if ~any(isnan(bc(iBeat,:))) matthiasm@8: bc(iBeat,:) = bc(iBeat,:)/max(bc(iBeat,:)); matthiasm@8: end matthiasm@8: end matthiasm@8: else matthiasm@8: for iBeat = 1:nBeat matthiasm@8: currind = (frame_t >= beats(iBeat,1) & frame_t < beats(iBeat,2)); matthiasm@8: bc(iBeat,:) = median(chromag(:,currind),2); matthiasm@8: if ~any(isnan(bc(iBeat,:))) matthiasm@8: bc(iBeat,:) = bc(iBeat,:)/max(bc(iBeat,:)); matthiasm@8: end matthiasm@8: end matthiasm@8: end