Mercurial > hg > aimc
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/matlab/bmm/carfac/CARFAC_Compare_CPP_Test_Data.m Mon May 27 16:36:54 2013 +0000 @@ -0,0 +1,83 @@ +% Author: Alex Brandmeyer +% +% This Matlab file is part of an implementation of Lyon's cochlear model: +% "Cascade of Asymmetric Resonators with Fast-Acting Compression" +% to supplement Lyon's upcoming book "Human and Machine Hearing" +% +% Licensed under the Apache License, Version 2.0 (the "License"); +% you may not use this file except in compliance with the License. +% You may obtain a copy of the License at +% +% http://www.apache.org/licenses/LICENSE-2.0 +% +% Unless required by applicable law or agreed to in writing, software +% distributed under the License is distributed on an "AS IS" BASIS, +% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +% See the License for the specific language governing permissions and +% limitations under the License. + +function CARFAC_Compare_CPP_Test_Data() +data_dir = '../../../carfac/test_data/'; +filename = 'long_test_nap1.txt'; +matlab_nap1 = dlmread([data_dir filename]); +filename = 'cpp_nap_output_1_long_test.txt'; +cpp_nap1 = dlmread([data_dir filename]); +filename = 'long_test_nap2.txt'; +matlab_nap2 = dlmread([data_dir filename]); +filename = 'cpp_nap_output_2_long_test.txt'; +cpp_nap2 = dlmread([data_dir filename]); + +factor = 10; +figure(1) +subplot(2,2,1) +image(matlab_nap1' * factor); +title('Long Test: Matlab NAP, Ear 1'); +ylabel('Channel'); +xlabel('Sample Index'); +subplot(2,2,2) +image(matlab_nap2' * factor); +title('Long Test: Matlab NAP, Ear 2') +ylabel('Channel'); +xlabel('Sample Index'); +subplot(2,2,3) +image(cpp_nap1' * factor); +title('Long Test: C++ NAP, Ear 1') +ylabel('Channel'); +xlabel('Sample Index'); +subplot(2,2,4) +image(cpp_nap2' * factor); +title('Long Test: C++ NAP, Ear 2') +ylabel('Channel'); +xlabel('Sample Index'); + +filename = 'binaural_test_nap1.txt'; +matlab_nap1 = dlmread([data_dir filename]); +filename = 'cpp_nap_output_1_binaural_test.txt'; +cpp_nap1 = dlmread([data_dir filename]); +filename = 'binaural_test_nap2.txt'; +matlab_nap2 = dlmread([data_dir filename]); +filename = 'cpp_nap_output_2_binaural_test.txt'; +cpp_nap2 = dlmread([data_dir filename]); + +factor = 10; +figure(2) +subplot(2,2,1) +image(matlab_nap1' * factor); +title('Binaural Test: Matlab NAP, Ear 1'); +ylabel('Channel'); +xlabel('Sample Index'); +subplot(2,2,2) +image(matlab_nap2' * factor); +title('Binaural Test: Matlab NAP, Ear 2') +ylabel('Channel'); +xlabel('Sample Index'); +subplot(2,2,3) +image(cpp_nap1' * factor); +title('Binaural Test: C++ NAP, Ear 1') +ylabel('Channel'); +xlabel('Sample Index'); +subplot(2,2,4) +image(cpp_nap2' * factor); +title('Binaural Test: C++ NAP, Ear 2') +ylabel('Channel'); +xlabel('Sample Index'); \ No newline at end of file
