Bugfixes and improvements in Filters
This commit is contained in:
parent
1748daab4c
commit
2270a297cc
@ -30,7 +30,7 @@ class FilterBankDesigner:
|
||||
fs: Sampling frequency [Hz]
|
||||
"""
|
||||
# Default FIR filter length
|
||||
firFilterLength = 256 # Filter order
|
||||
self.firFilterLength = 256 # Filter order
|
||||
self.fs = fs
|
||||
|
||||
# Constant G, according to standard
|
||||
@ -99,8 +99,8 @@ class FilterBankDesigner:
|
||||
Returns:
|
||||
filter: 1D ndarray with FIR filter coefficients
|
||||
"""
|
||||
assert np.isclose(fs, self.fs), "Invalid sampling frequency"
|
||||
fd = fs / np.prod(self.firDecimation(x))
|
||||
assert np.isclose(self.fs, 48000), "Invalid sampling frequency"
|
||||
fd = self.fs / np.prod(self.firDecimation(x))
|
||||
|
||||
# For designing the filter, the lower and upper frequencies need to be
|
||||
# slightly adjusted to fall within the limits for a class 1 filter.
|
||||
|
@ -60,6 +60,8 @@ class AvStream:
|
||||
# Determine highest input channel number
|
||||
channelconfigs = daqconfig.en_input_channels
|
||||
|
||||
self.channel_names = []
|
||||
|
||||
self.sensitivity = self.daqconfig.getSensitivities()
|
||||
|
||||
rtaudio_inputparams = None
|
||||
@ -79,6 +81,7 @@ class AvStream:
|
||||
for i, channelconfig in enumerate(channelconfigs):
|
||||
if channelconfig.channel_enabled:
|
||||
self.nchannels = i+1
|
||||
self.channel_names.append(channelconfig.channel_name)
|
||||
rtaudio_inputparams = {'deviceid': device.index,
|
||||
'nchannels': self.nchannels,
|
||||
'firstchannel': 0}
|
||||
|
@ -82,9 +82,9 @@ class TimeWeighting:
|
||||
fast = (0.125, 'Fast (0.125 s)')
|
||||
slow = (1.0, 'Slow (1.0 s)')
|
||||
tens = (10, '10 s')
|
||||
infinite = (np.Inf, 'Infinite')
|
||||
infinite = (np.Inf, 'Infinite (Leq)')
|
||||
types = (none, uufast, ufast, fast, slow, tens, infinite)
|
||||
default = 2
|
||||
default = 3
|
||||
|
||||
@staticmethod
|
||||
def fillComboBox(cb):
|
||||
|
@ -115,7 +115,7 @@ class FirFilterBank:
|
||||
# These are the filters that do not require lasp_decimation
|
||||
# prior to filtering
|
||||
nominals_txt.append(self.designer.nominal_txt(x))
|
||||
firs[:, i] = self.designer.createFirFilter(fs, x)
|
||||
firs[:, i] = self.designer.createFirFilter(x)
|
||||
filterbank = {'fb': pyxFilterBank(firs, 1024),
|
||||
'xs': xs,
|
||||
'nominals': nominals_txt}
|
||||
@ -203,7 +203,7 @@ class FirOctaveFilterBank(FirFilterBank):
|
||||
"""
|
||||
|
||||
def __init__(self, fs, xmin, xmax):
|
||||
self.designer = OctaveBankDesigner()
|
||||
self.designer = OctaveBankDesigner(fs)
|
||||
FirFilterBank.__init__(self, fs, xmin, xmax)
|
||||
|
||||
|
||||
@ -231,6 +231,7 @@ class SosFilterBank:
|
||||
self.fs = fs
|
||||
self.xs = list(range(xmin, xmax + 1))
|
||||
nfilt = len(self.xs)
|
||||
self.nfilt = nfilt
|
||||
self._fb = pyxSosFilterBank(nfilt, 5)
|
||||
for i, x in enumerate(self.xs):
|
||||
sos = self.designer.createSOSFilter(x)
|
||||
@ -279,7 +280,7 @@ class SosThirdOctaveFilterBank(SosFilterBank):
|
||||
band.
|
||||
"""
|
||||
|
||||
def __init__(self, fs, xmin, xmax):
|
||||
def __init__(self, fs, xmin=None, xmax=None):
|
||||
"""
|
||||
Initialize a second order sections filterbank.
|
||||
|
||||
@ -289,6 +290,10 @@ class SosThirdOctaveFilterBank(SosFilterBank):
|
||||
xmax: Maximum value for the bands
|
||||
"""
|
||||
self.designer = ThirdOctaveBankDesigner(fs)
|
||||
if xmin is None:
|
||||
xmin = self.designer.xs[0]
|
||||
if xmax is None:
|
||||
xmax = self.designer.xs[-1]
|
||||
SosFilterBank.__init__(self, fs, xmin, xmax)
|
||||
|
||||
|
||||
@ -298,16 +303,20 @@ class SosOctaveFilterBank(SosFilterBank):
|
||||
band.
|
||||
"""
|
||||
|
||||
def __init__(self, fs, xmin, xmax):
|
||||
def __init__(self, fs, xmin=None, xmax=None):
|
||||
"""
|
||||
Initialize a second order sections filterbank.
|
||||
|
||||
Args:
|
||||
fs: Sampling frequency [Hz]
|
||||
xmin: Minimum value for the bands
|
||||
xmax: Maximum value for the bands
|
||||
xmin: Minimum value for the bands, if not specified, use minimum
|
||||
xmax: Maximum value for the bands, if not specified, use maximum
|
||||
"""
|
||||
self.designer = OctaveBankDesigner(fs)
|
||||
if xmin is None:
|
||||
xmin = self.designer.xs[0]
|
||||
if xmax is None:
|
||||
xmax = self.designer.xs[-1]
|
||||
SosFilterBank.__init__(self, fs, xmin, xmax)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user