## [b6ad1a]: comp / comp_filterbank.m  Maximize  Restore  History

### 103 lines (89 with data), 3.4 kB

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98``` ```function c=comp_filterbank(f,g,a); %COMP_FILTERBANK Compute filtering % % If numel(g.h)<=crossover, the routine will use the time-side algorithm for % FIR filters, otherwise it will always do the multiplication in the % frequency domain. [L,W]=size(f); M=numel(g); c = cell(M,1); % Divide filters to time domain and frequency domain groups mFreq = 1:M; mTime = mFreq(cellfun(@(gEl) isfield(gEl,'h') ,g)>0); mFreq(mTime) = []; if ~isempty(mTime) % Pick imp. resp. gtime = cellfun(@(gEl) gEl.h, g(mTime),'UniformOutput',0); % Call the routine gskip = cellfun(@(gEl) gEl.offset ,g(mTime)); c(mTime) = comp_filterbank_td(f,gtime,a(mTime),gskip,'per'); end if ~isempty(mFreq) F=fft(f); gfreq = g(mFreq); mFreqFullL = 1:numel(gfreq); amFreqCell = mat2cell(a(mFreq,:).',size(a,2),ones(1,numel(mFreq))); mFreqBL = mFreqFullL(cellfun(@(gEl,aEl) numel(gEl)~=L || (numel(aEl)>1 && aEl(2) ~=1), gfreq,amFreqCell)>0); mFreqFullL(mFreqBL) = []; mFreqFullL = mFreq(mFreqFullL); mFreqBL = mFreq(mFreqBL); if ~isempty(mFreqFullL) G = cellfun(@(gEl) gEl.H, g(mFreqFullL),'UniformOutput',0); c(mFreqFullL) = comp_filterbank_fft(F,G,a(mFreqFullL)); end if ~isempty(mFreqBL) G = cellfun(@(gEl) gEl.H, g(mFreqBL),'UniformOutput',0); foff = cellfun(@(gEl) gEl.foff, g(mFreqBL)); realonly = cellfun(@(gEl) isfield(gEl,'realonly') && gEl.realonly, g(mFreqBL)); c(mFreqBL) = comp_filterbank_fftbl(F,G,foff,a(mFreqBL,:),realonly); end end % for mId=1:numel(mFreq) % m = mFreq(mId); % G = g{m}.H; % Lg = numel(G); % c{m}=zeros(N(m),W,classname); % % Band-limited case. % if (g{m}.foff~=0 && Lg1 % % fsuppStart = g{m}.foff; % fsuppEnd = g{m}.foff+numel(g{m}.H); % % % Partition the support to intervals of length N(m) % fsuppSidx = floor(fsuppStart/N(m)); % fsuppEidx = ceil(fsuppEnd/N(m)); % fsuppS = fsuppSidx*N(m); % fsuppE = fsuppEidx*N(m); % intNo = (fsuppE-fsuppS)/N(m); % Gtmp = zeros(intNo*N(m),1); % %Gtmp(fsuppStart-fsuppS+1:end-(fsuppE-fsuppEnd)) = G; % % fsuppRangeSmall = mod(fsuppStart:fsuppEnd-1,L)+1; % %fsuppRange = mod(fsuppS:fsuppS+intNo*N(m)-1,L)+1; % for w=1:W % interstuff = G.*F(fsuppRangeSmall,w); % Gtmp(fsuppStart-fsuppS+1:end-(fsuppE-fsuppEnd)) = interstuff; % c{m}(:,w) = ifft(sum(reshape(Gtmp,N(m),intNo),2))/a(m); % end % else % G = comp_transferfunction(g{m},L); % if size(a,2)==1 % % for w=1:W % c{m}(:,w)=ifft(sum(reshape(F(:,w).*G,N(m),a(m)),2))/a(m); % end; % else % % Fractional case % %Llarge=ceil(L/N(m)+1)*N(m); % % postpadL = ceil(max([N(m),numel(g{m}.H)])/N(m))*N(m); % foff = g{m}.foff + floor(numel(g{m}.H)/2); % amod=postpadL/N(m); % % for w=1:W % c{m}(:,w)=ifft(sum(reshape(circshift(middlepad(circshift(F(:,w).*G,-foff),postpadL),foff),N(m),amod),2))/afrac(m); % end; % end; % end; % end %end ```