tom@516: % Copyright 2012, Google, Inc. tom@516: % Author: Richard F. Lyon tom@516: % tom@516: % This Matlab file is part of an implementation of Lyon's cochlear model: tom@516: % "Cascade of Asymmetric Resonators with Fast-Acting Compression" tom@516: % to supplement Lyon's upcoming book "Human and Machine Hearing" tom@516: % tom@516: % Licensed under the Apache License, Version 2.0 (the "License"); tom@516: % you may not use this file except in compliance with the License. tom@516: % You may obtain a copy of the License at tom@516: % tom@516: % http://www.apache.org/licenses/LICENSE-2.0 tom@516: % tom@516: % Unless required by applicable law or agreed to in writing, software tom@516: % distributed under the License is distributed on an "AS IS" BASIS, tom@516: % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. tom@516: % See the License for the specific language governing permissions and tom@516: % limitations under the License. tom@516: tom@516: % Test/demo hacking for audio/hearing/filterbanks/carfac/matlab/ stuff tom@516: tom@516: clear variables tom@516: tom@516: agc_plot_fig_num = 1; tom@516: tom@516: tic tom@516: tom@516: %test_signal = wavread('pbav4p-22050.wav'); tom@516: test_signal = wavread('plan-twochannel-1ms.wav') tom@516: %test_signal = wavread('binaural.wav') tom@516: %test_signal = test_signal(20000:2); % trim for a faster test tom@516: tom@516: CF_struct = CARFAC_Design; % default design tom@516: cum_k = 0; % not doing segments, so just count from 0 tom@516: tom@516: % Run mono, then stereo test: tom@516: n_mics = 2 tom@516: CF_struct = CARFAC_Init(CF_struct, n_mics); tom@516: tom@516: [nap, CF_struct, cum_k, nap_decim] = ... tom@516: CARFAC_Run(CF_struct, test_signal, cum_k, agc_plot_fig_num); tom@516: tom@516: % Display results for 1 or 2 mics: tom@516: for mic = 1:n_mics tom@516: smooth_nap = nap_decim(:, :, mic); tom@516: figure(mic + n_mics) % Makes figures 2, 3, and 4 tom@516: image(63 * ((smooth_nap)' .^ 0.5)) tom@516: tom@516: colormap(1 - gray); tom@516: end tom@516: tom@516: toc tom@516: tom@516: % Show resulting data, even though M-Lint complains: tom@516: cum_k tom@516: CF_struct tom@516: CF_struct.filter_state tom@516: CF_struct.AGC_state tom@516: min_max = [min(nap(:)), max(nap(:))] tom@516: min_max_decim = [min(nap_decim(:)), max(nap_decim(:))]