# Understanding the magnitude of frequency response filterbank based on elliptic filters

I've implemented a 10-channels filterbank with octave-scaled second-order elliptic filters using the Python's library scipy.signal.

Here is the magnitude of the frequency response:

Can someone please explain to me why the response changes with increasing frequency? I was expecting each filter magnitude response similar to the high-frequency ones (more or less from 800 Hz upwards). Particularly, I was expecting a different response from the first 4 filters.

Here is the code:

import numpy as np
import matplotlib.pyplot as plt
import scipy.signal as signal

fs = 44100

# Elliptic filters
subbands = {'Band01': [50],
'Band02': [50,100],
'Band03': [100,200],
'Band04': [200,400],
'Band05': [400,800],
'Band06': [800,1600],
'Band07': [1600,3200],
'Band08': [3200,6400],
'Band09': [6400,12800],
'Band10': [12800]}

band_ticks = [10,50,100,200,400,800,1600,3200,6400,12800,22050]
labels_ticks =["0","50","100","200","400","800","1.6k","3.2k","6.4k","12.8k","22.05k"]
filters = {}
f_resp = {}
for key in subbands:
wc = [wc/(fs/2) for wc in subbands[key]]
if key == 'Band01':
filters[key] = signal.ellip(N=2,rp=3,rs=60,Wn=wc,btype='lowpass',analog=False)
elif key == 'Band10':
filters[key] = signal.ellip(N=2,rp=3,rs=60,Wn=wc,btype='highpass',analog=False)
else:
filters[key] = signal.ellip(N=2,rp=3,rs=60,Wn=wc,btype='bandpass',analog=False)
f_resp[key] = signal.freqz(filters[key][0],filters[key][1])
mag = 20*np.log10(abs(f_resp[key][1]))
freqs = f_resp[key][0]*fs/(2*np.pi)
plt.semilogx(freqs,mag,'b')
plt.ylim([-35,4])
plt.xlim([10,fs/2])
plt.grid(axis='both', linestyle='-', color='grey')
plt.xticks(ticks=band_ticks,labels=labels_ticks)
plt.xlabel('Frequency (Hz)')
plt.ylabel('Magnitude (dB)')

• Hi! Can you get the expected frequency response magnitude plot from a non elliptic filter bank design ? Give it a try, then probably it's your elliptic design parameters which causes the problem at low frequency channels. – Fat32 Jun 15 '19 at 20:58
• It looks like you're plotting logarithmic, but display linear. – a concerned citizen Jun 16 '19 at 5:47
• @Fat32 I have tried both Chebyshev and Butterworth but I get the same issue at low frequencies. I also played with several filter parameters but it does not seem to be the cause – enne Jun 18 '19 at 11:05
• @aconcernedcitizen I'm not sure I understand what you mean. Please could you explain me again? The usage of 'semilogx' is needed in order to visualise the filters, otherwise they would have been squeezed on the left side of the figure while the last two filters would have been largely visible, occupying the whole figure. This is due to the fact that the passbands increase with frequency. – enne Jun 18 '19 at 11:05
• @Alex I mean it looks like you're not plotting the same way you're calculating the frequency data. If you're calculating the frequency linearly, and plot it logarithmically, you're going to have discrepancies: the axis "crams" towards the end while being stretched towards the DC, so the resolution drops towards the origins of the X axis. – a concerned citizen Jun 18 '19 at 17:51