Mercurial > hg > ishara
diff dsp/specbasis.m @ 33:5b7d90b6393a
Minor tweaks, still needs work.
author | samer |
---|---|
date | Sun, 20 Jan 2013 18:56:19 +0000 |
parents | c3b0cd708782 |
children |
line wrap: on
line diff
--- a/dsp/specbasis.m Sun Jan 20 13:48:47 2013 +0000 +++ b/dsp/specbasis.m Sun Jan 20 18:56:19 2013 +0000 @@ -1,14 +1,14 @@ function map=specbasis(edges,M) % specbasis - Create frequency mapping matrix -% -% Converts a filterbank specification into a sparse matrix for -% mutliplying with a linear-frequency spectrogram. % % as_fmap :: % [[L-1]] ~ 'array of L-1 bin edge frequencies, in FT bins', % M:natural ~ 'number of bins in linear-freq spectrum' % -> % [[L,M]] ~ 'L-by-M sparse array'. +% +% Converts a filterbank specification into a sparse matrix for +% mutliplying with a linear-frequency spectrogram. % % Note, frequencies must measured in bins of the target spectrum, % Also, the first and last of the L bands are catch-alls which @@ -16,23 +16,11 @@ % respectively. If, eg, the bottom edge is 0, then the bottom % band will be empty. -% 2005-01-15 Written - Samer Abdallah: to reproduce behaviour of -% a the function as_fmap_orig.m. It runs at about half -% the speed, but this version is only 8 lines of code! -% Also, this version doesn't barf if more than one band -% edge falls in a frequency bin. -% -% 2005-01-29 SA: switched to measuring frequency in bins and specifying -% the size of the spectrum to be remapped. This makes the -% function more general in that it doesn't assume that -% 1+N/2 bins are retained from an N-point FFT. In fact, the -% function is now independent of the FFT size. - - E=repmat([0; edges(:); M-1],1,M); - I=repmat(0:M-1,length(edges)+1,1); - map=sparse(phi(E(2:end,:)-I)-phi(E(1:end-1,:)-I)); - map=map.*(map>8e-15); % squeeze out more small values - map(:,2:end-1)=map(:,2:end-1)/2; % make up for top and bottom bins +E=repmat([0; edges(:); M-1],1,M); +I=repmat(0:M-1,length(edges)+1,1); +map=sparse(phi(E(2:end,:)-I)-phi(E(1:end-1,:)-I)); +map=map.*(map>8e-15); % squeeze out more small values +map(:,2:end-1)=map(:,2:end-1)/2; % make up for top and bottom bins % ____ % this is piecewise linear ramp : ___/