-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathToolMfccFb.m
40 lines (32 loc) · 1.17 KB
/
ToolMfccFb.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
%> see function mfcc.m from Slaneys Auditory Toolbox
function [H] = ToolMfccFb (iMagSpecLength, f_s)
% initialization
f_start = 133.3333;
iNumLinFilters = 13;
iNumLogFilters = 27;
iNumFilters = iNumLinFilters + iNumLogFilters;
linearSpacing = 66.66666666;
logSpacing = 1.0711703;
% compute band frequencies
f = f_start + (0:iNumLinFilters-1)*linearSpacing;
f(iNumLinFilters+1:iNumFilters+2) = ...
f(iNumLinFilters) * logSpacing.^(1:iNumLogFilters+2);
% sanity check
f = f (f<f_s/2);
iNumFilters = length(f)-2;
f_l = f(1:iNumFilters);
f_c = f(2:iNumFilters+1);
f_u = f(3:iNumFilters+2);
% allocate memory for filters and set max amplitude
H = zeros(iNumFilters,iMagSpecLength);
afFilterMax = 2./(f_u-f_l);
f_k = (0:iMagSpecLength-1)/(iMagSpecLength-1)*f_s/2;
% compute the transfer functions
for c = 1:iNumFilters
H(c,:) = ...
(f_k > f_l(c) & f_k <= f_c(c)).* ...
afFilterMax(c).*(f_k-f_l(c))/(f_c(c)-f_l(c)) + ...
(f_k > f_c(c) & f_k < f_u(c)).* ...
afFilterMax(c).*(f_u(c)-f_k)/(f_u(c)-f_c(c));
end
end