tom@513: % Copyright 2012 Google Inc. All Rights Reserved. tom@455: % Author: Richard F. Lyon tom@455: % tom@455: % This Matlab file is part of an implementation of Lyon's cochlear model: tom@455: % "Cascade of Asymmetric Resonators with Fast-Acting Compression" tom@455: % to supplement Lyon's upcoming book "Human and Machine Hearing" tom@455: % tom@455: % Licensed under the Apache License, Version 2.0 (the "License"); tom@455: % you may not use this file except in compliance with the License. tom@455: % You may obtain a copy of the License at tom@455: % tom@455: % http://www.apache.org/licenses/LICENSE-2.0 tom@455: % tom@455: % Unless required by applicable law or agreed to in writing, software tom@455: % distributed under the License is distributed on an "AS IS" BASIS, tom@455: % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. tom@455: % See the License for the specific language governing permissions and tom@455: % limitations under the License. tom@455: tom@455: function MultiScaleSmooth(waves, n_scales) tom@455: % function MultiScaleSmooth(waves, n_scales) tom@455: % tom@455: % Let's take columns as waveforms, and smooth them to different scales; tom@455: % these inputs can be carfac NAPs, for example, and the peaks of the tom@455: % smoothed versions can be used as trigger events, even tracking back tom@455: % to less-smoothed versions. tom@455: % And we'll deciamte 2:1 at every other smoothing. tom@455: % tom@455: % Until we decide what we want, we'll just plot things, one plot per scale. tom@455: tom@455: fig_offset1 = 10; tom@455: tom@455: if nargin < 2 tom@455: n_scales = 20; tom@455: end tom@455: tom@455: smoothed = waves; tom@455: tom@455: for scale_no = 1:n_scales tom@455: tom@455: if mod(scale_no, 2) == 1 tom@455: newsmoothed = filter([1, 1]/2, 1, smoothed); tom@455: diffsmoothed = max(0, smoothed - newsmoothed); tom@455: smoothed = newsmoothed; tom@455: else tom@455: newsmoothed = filter([1, 2, 1]/4, 1, smoothed); tom@455: diffsmoothed = max(0, smoothed - newsmoothed); tom@455: smoothed = newsmoothed(1:2:end, :); tom@455: end tom@455: tom@455: figure(scale_no + fig_offset1) dicklyon@462: imagesc(squeeze(smoothed(:,:,1))') tom@455: tom@455: drawnow tom@455: pause(1) tom@455: tom@455: end tom@455: