tomwalters@0
|
1 % CalMICoef
|
tomwalters@0
|
2 % SAI -> Mellin Image Coefficient Direct
|
tomwalters@0
|
3 % IRINO T.
|
tomwalters@0
|
4 % 18 Jan 01
|
tomwalters@0
|
5 % 27 Jun 01 (modified to MFCC type, Not on LogFrq)
|
tomwalters@0
|
6 % 11 Jan 02 (NAPparam, MIparam)
|
tomwalters@0
|
7 %
|
tomwalters@0
|
8 % Modified for the size shape image
|
tomwalters@0
|
9 % Marc A. Al-Hames
|
tomwalters@0
|
10 % April 2003
|
tomwalters@0
|
11 %
|
tomwalters@0
|
12 % function [ MICoef ] = CalMellinCoef(SAIPhsCmp,NAPparam,MIparam)
|
tomwalters@0
|
13 % INPUT: SAIPhsCmp : SAI val with Phase Compensation
|
tomwalters@0
|
14 % NAPparam:
|
tomwalters@0
|
15 % fs : Sampling Frequency
|
tomwalters@0
|
16 % Frs : Channel frequencies
|
tomwalters@0
|
17 % MIparam:
|
tomwalters@0
|
18 % RangeAudFig: Range of Auditory Figure
|
tomwalters@0
|
19 % [ZERO, Boundary] in sampling-point
|
tomwalters@0
|
20 % TFval : TFval == Hval (--> abscissa of MI)
|
tomwalters@0
|
21 % c_2pi : Kernel spatial frequeny (--> ordinate of MI)
|
tomwalters@0
|
22 % Mu : Kernel spatial weighting
|
tomwalters@0
|
23 % OUTPUT: MICoef : MI value
|
tomwalters@0
|
24
|
tomwalters@0
|
25 function [ ssi ] = Calssicoef(SAIPhsCmp,NAPparam,MIparam)
|
tomwalters@0
|
26
|
tomwalters@0
|
27 fs = NAPparam.fs;
|
tomwalters@0
|
28 Frs = NAPparam.Frs;
|
tomwalters@0
|
29 RangeAudFig = MIparam.RangeAudFig;
|
tomwalters@0
|
30 TFval = MIparam.TFval;
|
tomwalters@0
|
31 c_2pi = MIparam.c_2pi;
|
tomwalters@0
|
32 Mu = MIparam.Mu;
|
tomwalters@0
|
33
|
tomwalters@0
|
34 [NumCh LenSAI] = size(SAIPhsCmp);
|
tomwalters@0
|
35 LenAF = diff(RangeAudFig)+1;
|
tomwalters@0
|
36 LenTaper = round(0.5*NAPparam.fs/1000); % 0.5 ms taper
|
tomwalters@0
|
37 WinAF = TaperWindow(LenAF+LenTaper,'han',LenTaper);
|
tomwalters@0
|
38 WinAF = ones(NumCh,1)*WinAF(LenTaper+(1:LenAF));
|
tomwalters@0
|
39
|
tomwalters@0
|
40
|
tomwalters@0
|
41
|
tomwalters@0
|
42 AFval = WinAF .* SAIPhsCmp(:,RangeAudFig(1):RangeAudFig(2));
|
tomwalters@0
|
43 [NumCh,LenAF] = size(AFval);
|
tomwalters@0
|
44 %MICoef=AFval; %added line
|
tomwalters@0
|
45 %%%%%%%%%%
|
tomwalters@0
|
46 %% LogFrs = log10(Frs(:)/min(Frs))/log10(6000/100); % normalized in [100 6000]
|
tomwalters@0
|
47 %% NormFrq = LogFrs;
|
tomwalters@0
|
48 %% Change to MFCC type, DCT on ERB domain on 27 Jun 2001
|
tomwalters@0
|
49 NormFreq = ( (0:NumCh-1) + 0.5 )/NumCh;
|
tomwalters@0
|
50 c_pi = 2*c_2pi;
|
tomwalters@0
|
51
|
tomwalters@0
|
52 amp = exp((Mu-0.5)*0.5)*sqrt(2/NumCh); % mag. norm. when NormFreq == 0.5
|
tomwalters@0
|
53 % when using ERB --> Frs~=760 Hz
|
tomwalters@0
|
54 Kernel = amp*exp( ( i*pi*c_pi(:) - (Mu-0.5)) * NormFreq(:)');
|
tomwalters@0
|
55 Kernel(1,1:NumCh) = Kernel(1,1:NumCh)/sqrt(2);
|
tomwalters@0
|
56 %
|
tomwalters@0
|
57 % for confirmation (15 Jan 2002)
|
tomwalters@0
|
58 % Kernel1 = Kernel;
|
tomwalters@0
|
59 % Kernel2 = DCTWarpFreq(0,length(NormFreq),length(c_pi),0);
|
tomwalters@0
|
60 % plot(real(Kernel1(7,:)))
|
tomwalters@0
|
61 % hold on
|
tomwalters@0
|
62 % plot(1:NumCh,real(Kernel(4,:)),'r--', 1:NumCh,abs(Kernel(4,:)))
|
tomwalters@0
|
63 % sum(Kernel1(3,:)-Kernel2(2,:))
|
tomwalters@0
|
64 % hold off
|
tomwalters@0
|
65 % pause
|
tomwalters@0
|
66 %
|
tomwalters@0
|
67 % Kernel Mag at 100Hz Mag at 6000Hz
|
tomwalters@0
|
68 % Mu = 2: 2.1170 0.4724 % lowpass
|
tomwalters@0
|
69 % Mu = 1: 1.2840 0.7788 % lowpass
|
tomwalters@0
|
70 % Mu = 0.5: 1.0 1.0 % flat
|
tomwalters@0
|
71 % Mu = 0: 0.7788 1.2840 % high pass
|
tomwalters@0
|
72 %
|
tomwalters@0
|
73 % clf
|
tomwalters@0
|
74 % plot(LogFrs,Kernel);
|
tomwalters@0
|
75 % amp*exp((-Mu+0.5)*[0 1])
|
tomwalters@0
|
76
|
tomwalters@0
|
77 %%%%%%%%%%
|
tomwalters@0
|
78
|
tomwalters@0
|
79 TFmargin = 0.1;
|
tomwalters@0
|
80 AFave = zeros(NumCh,length(TFval));
|
tomwalters@0
|
81 MICoef = zeros(length(c_2pi),length(TFval));
|
tomwalters@0
|
82
|
tomwalters@0
|
83 ValNorm = 1;
|
tomwalters@0
|
84
|
tomwalters@0
|
85 % It's worth notin what's going on here, becuase it's not completely
|
tomwalters@0
|
86 % obvious. AFval contains the
|
tomwalters@0
|
87 for cntTF = 1:length(TFval);
|
tomwalters@0
|
88 cntCh = 0;
|
tomwalters@0
|
89 for nch = 1:NumCh
|
tomwalters@0
|
90 nSAImin = max(1,fix((TFval(cntTF)-TFmargin)/Frs(nch)*fs));
|
tomwalters@0
|
91 nSAImax = min(ceil((TFval(cntTF)+TFmargin)/Frs(nch)*fs), LenAF);
|
tomwalters@0
|
92 % aaa(nch,1:5) = [cntTF, nch, Frs(nch), nSAImin nSAImax];
|
tomwalters@0
|
93 if nSAImin <= nSAImax,
|
tomwalters@0
|
94 AFave(nch,cntTF) = mean(AFval(nch,nSAImin:nSAImax))/ValNorm;
|
tomwalters@0
|
95 cntCh = cntCh +1;
|
tomwalters@0
|
96 end;
|
tomwalters@0
|
97 end;
|
tomwalters@0
|
98 % NumValidCh(cntTF) = cntCh;
|
tomwalters@0
|
99 % ChNorm = NumCh/cntCh; % 10 Oct 01 --> Too much normalization
|
tomwalters@0
|
100 % ChNorm = 1; % it seems the best at 15 Jan 02
|
tomwalters@0
|
101 % MICoef(1:length(c_2pi),cntTF) = ( Kernel*AFave(:,cntTF) )*ChNorm;
|
tomwalters@0
|
102 end;
|
tomwalters@0
|
103
|
tomwalters@0
|
104 ssi = AFave;
|
tomwalters@0
|
105
|
tomwalters@0
|
106 % Normalization by Number of channels within one AF,
|
tomwalters@0
|
107 % which depends on h values.
|
tomwalters@0
|
108
|
tomwalters@0
|
109 % ValRatio = sum(NumValidCh)/(length(TFval)*NumCh);
|
tomwalters@0
|
110 % MICoef = MICoef*ValRatio;
|
tomwalters@0
|
111
|
tomwalters@0
|
112 return
|
tomwalters@0
|
113
|
tomwalters@0
|
114 % Do not apply this. (12 Mar. 2001)
|
tomwalters@0
|
115 % if length(SAIval) > 1,
|
tomwalters@0
|
116 % ValNorm = max(mean(SAIval)); % Mag. of strobing point
|
tomwalters@0
|
117 % if ValNorm < 0.01, ValNorm = 1; end;
|
tomwalters@0
|
118 % end;
|