To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Revision:

root / _segmentation / parts2csv.m

History | View | Annotate | Download (724 Bytes)

1
function parts2csv(song, filename, varargin)
2
if nargin > 2 && strcmp(varargin{1}, 'integrated')
3
    parts = song.integratedparts;
4
else 
5
    parts = song.parts;
6
end
7

    
8
beattimes = song.beattimes;
9
% beattimes = [0; beattimes];
10
indices = [];
11
levels = [];
12
letters = {};
13

    
14
for iPart = 1:length(parts)
15
    for iInstance = 1:length(parts(iPart).indices)
16
       indices = [indices parts(iPart).indices(iInstance)];
17
       levels = [levels parts(iPart).level];
18
       letters = [letters parts(iPart).letter];
19
    end
20
end
21

    
22
[sorted, sortind] = sort(indices);
23

    
24
f = fopen(filename,'w');
25

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

    
30
fclose(f);
31