-
Notifications
You must be signed in to change notification settings - Fork 0
/
Extract_short.m
40 lines (40 loc) · 1.08 KB
/
Extract_short.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
function [out, names] = Extract_short(dirname,subname,counter)
full = strcat(dirname,'/',subname);
files = dir(full);
out = zeros(432432,length(files)-2);
for file = files'
if file.name == '.'
continue
end
name = strcat(full,'/',file.name);
[x,~] = audioread(name);
x = x(:,1);
if length(x) ~= length(out)
if length(x) > length(out)
x = x(1:length(out));
else
x(numel(out(:,1))) = 0;
end
end
out(:,counter) = x;
counter = counter+1;
end
names =[];
counter = 1;
start = length(full)+2;
for file = files'
if file.name == '.'
continue
end
name = strcat(full,'/',file.name);
if subname(1:4) == 'Free'
temp = string(name(start:end));
pername = extractBefore(temp,'-');
else
pername = string(name(start:end-6));
end
names{counter} = pername;
% names(:,counter) = pername;
counter = counter+1;
end
end