dicklyon@615: % Copyright 2013, Google, Inc. dicklyon@615: % Author: Richard F. Lyon dicklyon@615: % dicklyon@615: % This Matlab file is part of an implementation of Lyon's cochlear model: dicklyon@615: % "Cascade of Asymmetric Resonators with Fast-Acting Compression" dicklyon@615: % to supplement Lyon's upcoming book "Human and Machine Hearing" dicklyon@615: % dicklyon@615: % Licensed under the Apache License, Version 2.0 (the "License"); dicklyon@615: % you may not use this file except in compliance with the License. dicklyon@615: % You may obtain a copy of the License at dicklyon@615: % dicklyon@615: % http://www.apache.org/licenses/LICENSE-2.0 dicklyon@615: % dicklyon@615: % Unless required by applicable law or agreed to in writing, software dicklyon@615: % distributed under the License is distributed on an "AS IS" BASIS, dicklyon@615: % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. dicklyon@615: % See the License for the specific language governing permissions and dicklyon@615: % limitations under the License. dicklyon@615: dicklyon@615: %% Test/demo hacking for CARFAC_SAI Matlab stuff: dicklyon@615: dicklyon@615: clear variables dicklyon@615: dicklyon@615: system('mkdir frames'); dicklyon@615: dicklyon@615: %% dicklyon@615: dicklyon@615: dB_list = -40; % -60:20:0 dicklyon@615: dicklyon@615: wav_fn = 'plan.wav'; dicklyon@665: wav_fn = 'Stiletto44.wav'; dicklyon@665: wav_fn = 'You Can Call Me Al.wav'; dicklyon@615: dicklyon@615: if ~exist(['./', wav_fn], 'file') dicklyon@615: error('wav file not found') dicklyon@615: end dicklyon@615: dicklyon@615: wav_fn dicklyon@615: [file_signal, fs] = wavread(wav_fn); dicklyon@615: dicklyon@665: % if fs == 44100 dicklyon@665: % file_signal = (file_signal(1:2:end-1, :) + file_signal(2:2:end, :)) / 2; dicklyon@665: % fs = fs / 2; dicklyon@665: % end dicklyon@665: % dicklyon@665: % if fs ~= 22050 dicklyon@665: % error('unexpected sample rate') dicklyon@665: % end dicklyon@615: dicklyon@615: file_signal = file_signal(:, 1); % mono dicklyon@615: file_signal = [file_signal; zeros(fs, 1)]; % pad with a second of silence dicklyon@615: dicklyon@615: dicklyon@615: % make a long test signal by repeating at different levels: dicklyon@615: test_signal = []; dicklyon@615: for dB = dB_list dicklyon@615: test_signal = [test_signal; file_signal * 10^(dB/20)]; dicklyon@615: end dicklyon@615: dicklyon@615: %% dicklyon@665: CF_struct = CARFAC_Design(1, fs); % default design dicklyon@615: dicklyon@615: CF_struct = CARFAC_Init(CF_struct); dicklyon@615: dicklyon@615: [frame_rate, num_frames] = SAI_RunLayered(CF_struct, test_signal); dicklyon@615: dicklyon@615: %% dicklyon@615: png_name_pattern = 'frames/frame%05d.png'; dicklyon@615: MakeMovieFromPngsAndWav(round(frame_rate), png_name_pattern, ... dicklyon@615: wav_fn, ['CARFAC_SAI_movie_', wav_fn(1:end-4), '.mpg']) dicklyon@615: dicklyon@615: %% dicklyon@615: system('rm -r frames'); dicklyon@615: dicklyon@665: