-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_tracks.m
47 lines (45 loc) · 1.21 KB
/
add_tracks.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
function [N,T] = add_tracks(D,SR,ID)
% [N,T] = add_tracks(D,SR,ID)
% Add one or more tracks to the hashtable database.
% <D, SR> define the waveform of the track, and ID is its
% reference ID.
% If D is a char array, load that wavefile. Second arg is ID.
% If D is a cell array, load each of those wavefiles; second arg
% is vector of IDs.
% N returns the total number of hashes added, T returns total
% duration in secs of tracks added.
% 2008-12-29 Dan Ellis dpwe@ee.columbia.edu
if isnumeric(D)
H = landmark2hash(find_landmarks(D,SR),ID);
save_hashes(H);
N = length(H);
T = length(D)/SR;
elseif ischar(D)
if nargin < 3
ID = SR;
end
[D,SR] = mp3read(D);
[N,T] = add_tracks(D,SR,ID);
elseif iscell(D)
nd = length(D);
if nargin < 3
if nargin < 2
% omitting IDs defaults to track number
ID = 1:nd;
else
ID = SR;
end
end
N = 0;
T = 0;
for i = 1:nd
disp(['Adding #',num2str(ID(i)),' ',D{i},' ...']);
[n,t] = add_tracks(D{i},ID(i));
N = N + n;
T = T + t;
end
disp(['added ',num2str(nd),' tracks (',num2str(T),' secs, ', ...
num2str(N),' hashes, ',num2str(N/T),' hashes/sec)']);
else
error('I cant tell what D is');
end