"For a real input the mixer can either downconvert the positive or the negative frequeny band. Convention is to downconvert the positive frequency band [2, 3]. This leads to using IDFT in the analysis DFT filterbank and IDFT in the synthesis filterbank [2, 3]. By using IDFT(x) = DFT(fold(x)) it is possible to change to a DFT in the analysis filterbank, this corresponds to using a clockwise commutator [3] and type 3 polyphase filter structure [4].\n",
"\n",
"Sampling and anlogue signal yields the low pass spectrum and its replicas around multiples of fs. This endles replication is why the discrete samples can represent and anlogue signal. Downsampling of the digitized signal again causes aliasing of all replicas to baseband. Normally the interest is in the baseband replica. However using a BPF instead of an LPF any of the replicas can be selected for baseband. Similar for upsampling (synthesis) the baseband signal can be upconverted to the wanted replica by using a BPF instead of an LPF. The first step in upsampling is inserting zeros to increase the sample rate, without changing the digital signal. However this increased sample rate does make the replicas available in the digital domain.\n",
"\n",
"With a single channel mixer the downsampling by M implies that at the downsampled rate there is processing power to process M - 1 more channels. This fits a critically sampled DFT filterbank with K = M. Whereby the DFT should typically be an FFT.\n",
"\n",
"The single channel mixer and DFT filterbank can share a prototype LPF for all channels, because the downsampling and upsampling performs the demodulation and modulation, to and from baseband at 0 Hz. When Ros = K / M > 1 then there remains and offset frequency that is compensated by a phasor term W_K^(knM). With the DFT filterbank this phasor that can be implemented as a circular shift (modulo K) at the input of the DFT. \n",
"\n",
"For perfect reconstruction by an analysis-synthesis filterbank the aliasing must cancel and distortion must be zero. Considering only adjancent channels is called pseudo QMF (two-channel), for the other channels the stop band attenuation suppresses the crosstalk. For zero distortion the transfer function of the channels must be power complementary. With an DFT filterbank (= complex modulated filterbank) the aliasing does not cancel. For critically sampled filterbanks this leads to the Modified DFT (MDFT) or Cosine modulated fiterbank [4]. By using oversampling the aliasing can be avoided. Hence using some oversampling and power complementary channel filters the oversampled DFT filterbank can achieve almost perfect reconstruction.\n",
"\n",
"Remarks:\n",
"* With oversampling the subband bandwidth can be increased to have a flat reponse up to fsub / 2. The transition band is then from fsub / 2 to Ros * fsub / 2 The subband filter is then not power complementary (around fsub / 2), so the subbands are not suitable for synthesis. It may be feasible achieve almost perfect reconstruction by first removing the transition band from the subbands, by separating the subbands into fine channels using a DFT, then zero the fine channels of the transistion band, and then synthesize the subband using IDFT.\n",
"\n",
"Features:\n",
"* Use full rate model of single channel down converter and up converter as expected exact golden reference result for the efficient polyphase implementation and WOLA implementation and refBunton.\n",
"* Use SNR of input and difference with time aligned reconstructed output, to show that perfect reconstruction depends on the pass band gain being one and the stopband gain approaching zero. Hence the SNR for center bin sine wave inputs improves, towards perfect reconstruction, when Ntaps is increased.\n",
"* Use analysis DFT filterbank and synthesis IDFT filterbank and verify that it yields the same result as with the single channel pipeline.\n",
"* Compare model with PFB reconstruction by reconstruct.m of John Bunton for Ntaps = 12 and Ndft = 192, using refBunton.\n",
"* Support Ncoefs <= Ndelays = Ntaps * Ndft, to verify correct implementation of coefs and delay line\n",
"* Support WG with offset bin center frequency or with noise, to verify that result is correct for any frequency, not only the center frequency\n",
"* Support Ncoefs <= Ndelays = Ntaps * Ndft, to verify correct implementation of coefs and delay line.\n",
"* Support WG with offset bin center frequency (e.g. wgSub = 1.5) or with noise (via SNR_WG_dB < 100), to verify that result is correct for any frequency, not only the center frequency.\n",
"* Support refBunton with asymmetrical hPrototype, to verify correct order implementation of coefs in analysis and synthesis. The refBunton has slightly asymmetrical hPrototype due to that it uses interpolation to increase the number of coefficient after designing the FIR filter with fircls1().\n",
"\n",
"References:\n",
"1. dsp_study_erko, summary of DSP books\n",
"2. chapter 7 in [CROCHIERE]\n",
"3. chapter 6 downconverter, 7 upconverter, 9 filterbank in [HARRIS]\n",
* Use multirate processing to implement a single channel mixer
* Extend single channel mixer to DFT filterbank
Description:
For a real input the mixer can either downconvert the positive or the negative frequeny band. Convention is to downconvert the positive frequency band [2, 3]. This leads to using IDFT in the analysis DFT filterbank and IDFT in the synthesis filterbank [2, 3]. By using IDFT(x) = DFT(fold(x)) it is possible to change to a DFT in the analysis filterbank, this corresponds to using a clockwise commutator [3] and type 3 polyphase filter structure [4].
Sampling and anlogue signal yields the low pass spectrum and its replicas around multiples of fs. This endles replication is why the discrete samples can represent and anlogue signal. Downsampling of the digitized signal again causes aliasing of all replicas to baseband. Normally the interest is in the baseband replica. However using a BPF instead of an LPF any of the replicas can be selected for baseband. Similar for upsampling (synthesis) the baseband signal can be upconverted to the wanted replica by using a BPF instead of an LPF. The first step in upsampling is inserting zeros to increase the sample rate, without changing the digital signal. However this increased sample rate does make the replicas available in the digital domain.
With a single channel mixer the downsampling by M implies that at the downsampled rate there is processing power to process M - 1 more channels. This fits a critically sampled DFT filterbank with K = M. Whereby the DFT should typically be an FFT.
The single channel mixer and DFT filterbank can share a prototype LPF for all channels, because the downsampling and upsampling performs the demodulation and modulation, to and from baseband at 0 Hz. When Ros = K / M > 1 then there remains and offset frequency that is compensated by a phasor term W_K^(knM). With the DFT filterbank this phasor that can be implemented as a circular shift (modulo K) at the input of the DFT.
For perfect reconstruction by an analysis-synthesis filterbank the aliasing must cancel and distortion must be zero. Considering only adjancent channels is called pseudo QMF (two-channel), for the other channels the stop band attenuation suppresses the crosstalk. For zero distortion the transfer function of the channels must be power complementary. With an DFT filterbank (= complex modulated filterbank) the aliasing does not cancel. For critically sampled filterbanks this leads to the Modified DFT (MDFT) or Cosine modulated fiterbank [4]. By using oversampling the aliasing can be avoided. Hence using some oversampling and power complementary channel filters the oversampled DFT filterbank can achieve almost perfect reconstruction.
Remarks:
* With oversampling the subband bandwidth can be increased to have a flat reponse up to fsub / 2. The transition band is then from fsub / 2 to Ros * fsub / 2 The subband filter is then not power complementary (around fsub / 2), so the subbands are not suitable for synthesis. It may be feasible achieve almost perfect reconstruction by first removing the transition band from the subbands, by separating the subbands into fine channels using a DFT, then zero the fine channels of the transistion band, and then synthesize the subband using IDFT.
Features:
* Use full rate model of single channel down converter and up converter as expected exact golden reference result for the efficient polyphase implementation and WOLA implementation and refBunton.
* Use SNR of input and difference with time aligned reconstructed output, to show that perfect reconstruction depends on the pass band gain being one and the stopband gain approaching zero. Hence the SNR for center bin sine wave inputs improves, towards perfect reconstruction, when Ntaps is increased.
* Use analysis DFT filterbank and synthesis IDFT filterbank and verify that it yields the same result as with the single channel pipeline.
* Compare model with PFB reconstruction by reconstruct.m of John Bunton for Ntaps = 12 and Ndft = 192, using refBunton.
* Support Ncoefs <= Ndelays = Ntaps * Ndft, to verify correct implementation of coefs and delay line
* Support WG with offset bin center frequency or with noise, to verify that result is correct for any frequency, not only the center frequency
* Support Ncoefs <= Ndelays = Ntaps * Ndft, to verify correct implementation of coefs and delay line.
* Support WG with offset bin center frequency (e.g. wgSub = 1.5) or with noise (via SNR_WG_dB < 100), to verify that result is correct for any frequency, not only the center frequency.
* Support refBunton with asymmetrical hPrototype, to verify correct order implementation of coefs in analysis and synthesis. The refBunton has slightly asymmetrical hPrototype due to that it uses interpolation to increase the number of coefficient after designing the FIR filter with fircls1().
References:
1. dsp_study_erko, summary of DSP books
2. chapter 7 in [CROCHIERE]
3. chapter 6 downconverter, 7 upconverter, 9 filterbank in [HARRIS]
## 3.2 LO at downsampled rate: BPF --> D --> LOdown
Use BPF centered at kLo (is LPF shifted by +kLo) still at sample rate, then downsample and do down conversion from kLo to baseband at downsampled rate [HARRIS Fig 6.7].
If Ndown = Ndft, then D * w_k = D * 2pi * k / Ndft is multiple of 2pi, so then LOdown = 1.
%% Cell type:code id:b8036250 tags:
``` python
# LO --> D --> LOdown == loD
#
# LOdown = exp(-j * D w_k * m) = loD
# = exp(-j * 2 pi D / Ndft * k * m)
LOdown = down(LO, Ndown)
D_w_k = Ndown * w_k
loD = np.exp(-1j * D_w_k * m_i)
print('Ndft =', Ndft)
print('Ndown =', Ndown)
print('w_k =', w_k)
print('D_w_k =', D_w_k)
print('')
# Verify that LO data rotates with w_k and LO down with D * w_k rad/s
result = np.all(np.isclose(LOdown, loD))
if not result:
plt.plot(m_sub, LOdown.real, 'r-')
plt.plot(m_sub, LOdown.imag, 'r--')
plt.plot(m_sub, loD.real, 'g-')
plt.plot(m_sub, loD.imag, 'g--')
verify_result(result, ': LOdown == LoD', enExit)
```
%% Output
Ndft = 192
Ndown = 144
w_k = 0.06544984694978735
D_w_k = 9.42477796076938
PASSED: LOdown == LoD
%% Cell type:code id:0663df66 tags:
``` python
# Verify that LOdown == 1 when Ndown == Ndft
if Ndown == Ndft:
result = np.all(np.isclose(LOdown, 1.0))
if not result:
plt.plot(m_sub, LOdown.real, 'r-')
plt.plot(m_sub, LOdown.imag, 'r--')
verify_result(result, ': LOdown == 1, for Ros = 1', enExit)
# result is True for any Ndft, Ndown, because LOdown is in equation of yBpfDownLo
result = np.all(np.isclose(yDown, yBpfDownLo))
verify_result(result, ': yDown == yBpfDownLo, for Ros >= 1', enExit)
```
%% Output
PASSED: yDown == yBpfDownLo, for Ros >= 1
%% Cell type:markdown id:589b5e1e tags:
## 3.3 BPF and LO at downsampled rate: D --> poly BPF --> LOdown
Partition the BPF FIR filter H(z) in Ndown polyphases to have Hp(z^Ndown) per polyphase branch p, so that the down sampling can be done before the BPF by using the Noble identity.
# 4.2 LOp at downsampled rate: LOpDown --> U --> BPF
Use LOp at downsampled rate. Do upconversion by U from baseband to kLo at sampled rate. Use BPF centered at kLo (is LPF shifted by +kLo) at sample rate.
If Nup = Ndft, then U w_k = U 2pi * k / Ndft is multiple of 2pi, so then LOpDown = 1.
%% Cell type:code id:7049249e tags:
``` python
# LOpDown --> U --> LOp
#
# LOpD = exp(-j * U w_k * m)
# = exp(-j * 2 pi U / Ndft * k * m)
LOpDown = down(LOp, Nup)
U_w_k = Nup * w_k
LOpD = np.exp(1j * U_w_k * m_i)
# Verify that LOp rotates with w_k and LOpDown with U * w_k rad/s
# result is True for any Ndft, Ndown, because LOdown is in equation of yBpfDownLo
result = np.all(np.isclose(yrUpLpfLo, yrLoUpBpf))
if not result:
plt.plot(yrUpLpfLo, 'r')
plt.plot(yrLoUpBpf, 'b')
#plt.xlim([0, 850])
verify_result(result, ': yrUpLpfLo == yrLoUpBpf, for Ros >= 1', enExit)
```
%% Output
PASSED: yrUpLpfLo == yrLoUpBpf, for Ros >= 1
%% Cell type:markdown id:2830cdc7 tags:
# 4.3 BPF and LOp at downsampled rate: LOpDown --> poly BPF --> U
Partition the BPF FIR filter H(z) in Nup polyphases to have Hp(z^Nup) per polyphase branch p, so that the upsampling can be done after the BPF by using the Noble identity.
yrLoBpfUp = ycLoBpfUp.real * nofSsb # add negative bin -kLo to make real
result = np.all(np.isclose(yrUpLpfLo, yrLoBpfUp))
if not result:
plt.plot(n_sub, yrUpLpfLo, 'g.-')
plt.plot(n_sub, yrLoBpfUp, 'r.-')
plt.xlim([12,24])
verify_result(result, ': yrUpLpfLo == yrLoBpfUp, for Ros >= 1', enExit)
```
%% Cell type:markdown id:ee9daf9f tags:
# 5 Compare with DFT filterbank
Can use 'cw' or 'ccw' independently for analysis and synthesis PFB, because with fold() the IDFT can be expressed as a DFT and vice versa. However to have back to back DFT - IDFT in pipeline, use analysis 'cw' and synthesis 'ccw' [CROCHIERE 7.2.3].
%% Cell type:code id:4b55557c tags:
``` python
# Select analysis filterbank
aStructure = 'wola'
aStructure = 'pfs'
aCommutator = 'cw'
# Select synthesis filterbank
sStructure = 'wola'
sCommutator = 'ccw'
```
%% Cell type:code id:abb548f6 tags:
``` python
# Parameters
print('wgSub = %f' % wgSub)
print('kLo = %d' % kLo)
print('Ndft = %d' % Ndft)
print('Ndown = %d' % Ndown)
```
%% Output
wgSub = 1.500000
kLo = 2
Ndft = 192
Ndown = 144
%% Cell type:markdown id:d8bb436d tags:
# 5.1 Analysis
%% Cell type:code id:a6de2be1 tags:
``` python
# Verify that different analysis_dft_filterbank() structures yield exactly the same