-
Notifications
You must be signed in to change notification settings - Fork 0
/
feature_mfccs_init.m
60 lines (55 loc) · 2.56 KB
/
feature_mfccs_init.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
59
60
function mfccParams = feature_mfccs_init(windowLength, fs)
% function mfccParams = feature_mfccs_init(windowLength, fs)
%
% This function is used to initalize the mfcc quantities
% used in the MFCC calculation
%
% ARGUMENTS:
% - windowLength: the length of the window analysis (in number of samples)
% - fs: : the sampling frequency (in Hz)
%
% RETURNS:
% - mfccParams : returns a structure with the mfcc params:
%
% (c) 2014 T. Giannakopoulos, A. Pikrakis
% number of cepstral coefficients:
mfccParams.cepstralCoefficients = 13;
% fft resolution:
mfccParams.fftSize = round(windowLength / 2);
% filter parameters:
mfccParams.lowestFrequency = 133.3333;
mfccParams.linearFilters = 13;
mfccParams.linearSpacing = 66.66666666;
mfccParams.logFilters = 27;
mfccParams.logSpacing = 1.0711703;
mfccParams.totalFilters = mfccParams.linearFilters + ...
mfccParams.logFilters;
mfccParams.freqs = mfccParams.lowestFrequency + ...
(0:mfccParams.linearFilters-1)*mfccParams.linearSpacing;
mfccParams.freqs(mfccParams.linearFilters+1:mfccParams.totalFilters+2) = ...
mfccParams.freqs(mfccParams.linearFilters) * ...
mfccParams.logSpacing.^(1:mfccParams.logFilters+2);
mfccParams.lower = mfccParams.freqs(1:mfccParams.totalFilters);
mfccParams.center = mfccParams.freqs(2:mfccParams.totalFilters+1);
mfccParams.upper = mfccParams.freqs(3:mfccParams.totalFilters+2);
mfccParams.mfccFilterWeights = zeros(mfccParams.totalFilters,mfccParams.fftSize);
mfccParams.triangleHeight = 2./(mfccParams.upper-mfccParams.lower);
mfccParams.fftFreqs = (0:mfccParams.fftSize-1)/mfccParams.fftSize*fs;
for chan=1:mfccParams.totalFilters % for each filter:
% compute the respective filter weights:
mfccParams.mfccFilterWeights(chan,:) = (mfccParams.fftFreqs > ...
mfccParams.lower(chan) & mfccParams.fftFreqs <= mfccParams.center(chan)).* ...
mfccParams.triangleHeight(chan).*...
(mfccParams.fftFreqs-mfccParams.lower(chan))/...
(mfccParams.center(chan)-mfccParams.lower(chan)) + ...
(mfccParams.fftFreqs > mfccParams.center(chan) & ...
mfccParams.fftFreqs < mfccParams.upper(chan)).* ...
mfccParams.triangleHeight(chan).*...
(mfccParams.upper(chan)-mfccParams.fftFreqs)/...
(mfccParams.upper(chan)-mfccParams.center(chan));
end
% matrix used in the DCT calculation:
mfccParams.mfccDCTMatrix = 1/sqrt(mfccParams.totalFilters/2)*...
cos((0:(mfccParams.cepstralCoefficients-1))' * ...
(2*(0:(mfccParams.totalFilters-1))+1) * pi/2/mfccParams.totalFilters);
mfccParams.mfccDCTMatrix(1,:) = mfccParams.mfccDCTMatrix(1,:) * sqrt(2)/2;