Mercurial > hg > aimc
comparison matlab/bmm/carfac/CARFAC_Compare_CPP_Test_Data.m @ 636:27f2d9b76075
Fifth revision of Alex Brandmeyer's C++ implementation of CARFAC. Moved output structure to deque<vector<FloatArray>, moved coefficient Design methods to CARFAC object, moved tests into carfac_test.cc. Verified binaural output against Matlab using two tests. Added CARFAC_Compare_CPP_Test_Data to plot NAP output of C++ version against Matlab version. Verified build and test success on OS X using SCons with g++ 4.7 (std=c++11).
author | alexbrandmeyer |
---|---|
date | Mon, 27 May 2013 16:36:54 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
635:0bdd58ee6e92 | 636:27f2d9b76075 |
---|---|
1 % Author: Alex Brandmeyer | |
2 % | |
3 % This Matlab file is part of an implementation of Lyon's cochlear model: | |
4 % "Cascade of Asymmetric Resonators with Fast-Acting Compression" | |
5 % to supplement Lyon's upcoming book "Human and Machine Hearing" | |
6 % | |
7 % Licensed under the Apache License, Version 2.0 (the "License"); | |
8 % you may not use this file except in compliance with the License. | |
9 % You may obtain a copy of the License at | |
10 % | |
11 % http://www.apache.org/licenses/LICENSE-2.0 | |
12 % | |
13 % Unless required by applicable law or agreed to in writing, software | |
14 % distributed under the License is distributed on an "AS IS" BASIS, | |
15 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 % See the License for the specific language governing permissions and | |
17 % limitations under the License. | |
18 | |
19 function CARFAC_Compare_CPP_Test_Data() | |
20 data_dir = '../../../carfac/test_data/'; | |
21 filename = 'long_test_nap1.txt'; | |
22 matlab_nap1 = dlmread([data_dir filename]); | |
23 filename = 'cpp_nap_output_1_long_test.txt'; | |
24 cpp_nap1 = dlmread([data_dir filename]); | |
25 filename = 'long_test_nap2.txt'; | |
26 matlab_nap2 = dlmread([data_dir filename]); | |
27 filename = 'cpp_nap_output_2_long_test.txt'; | |
28 cpp_nap2 = dlmread([data_dir filename]); | |
29 | |
30 factor = 10; | |
31 figure(1) | |
32 subplot(2,2,1) | |
33 image(matlab_nap1' * factor); | |
34 title('Long Test: Matlab NAP, Ear 1'); | |
35 ylabel('Channel'); | |
36 xlabel('Sample Index'); | |
37 subplot(2,2,2) | |
38 image(matlab_nap2' * factor); | |
39 title('Long Test: Matlab NAP, Ear 2') | |
40 ylabel('Channel'); | |
41 xlabel('Sample Index'); | |
42 subplot(2,2,3) | |
43 image(cpp_nap1' * factor); | |
44 title('Long Test: C++ NAP, Ear 1') | |
45 ylabel('Channel'); | |
46 xlabel('Sample Index'); | |
47 subplot(2,2,4) | |
48 image(cpp_nap2' * factor); | |
49 title('Long Test: C++ NAP, Ear 2') | |
50 ylabel('Channel'); | |
51 xlabel('Sample Index'); | |
52 | |
53 filename = 'binaural_test_nap1.txt'; | |
54 matlab_nap1 = dlmread([data_dir filename]); | |
55 filename = 'cpp_nap_output_1_binaural_test.txt'; | |
56 cpp_nap1 = dlmread([data_dir filename]); | |
57 filename = 'binaural_test_nap2.txt'; | |
58 matlab_nap2 = dlmread([data_dir filename]); | |
59 filename = 'cpp_nap_output_2_binaural_test.txt'; | |
60 cpp_nap2 = dlmread([data_dir filename]); | |
61 | |
62 factor = 10; | |
63 figure(2) | |
64 subplot(2,2,1) | |
65 image(matlab_nap1' * factor); | |
66 title('Binaural Test: Matlab NAP, Ear 1'); | |
67 ylabel('Channel'); | |
68 xlabel('Sample Index'); | |
69 subplot(2,2,2) | |
70 image(matlab_nap2' * factor); | |
71 title('Binaural Test: Matlab NAP, Ear 2') | |
72 ylabel('Channel'); | |
73 xlabel('Sample Index'); | |
74 subplot(2,2,3) | |
75 image(cpp_nap1' * factor); | |
76 title('Binaural Test: C++ NAP, Ear 1') | |
77 ylabel('Channel'); | |
78 xlabel('Sample Index'); | |
79 subplot(2,2,4) | |
80 image(cpp_nap2' * factor); | |
81 title('Binaural Test: C++ NAP, Ear 2') | |
82 ylabel('Channel'); | |
83 xlabel('Sample Index'); |