view _segmentation/parts2csv.m @ 9:4ea6619cb3f5 tip

removed log files
author matthiasm
date Fri, 11 Apr 2014 15:55:11 +0100
parents b5b38998ef3b
children
line wrap: on
line source
function parts2csv(song, filename, varargin)
if nargin > 2 && strcmp(varargin{1}, 'integrated')
    parts = song.integratedparts;
else 
    parts = song.parts;
end

beattimes = song.beattimes;
% beattimes = [0; beattimes];
indices = [];
levels = [];
letters = {};

for iPart = 1:length(parts)
    for iInstance = 1:length(parts(iPart).indices)
       indices = [indices parts(iPart).indices(iInstance)];
       levels = [levels parts(iPart).level];
       letters = [letters parts(iPart).letter];
    end
end

[sorted, sortind] = sort(indices);

f = fopen(filename,'w');

for iSeg = 1:length(indices)
    fprintf(f,'%1.2f,%1.3f,"%s"\n',beattimes(sorted(iSeg)),levels(sortind(iSeg)),letters{sortind(iSeg)});
end

fclose(f);