Mercurial > hg > camir-aes2014
comparison toolboxes/MIRtoolbox1.3.2/AuditoryToolbox/LyonPassiveEar.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e9a9cd732c1e |
---|---|
1 function y=LyonPassiveEar(x,sr,df,earQ,stepfactor,differ,agcf,taufactor) | |
2 % y=LyonPassiveEar(input, sample_rate, decimation, earQ, stepfactor); | |
3 % | |
4 % Changes | |
5 % Zeroed out the preemphasis channels before doing the AGC. This is needed | |
6 % so that cochlear inversion is possible (since we don't have those channels, | |
7 % we can't invert their gain.)..... Malcolm 6/26/95 | |
8 | |
9 % (c) 1998 Interval Research Corporation | |
10 | |
11 if nargin < 3 | |
12 fprintf('Syntax: y=LyonPassiveEar(input, sample_rate, decimation, earQ, stepfactor)\n'); | |
13 fprintf(' The input, sample_rate, and decimation parameters are mandatory.\n'); | |
14 return; | |
15 end | |
16 | |
17 if df < 1; df = 1; end | |
18 if nargin < 4; earQ = 8; end | |
19 if nargin < 5; stepfactor = earQ/32; end | |
20 if nargin < 6; differ=1; end | |
21 if nargin < 7; agcf=1; end | |
22 if nargin < 8; taufactor=3; end | |
23 | |
24 earFilters = DesignLyonFilters(sr, earQ, stepfactor); | |
25 | |
26 nSamples = length(x); | |
27 nOutputSamples = floor(nSamples/df); | |
28 [nChannels filterWidth] = size(earFilters); | |
29 | |
30 sosOutput = zeros(nChannels, df); | |
31 sosState = zeros(nChannels, 2); | |
32 agcState = zeros(nChannels, 4); | |
33 y = zeros(nChannels, nOutputSamples); | |
34 | |
35 decEps = EpsilonFromTauFS(df/sr*taufactor,sr); | |
36 decState = zeros(nChannels, 2); | |
37 decFilt = SetGain([0 0 1 -2*(1-decEps) (1-decEps)^2], 1, 0, sr); | |
38 | |
39 eps1 = EpsilonFromTauFS(.64,sr); | |
40 eps2 = EpsilonFromTauFS(.16,sr); | |
41 eps3 = EpsilonFromTauFS(.04,sr); | |
42 eps4 = EpsilonFromTauFS(.01,sr); | |
43 | |
44 tar1 = .0032; | |
45 tar2 = .0016; | |
46 tar3 = .0008; | |
47 tar4 = .0004; | |
48 | |
49 if 0 | |
50 fprintf('df=%g, earq=%g, stepfactor=%g, differ=%g\n',df,earQ,stepfactor,differ); | |
51 fprintf('agcf=%g, taufactor=%g\n', agcf, taufactor); | |
52 [tar1 tar2 tar3 tar4; eps1 eps2 eps3 eps4] | |
53 end | |
54 | |
55 for i=0:nOutputSamples-1 | |
56 [sosOutput sosState]= soscascade(x(i*df+1:i*df+df), earFilters, ... | |
57 sosState); | |
58 output = max(0, sosOutput); %% Half Wave Rectify | |
59 output(1) = 0; %% Test Hack to make inversion easier. | |
60 output(2) = 0; | |
61 if agcf > 0 | |
62 [output agcState] = agc(output, [tar1 tar2 tar3 tar4; ... | |
63 eps1 eps2 eps3 eps4], ... | |
64 agcState); | |
65 end | |
66 | |
67 if differ > 0 | |
68 output = [output(1,:);output(1:nChannels-1,:) - ... | |
69 output(2:nChannels,:)]; | |
70 output = max(0, output); | |
71 end | |
72 | |
73 if df > 1 | |
74 [output decState] = sosfilters(output, decFilt, decState); | |
75 end | |
76 y(:,i+1) = output(:,df); | |
77 end | |
78 | |
79 %y = min(y,2*tar4); | |
80 y=y(3:nChannels,:); |