Mercurial > hg > ishara
view dsp/hann_filterbank.m @ 61:eff6bddf82e3 tip
Finally implemented perceptual brightness thing.
author | samer |
---|---|
date | Sun, 11 Oct 2015 10:20:42 +0100 |
parents | c3b0cd708782 |
children |
line wrap: on
line source
% hann_filterbank - Bank of Hanning (raised cosine) filters % % hann_filterbank :: % E:[[M+2]->nonneg] ~'array of filter edge frequencies', % F:[[N]] ~'array of bin frequencies for input spectra' % -> [[M,N]] ~'matrix to multiply by input spectra'. % % Modelled on Malcom Slaney's code in Auditory toolbox. function W=hann_filterbank(edges,f) M = length(edges)-2; % total number of filters to prepare lower = edges(1:M); center = edges(2:M+1); upper = edges(3:M+2); W = zeros(M,length(f)); for i=1:M W(i,:) = (f>lower(i) & f<=center(i)).*(f-lower(i))/(center(i)-lower(i)) ... + (f>center(i) & f<upper(i)).*(upper(i)-f)/(upper(i)-center(i)); end W=sparse((1-cos(pi*W))/2); end