comparison Source/initMFCCVariables.m @ 0:25bf17994ef1

First commit. VS2013, Codeblocks and Mac OSX configuration
author Geogaddi\David <d.m.ronan@qmul.ac.uk>
date Thu, 09 Jul 2015 01:12:16 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:25bf17994ef1
1 function [mfccFilterWeights mfccDCTMatrix] = initMFCCVariables(sampleRate, FFTsize)
2
3 Fs = sampleRate;
4 Nfft = FFTsize;
5
6 %Filter bank parameters
7 lowestFrequency = 133.3333;
8 linearFilters = 13;
9 linearSpacing = 66.66666666;
10 logFilters = 27;
11 logSpacing = 1.0711703;
12 cepstralCoefficients = 13;
13
14 % Keep this around for later....
15 totalFilters = linearFilters + logFilters;
16
17 % Now figure the band edges. Interesting frequencies are spaced
18 % by linearSpacing for a while, then go logarithmic. First figure0
19 % all the interesting frequencies. Lower, center, and upper band
20 % edges are all consecutive interesting frequencies.
21 freqs = lowestFrequency + (0:linearFilters-1)*linearSpacing;
22 freqs(linearFilters+1:totalFilters+2) = freqs(linearFilters) * logSpacing.^(1:logFilters+2);
23 lower = freqs(1:totalFilters);
24 center = freqs(2:totalFilters+1);
25 upper = freqs(3:totalFilters+2);
26
27 % each filter has unit weight, assuming a triangular weighting function
28 mfccFilterWeights = zeros(totalFilters,Nfft/2);
29 triangleHeight = 2./(upper-lower);
30 fftFreqs = (0:Nfft/2-1)/(Nfft)*Fs;
31 for chan=1:totalFilters
32 mfccFilterWeights(chan,:) = (fftFreqs > lower(chan) & fftFreqs <= center(chan)).* triangleHeight(chan).*(fftFreqs-lower(chan))/(center(chan)-lower(chan)) + ...
33 (fftFreqs > center(chan) & fftFreqs < upper(chan)) .* triangleHeight(chan).*(upper(chan)-fftFreqs)/(upper(chan)-center(chan));
34 end
35
36 % Figure out Discrete Cosine Transform. We want a matrix
37 % dct(i,j) which is totalFilters x cepstralCoefficients in size.
38 % The i,j component is given by cos( i * (j+0.5)/totalFilters pi )
39 % where we have assumed that i and j start at 0.
40 mfccDCTMatrix = 1/sqrt(totalFilters/2)*cos((0:(cepstralCoefficients-1))' * (2*(0:(totalFilters-1))+1) * pi/2/totalFilters);
41 mfccDCTMatrix(1,:) = mfccDCTMatrix(1,:) * sqrt(2)/2;
42