-
Notifications
You must be signed in to change notification settings - Fork 0
/
computeQSpecBatch.m
executable file
·59 lines (51 loc) · 1.67 KB
/
computeQSpecBatch.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
47
48
49
50
51
52
53
54
55
56
57
58
function computeQSpecBatch(filelist,featDir,param)
% computeQSpecBatch(filelist,featDir,param)
%
% Computes constant Q transform on the specified list of files and
% saves the results to an output directory.
%
% filelist is a text file containing a list of wav files, one per line.
% The files should have unique basenames.
% featDir specifies where to save the CQT data
% param specifies parameters for computing CQT
% param.targetsr is the desired sample rate before CQT computation
% param.B is the number of bins per octave
% param.fmin is the lowest frequency to be analyzed (Hz)
% param.fmax is the highest frequency to be analyzed (Hz)
% param.gamma specifies factor in filter bandwidth (0 => CQT)
%
% 2016-07-08 TJ Tsai ttsai@g.hmc.edu
if nargin < 3
param = []; % will use default settings
end
fid = fopen(filelist);
curFileList = '';
fileIndex = 1;
curfile = fgetl(fid);
while ischar(curfile)
curFileList{fileIndex} = curfile;
% [pathstr,name,ext] = fileparts(curfile);
% disp(['Computing CQT on ',name]);
% savefile = strcat(featDir,'/',name,'.mat');
% if exist(savefile,'file') ~= 2
% Q = computeQSpec(curfile,param);
% save(savefile,'Q');
% end
curfile = fgetl(fid);
fileIndex = fileIndex + 1;
end
parfor index = 1:length(curFileList)
curfile = curFileList{index};
[pathstr,name,ext] = fileparts(curfile);
disp(['Computing CQT on ',name]);
savefile = strcat(featDir,'/',name,'.mat');
if exist(savefile,'file') ~= 2
Q = computeQSpec(curfile,param);
parSave(savefile, Q);
end
end
fclose(fid);
end
function parSave(fname, Q)
save(fname, 'Q');
end