comparison functions/fe_funcs/mel_matrix.m @ 0:2fadb31a9d55 tip

Import code by Vuegen et al
author Dan Stowell <dan.stowell@elec.qmul.ac.uk>
date Fri, 11 Oct 2013 12:02:43 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:2fadb31a9d55
1 function [M,fCen,Mfull]=mel_matrix(fs,NbCh,Nfft,warp,fhigh,flow)
2 % [M,fCen,Mfull]=mel_matrix(fs,NbCh,Nfft,warp,fhigh)
3 % returns Nfft/2+1 - by - NbCh matrix of triangular weights
4 % NbCh filterbanks linearly spaced on a MEL scale till fhigh
5 % warp: default 1.0
6 % fhigh: default=fs/2
7 % Mfull: matrix without truncation to Nfft/2+1 points
8
9 if nargin<4,
10 warp=1;
11 end
12 if nargin<5,
13 fhigh=fs/2;
14 end
15
16 LowMel=2595 * log10(1+flow/700);
17 NyqMel=2595 * log10(1+fhigh/700);
18
19 StartMel=LowMel + (0:NbCh-1)/(NbCh+1)*(NyqMel-LowMel);
20 fCen=warp*700*(10.^(StartMel/2595)-1);
21 StartBin=round(Nfft/fs*fCen)+1;
22
23 EndMel=LowMel + (2:NbCh+1)/(NbCh+1)*(NyqMel-LowMel);
24 EndBin=round(warp*Nfft/fs*700*(10.^(EndMel/2595)-1))+1;
25
26 TotLen=EndBin-StartBin+1;
27
28 LowLen=[StartBin(2:NbCh) EndBin(NbCh-1)]-StartBin+1;
29 HiLen=TotLen-LowLen+1;
30
31 M=sparse([],[],[],ceil(warp*Nfft/2+1),NbCh,sum(TotLen));
32 for k=1:NbCh,
33 M(StartBin(k):StartBin(k)+LowLen(k)-1,k)=(1:LowLen(k))'/LowLen(k);
34 M(EndBin(k)-HiLen(k)+1:EndBin(k),k)=(HiLen(k):-1:1)'/HiLen(k);
35 end
36 %TotWeight=sum(M,1);
37 Mfull=M;
38 M=M(1:Nfft/2+1,:);
39 %WeightSum=full([sum(M,1);TotWeight]);