diff --git a/simulation/cic_filter/cic_filter_comb_main.py b/simulation/cic_filter/cic_filter_comb_main.py index ae745e9..8d2ec2d 100644 --- a/simulation/cic_filter/cic_filter_comb_main.py +++ b/simulation/cic_filter/cic_filter_comb_main.py @@ -49,10 +49,9 @@ def compare_crc_filter_combs(length: int, R: int) -> None: for coefficients in FILTERS: # Apply a comb filter to the signal. - comb_filter = _create_comb_filter_before_decimation(coefficients, R) - cic_filter_decimator = CicFilterDecimator(R=1, + cic_filter_decimator = CicFilterDecimator(R=R, N=1, - comb_filter=comb_filter) + comb_filter=coefficients) response = cic_filter_decimator.filter(delta, downsampling=False) # Plot the spectrum. diff --git a/simulation/cic_filter/cic_filter_decimator.py b/simulation/cic_filter/cic_filter_decimator.py index 94a7e08..c81950b 100644 --- a/simulation/cic_filter/cic_filter_decimator.py +++ b/simulation/cic_filter/cic_filter_decimator.py @@ -14,9 +14,11 @@ def __init__(self, R: int, N: int, comb_filter: np.ndarray = None) -> None: if comb_filter is None: comb_filter = np.ones(1) - self.comb_filter = comb_filter + self.comb_filter = comb_filter.astype(np.float64) self.num_comb_filter_taps = len(comb_filter) - self.comb_filter_diff = self._create_comb_filter_diff(comb_filter) + # Scale the filter to its length. + self.comb_filter /= np.mean(self.comb_filter) + self.comb_filter_diff = self._create_comb_filter_diff(self.comb_filter) def filter(self, signal: np.ndarray,