tom@516
|
1 % Copyright 2012, Google, Inc.
|
tom@516
|
2 % Author: Richard F. Lyon
|
tom@516
|
3 %
|
tom@516
|
4 % This Matlab file is part of an implementation of Lyon's cochlear model:
|
tom@516
|
5 % "Cascade of Asymmetric Resonators with Fast-Acting Compression"
|
tom@516
|
6 % to supplement Lyon's upcoming book "Human and Machine Hearing"
|
tom@516
|
7 %
|
tom@516
|
8 % Licensed under the Apache License, Version 2.0 (the "License");
|
tom@516
|
9 % you may not use this file except in compliance with the License.
|
tom@516
|
10 % You may obtain a copy of the License at
|
tom@516
|
11 %
|
tom@516
|
12 % http://www.apache.org/licenses/LICENSE-2.0
|
tom@516
|
13 %
|
tom@516
|
14 % Unless required by applicable law or agreed to in writing, software
|
tom@516
|
15 % distributed under the License is distributed on an "AS IS" BASIS,
|
tom@516
|
16 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
tom@516
|
17 % See the License for the specific language governing permissions and
|
tom@516
|
18 % limitations under the License.
|
tom@516
|
19
|
dicklyon@517
|
20 % Test/demo hacking for carfac matlab stuff, two-channel (binaural) case
|
tom@516
|
21
|
tom@516
|
22 clear variables
|
tom@516
|
23
|
tom@516
|
24 agc_plot_fig_num = 1;
|
tom@516
|
25
|
tom@516
|
26 tic
|
tom@516
|
27
|
dicklyon@517
|
28 file_signal = wavread('plan.wav');
|
dicklyon@517
|
29 file_signal = file_signal(9000+(1:15000)); % trim for a faster test
|
tom@516
|
30
|
dicklyon@517
|
31 itd_offset = 22; % about 1 ms
|
dicklyon@517
|
32 test_signal = [file_signal((itd_offset+1):end), ...
|
dicklyon@517
|
33 file_signal(1:(end-itd_offset))] / 10;
|
dicklyon@517
|
34
|
tom@516
|
35 CF_struct = CARFAC_Design; % default design
|
tom@516
|
36
|
dicklyon@535
|
37 % Run stereo test:
|
dicklyon@535
|
38 n_ears = 2
|
dicklyon@535
|
39 CF_struct = CARFAC_Init(CF_struct, n_ears);
|
dicklyon@517
|
40
|
dicklyon@535
|
41 [CF_struct, nap_decim, nap] = CARFAC_Run(CF_struct, test_signal, agc_plot_fig_num);
|
tom@516
|
42
|
dicklyon@535
|
43 % Display results for 2 ears:
|
dicklyon@535
|
44 for ear = 1:n_ears
|
dicklyon@535
|
45 smooth_nap = nap_decim(:, :, ear);
|
dicklyon@535
|
46 figure(ear + n_ears) % Makes figures 3 and 4
|
tom@516
|
47 image(63 * ((smooth_nap)' .^ 0.5))
|
dicklyon@535
|
48
|
tom@516
|
49 colormap(1 - gray);
|
tom@516
|
50 end
|
tom@516
|
51
|
tom@516
|
52 toc
|
tom@516
|
53
|
tom@516
|
54 % Show resulting data, even though M-Lint complains:
|
tom@516
|
55 CF_struct
|
dicklyon@535
|
56 CF_struct.CAR_state
|
tom@516
|
57 CF_struct.AGC_state
|
tom@516
|
58 min_max = [min(nap(:)), max(nap(:))]
|
tom@516
|
59 min_max_decim = [min(nap_decim(:)), max(nap_decim(:))]
|
dicklyon@517
|
60
|