So, I want to do a polyphase implementation of a filter bank (I had problems with it since the beginning and I already asked for help to the community in the past, indeed: Norm MPEG-1 Layer III (Mp3) Filter banks distortion). Thanks to the support I was able to make it work (without polyphase implementation).
Nonetheless, I tried to do all the analysis filters and synthesis filters by means of polyphase filters banks as follows:
The idea is, basically, based on the first picture, with the low pass filter prototype modulated by a cosine to make frequency shifts of the filter response to cover all the bandwidth (with 32 filters), decomposing each particular filter response into 32 polyphase branches.
(So 32 branches, obtained by means of shifting the prototype by multiplying a cosine. Each of these 32 branches is implemented by means of decomposing each analysis and synthesis filters into 32 polyphase branches).
So, once the first part works (i.e. The filter bank not implemented by means of polyphase filter banks), I do the polyphase decomposition as follows:
1. Polyphase decomposition:
h
are the modulated coefficients of each filter of the bank.hh
is the polyphase filter bank coefficients- the $i^{\rm th}$ row of the matrix represents the coefficients of the $i^{\rm th}$ filter of the polyphase bank
M
are the polyphase filter branches, 32 in our examplehh=zeros(M,length(h)/M); for l=0:1:M-1 n=l+1:M:length(h); hh(l+1,:)=h(n); end end
2. The shift ($Z^{-1}$) is performed by a function that performs as follows ("delay" is the delay to apply. e.g. if 0 samples are to be delayed, then the output shall be equal to the input):
in_data
: Input sequenceout_data
: Output sequence.delay_samp=delay+1; out_data=zeros(1,length(in_data)); out_data(delay_samp:length(in_data))=in_data(1:length(in_data)-(delay_samp-1));
3. Ok, now, I apply the filters as follows:
Analysis:
yy=zeros(branches,length(hh(1,:))+fix(length(in_signal)/branches)); for k=1:branches %1. Shift shifted_input=shift_data(in_signal,k-1); %2. Downsample temp=zeros(1,fix(length(in_signal)/branches)); downsampled_data=shifted_input(1:branches:end); temp(1:length(downsampled_data))=downsampled_data; shifted_downsampled_input=temp; %3. Filter temp=conv(hh(k,:),shifted_downsampled_input); yy(k,:)=temp; end
And Synthesis:
yy=zeros(branches,branches*(length(hh(1,:))+length(in_signal)-1)); for k=1:branches %1. Filter temp_conv=conv(hh(k,:),in_signal); %2. Upsample temp=zeros(1,length(temp_conv)*branches); temp(1:branches:end)=temp_conv;%upsample(temp,branches); %3. Shift. yy(k,:)=shift_data(temp,branches-(k-1)); end
The output with a 1KHz tone as an input:
I guess that I am making something wrong with the upsampling and downsampling processes as there are spectral replicas all over the second example, but I have no clue on what exactly is wrong.
I checked on the internet and I also checked the reference referred in the other post. I mean this book. But I think there is a problem with the way I am coding this not with the theoretical back.