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