-
Notifications
You must be signed in to change notification settings - Fork 0
/
melFilter.m
48 lines (40 loc) · 1006 Bytes
/
melFilter.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
function abc = melFilter
sampleRate = 22050;
num = 19;
nfft = 1024;
startFreq = 60;
endFreq = 11025;
melStartFreq = melTransformation(startFreq);
melEndFreq = melTransformation(endFreq);
M = linspace(melStartFreq,melEndFreq,num+2);
F = inverseMelTransformation(M);
K(1,:) = floor(1+(nfft+1)*F(1,:)/sampleRate);
H = zeros(num,513);
for m = 1:num
start = K(1,m);
mid = K(1,m+1);
stop = K(1, m+2);
for k = start:mid
H(m,k) = (k - K(1,m))/(K(1,m+1) - K(1,m));
end
for k = mid:stop
H(m,k) = (K(1,m+2) - k)/(K(1, m+2) - K(1, m+1));
end
end
Ht = transpose(H);
abc = Ht;
end
function M = melTransformation(f)
[~,s] =size(f);
M = zeros(1,s);
for i =1:s
M(1,i) = 1125 * log(1 + f/700);
end
end
function I = inverseMelTransformation(m)
[~,s] =size(m);
I = zeros(1,s);
for i =1:s
I(1,i) = 700*(exp(m(1,i)/1125)-1);
end
end