matthiasm@8: function bc = beatchroma(chromag, beats, frame_t) matthiasm@8: matthiasm@8: % assigning beats to frames matthiasm@8: nBeat = length(beats); matthiasm@8: nFrame = size(chromag, 2); matthiasm@8: beatassign = zeros(1,nFrame); matthiasm@8: iBeat = 1; matthiasm@8: matthiasm@8: for iFrame = 1:nFrame matthiasm@8: if frame_t(iFrame) > beats(iBeat) && frame_t(iFrame) < beats(end) matthiasm@8: iBeat = iBeat + 1; matthiasm@8: end matthiasm@8: beatassign(iFrame) = iBeat; matthiasm@8: end matthiasm@8: % averaging over frames belonging to one beat matthiasm@8: fprintf(1,'__ preprocessing chromagram... ___________________________________________\n'); matthiasm@8: bc = zeros(nBeat,12); matthiasm@8: chromag(:,isnan(sum(chromag))) = 1; matthiasm@8: matthiasm@8: for iBeat = 1:nBeat matthiasm@8: bc(iBeat,:) = median(chromag(:,beatassign == iBeat),2); matthiasm@8: if ~any(isnan(bc(iBeat,:))) matthiasm@8: bc(iBeat,:) = bc(iBeat,:)/max(bc(iBeat,:)); matthiasm@8: end matthiasm@8: end