From 70ee2b878b16d0c77cd8b50409d8e91ad2c5f426 Mon Sep 17 00:00:00 2001 From: ar1st0crat Date: Sat, 21 Aug 2021 18:23:04 +0300 Subject: [PATCH] final fixes in Butterworth/Bessel/Chebyshev/Elliptic filters --- NWaves/Filters/Bessel/BandPassFilter.cs | 2 +- NWaves/Filters/Bessel/BandStopFilter.cs | 3 +-- NWaves/Filters/Bessel/HighPassFilter.cs | 3 +-- NWaves/Filters/Bessel/LowPassFilter.cs | 2 +- NWaves/Filters/Butterworth/BandPassFilter.cs | 2 +- NWaves/Filters/Butterworth/BandStopFilter.cs | 2 +- NWaves/Filters/Butterworth/HighPassFilter.cs | 2 +- NWaves/Filters/Butterworth/LowPassFilter.cs | 2 +- NWaves/Filters/ChebyshevI/BandPassFilter.cs | 4 ++-- NWaves/Filters/ChebyshevI/BandStopFilter.cs | 4 ++-- NWaves/Filters/ChebyshevI/HighPassFilter.cs | 4 ++-- NWaves/Filters/ChebyshevI/LowPassFilter.cs | 4 ++-- NWaves/Filters/ChebyshevII/BandPassFilter.cs | 4 ++-- NWaves/Filters/ChebyshevII/BandStopFilter.cs | 4 ++-- NWaves/Filters/ChebyshevII/HighPassFilter.cs | 4 ++-- NWaves/Filters/ChebyshevII/LowPassFilter.cs | 4 ++-- NWaves/Filters/Elliptic/BandPassFilter.cs | 4 ++-- NWaves/Filters/Elliptic/BandStopFilter.cs | 4 ++-- NWaves/Filters/Elliptic/HighPassFilter.cs | 4 ++-- NWaves/Filters/Elliptic/LowPassFilter.cs | 4 ++-- 20 files changed, 32 insertions(+), 34 deletions(-) diff --git a/NWaves/Filters/Bessel/BandPassFilter.cs b/NWaves/Filters/Bessel/BandPassFilter.cs index 10b507d..9690d0f 100644 --- a/NWaves/Filters/Bessel/BandPassFilter.cs +++ b/NWaves/Filters/Bessel/BandPassFilter.cs @@ -35,6 +35,6 @@ private static TransferFunction MakeTf(double f1, double f2, int order) /// /// /// - public void Change(double f1, double f2) => Change(MakeTf(f1, f2, _b.Length / 2)); + public void Change(double f1, double f2) => Change(MakeTf(f1, f2, (_a.Length - 1) / 2)); } } diff --git a/NWaves/Filters/Bessel/BandStopFilter.cs b/NWaves/Filters/Bessel/BandStopFilter.cs index c973d80..4f6da83 100644 --- a/NWaves/Filters/Bessel/BandStopFilter.cs +++ b/NWaves/Filters/Bessel/BandStopFilter.cs @@ -1,6 +1,5 @@ using NWaves.Filters.Base; using NWaves.Filters.Fda; -using System; namespace NWaves.Filters.Bessel { @@ -36,6 +35,6 @@ private static TransferFunction MakeTf(double f1, double f2, int order) /// /// /// - public void Change(double f1, double f2) => Change(MakeTf(f1, f2, _b.Length / 2)); + public void Change(double f1, double f2) => Change(MakeTf(f1, f2, (_a.Length - 1) / 2)); } } diff --git a/NWaves/Filters/Bessel/HighPassFilter.cs b/NWaves/Filters/Bessel/HighPassFilter.cs index 03e63f8..c684246 100644 --- a/NWaves/Filters/Bessel/HighPassFilter.cs +++ b/NWaves/Filters/Bessel/HighPassFilter.cs @@ -1,6 +1,5 @@ using NWaves.Filters.Base; using NWaves.Filters.Fda; -using System; namespace NWaves.Filters.Bessel { @@ -34,6 +33,6 @@ private static TransferFunction MakeTf(double freq, int order) /// Change filter coeffs online /// /// - public void Change(double freq) => Change(MakeTf(freq, _b.Length)); + public void Change(double freq) => Change(MakeTf(freq, _a.Length - 1)); } } diff --git a/NWaves/Filters/Bessel/LowPassFilter.cs b/NWaves/Filters/Bessel/LowPassFilter.cs index f079962..140b3f5 100644 --- a/NWaves/Filters/Bessel/LowPassFilter.cs +++ b/NWaves/Filters/Bessel/LowPassFilter.cs @@ -33,6 +33,6 @@ private static TransferFunction MakeTf(double freq, int order) /// Change filter coeffs online /// /// - public void Change(double freq) => Change(MakeTf(freq, _b.Length)); + public void Change(double freq) => Change(MakeTf(freq, _a.Length - 1)); } } diff --git a/NWaves/Filters/Butterworth/BandPassFilter.cs b/NWaves/Filters/Butterworth/BandPassFilter.cs index b1b1b13..5e05a16 100644 --- a/NWaves/Filters/Butterworth/BandPassFilter.cs +++ b/NWaves/Filters/Butterworth/BandPassFilter.cs @@ -35,6 +35,6 @@ private static TransferFunction MakeTf(double f1, double f2, int order) /// /// /// - public void Change(double f1, double f2) => Change(MakeTf(f1, f2, _b.Length / 2)); + public void Change(double f1, double f2) => Change(MakeTf(f1, f2, (_a.Length - 1) / 2)); } } diff --git a/NWaves/Filters/Butterworth/BandStopFilter.cs b/NWaves/Filters/Butterworth/BandStopFilter.cs index d43f748..50ef091 100644 --- a/NWaves/Filters/Butterworth/BandStopFilter.cs +++ b/NWaves/Filters/Butterworth/BandStopFilter.cs @@ -35,6 +35,6 @@ private static TransferFunction MakeTf(double f1, double f2, int order) /// /// /// - public void Change(double f1, double f2) => Change(MakeTf(f1, f2, _b.Length / 2)); + public void Change(double f1, double f2) => Change(MakeTf(f1, f2, (_a.Length - 1) / 2)); } } diff --git a/NWaves/Filters/Butterworth/HighPassFilter.cs b/NWaves/Filters/Butterworth/HighPassFilter.cs index e1889c5..8f0e88f 100644 --- a/NWaves/Filters/Butterworth/HighPassFilter.cs +++ b/NWaves/Filters/Butterworth/HighPassFilter.cs @@ -32,6 +32,6 @@ private static TransferFunction MakeTf(double freq, int order) /// Change filter coeffs online /// /// - public void Change(double freq) => Change(MakeTf(freq, _b.Length)); + public void Change(double freq) => Change(MakeTf(freq, _a.Length - 1)); } } diff --git a/NWaves/Filters/Butterworth/LowPassFilter.cs b/NWaves/Filters/Butterworth/LowPassFilter.cs index 386708f..e1c4d68 100644 --- a/NWaves/Filters/Butterworth/LowPassFilter.cs +++ b/NWaves/Filters/Butterworth/LowPassFilter.cs @@ -32,6 +32,6 @@ private static TransferFunction MakeTf(double freq, int order) /// Change filter coeffs online /// /// - public void Change(double freq) => Change(MakeTf(freq, _b.Length)); + public void Change(double freq) => Change(MakeTf(freq, _a.Length - 1)); } } diff --git a/NWaves/Filters/ChebyshevI/BandPassFilter.cs b/NWaves/Filters/ChebyshevI/BandPassFilter.cs index ba590cb..f38c0d1 100644 --- a/NWaves/Filters/ChebyshevI/BandPassFilter.cs +++ b/NWaves/Filters/ChebyshevI/BandPassFilter.cs @@ -6,7 +6,7 @@ namespace NWaves.Filters.ChebyshevI /// /// Band-pass Chebyshev-I filter /// - public class BandPassFilter : IirFilter + public class BandPassFilter : ZiFilter { /// /// Constructor @@ -36,6 +36,6 @@ private static TransferFunction MakeTf(double f1, double f2, int order, double r /// /// /// - public void Change(double f1, double f2, double ripple = 0.1) => Change(MakeTf(f1, f2, _b.Length / 2, ripple)); + public void Change(double f1, double f2, double ripple = 0.1) => Change(MakeTf(f1, f2, (_a.Length - 1) / 2, ripple)); } } diff --git a/NWaves/Filters/ChebyshevI/BandStopFilter.cs b/NWaves/Filters/ChebyshevI/BandStopFilter.cs index e6798f7..181e69c 100644 --- a/NWaves/Filters/ChebyshevI/BandStopFilter.cs +++ b/NWaves/Filters/ChebyshevI/BandStopFilter.cs @@ -6,7 +6,7 @@ namespace NWaves.Filters.ChebyshevI /// /// Band-stop Chebyshev-I filter /// - public class BandStopFilter : IirFilter + public class BandStopFilter : ZiFilter { /// /// Constructor @@ -36,6 +36,6 @@ private static TransferFunction MakeTf(double f1, double f2, int order, double r /// /// /// - public void Change(double f1, double f2, double ripple = 0.1) => Change(MakeTf(f1, f2, _b.Length / 2, ripple)); + public void Change(double f1, double f2, double ripple = 0.1) => Change(MakeTf(f1, f2, (_a.Length - 1) / 2, ripple)); } } diff --git a/NWaves/Filters/ChebyshevI/HighPassFilter.cs b/NWaves/Filters/ChebyshevI/HighPassFilter.cs index c151038..8dc7e29 100644 --- a/NWaves/Filters/ChebyshevI/HighPassFilter.cs +++ b/NWaves/Filters/ChebyshevI/HighPassFilter.cs @@ -6,7 +6,7 @@ namespace NWaves.Filters.ChebyshevI /// /// High-pass Chebyshev-I filter /// - public class HighPassFilter : IirFilter + public class HighPassFilter : ZiFilter { /// /// Constructor @@ -34,6 +34,6 @@ private static TransferFunction MakeTf(double freq, int order, double ripple = 0 /// /// /// - public void Change(double freq, double ripple = 0.1) => Change(MakeTf(freq, _b.Length, ripple)); + public void Change(double freq, double ripple = 0.1) => Change(MakeTf(freq, _a.Length - 1, ripple)); } } diff --git a/NWaves/Filters/ChebyshevI/LowPassFilter.cs b/NWaves/Filters/ChebyshevI/LowPassFilter.cs index e54fa3b..18abe72 100644 --- a/NWaves/Filters/ChebyshevI/LowPassFilter.cs +++ b/NWaves/Filters/ChebyshevI/LowPassFilter.cs @@ -6,7 +6,7 @@ namespace NWaves.Filters.ChebyshevI /// /// Low-pass Chebyshev-I filter /// - public class LowPassFilter : IirFilter + public class LowPassFilter : ZiFilter { /// /// Constructor @@ -34,6 +34,6 @@ private static TransferFunction MakeTf(double freq, int order, double ripple = 0 /// /// /// - public void Change(double freq, double ripple = 0.1) => Change(MakeTf(freq, _b.Length, ripple)); + public void Change(double freq, double ripple = 0.1) => Change(MakeTf(freq, _a.Length - 1, ripple)); } } diff --git a/NWaves/Filters/ChebyshevII/BandPassFilter.cs b/NWaves/Filters/ChebyshevII/BandPassFilter.cs index db7e5a0..7759cc1 100644 --- a/NWaves/Filters/ChebyshevII/BandPassFilter.cs +++ b/NWaves/Filters/ChebyshevII/BandPassFilter.cs @@ -6,7 +6,7 @@ namespace NWaves.Filters.ChebyshevII /// /// Band-pass Chebyshev-II filter /// - public class BandPassFilter : IirFilter + public class BandPassFilter : ZiFilter { /// /// Constructor @@ -38,6 +38,6 @@ private static TransferFunction MakeTf(double freq1, double freq2, int order, do /// /// /// - public void Change(double f1, double f2, double ripple = 0.1) => Change(MakeTf(f1, f2, _b.Length / 2, ripple)); + public void Change(double f1, double f2, double ripple = 0.1) => Change(MakeTf(f1, f2, (_a.Length - 1) / 2, ripple)); } } diff --git a/NWaves/Filters/ChebyshevII/BandStopFilter.cs b/NWaves/Filters/ChebyshevII/BandStopFilter.cs index 53e4bf1..849ebb7 100644 --- a/NWaves/Filters/ChebyshevII/BandStopFilter.cs +++ b/NWaves/Filters/ChebyshevII/BandStopFilter.cs @@ -6,7 +6,7 @@ namespace NWaves.Filters.ChebyshevII /// /// Band-stop Chebyshev-II filter /// - public class BandStopFilter : IirFilter + public class BandStopFilter : ZiFilter { /// /// Constructor @@ -38,6 +38,6 @@ private static TransferFunction MakeTf(double freq1, double freq2, int order, do /// /// /// - public void Change(double f1, double f2, double ripple = 0.1) => Change(MakeTf(f1, f2, _b.Length / 2, ripple)); + public void Change(double f1, double f2, double ripple = 0.1) => Change(MakeTf(f1, f2, (_a.Length - 1) / 2, ripple)); } } diff --git a/NWaves/Filters/ChebyshevII/HighPassFilter.cs b/NWaves/Filters/ChebyshevII/HighPassFilter.cs index 85a5f93..91528bf 100644 --- a/NWaves/Filters/ChebyshevII/HighPassFilter.cs +++ b/NWaves/Filters/ChebyshevII/HighPassFilter.cs @@ -6,7 +6,7 @@ namespace NWaves.Filters.ChebyshevII /// /// High-pass Chebyshev-II filter /// - public class HighPassFilter : IirFilter + public class HighPassFilter : ZiFilter { /// /// Constructor @@ -36,6 +36,6 @@ private static TransferFunction MakeTf(double freq, int order, double ripple = 0 /// /// /// - public void Change(double freq, double ripple = 0.1) => Change(MakeTf(freq, _b.Length, ripple)); + public void Change(double freq, double ripple = 0.1) => Change(MakeTf(freq, _a.Length - 1, ripple)); } } diff --git a/NWaves/Filters/ChebyshevII/LowPassFilter.cs b/NWaves/Filters/ChebyshevII/LowPassFilter.cs index a1dbc9c..4a01c45 100644 --- a/NWaves/Filters/ChebyshevII/LowPassFilter.cs +++ b/NWaves/Filters/ChebyshevII/LowPassFilter.cs @@ -6,7 +6,7 @@ namespace NWaves.Filters.ChebyshevII /// /// Low-pass Chebyshev-II filter /// - public class LowPassFilter : IirFilter + public class LowPassFilter : ZiFilter { /// /// Constructor @@ -36,6 +36,6 @@ private static TransferFunction MakeTf(double freq, int order, double ripple = 0 /// /// /// - public void Change(double freq, double ripple = 0.1) => Change(MakeTf(freq, _b.Length, ripple)); + public void Change(double freq, double ripple = 0.1) => Change(MakeTf(freq, _a.Length - 1, ripple)); } } diff --git a/NWaves/Filters/Elliptic/BandPassFilter.cs b/NWaves/Filters/Elliptic/BandPassFilter.cs index be9039d..f38546f 100644 --- a/NWaves/Filters/Elliptic/BandPassFilter.cs +++ b/NWaves/Filters/Elliptic/BandPassFilter.cs @@ -3,7 +3,7 @@ namespace NWaves.Filters.Elliptic { - public class BandPassFilter : IirFilter + public class BandPassFilter : ZiFilter { /// /// Constructor @@ -43,7 +43,7 @@ private static TransferFunction MakeTf(double freq1, double freq2, int order, do /// public void Change(double freq1, double freq2, double ripplePass = 1, double rippleStop = 20) { - Change(MakeTf(freq1, freq2, _b.Length / 2, ripplePass, rippleStop)); + Change(MakeTf(freq1, freq2, (_a.Length - 1) / 2, ripplePass, rippleStop)); } } } diff --git a/NWaves/Filters/Elliptic/BandStopFilter.cs b/NWaves/Filters/Elliptic/BandStopFilter.cs index 5b65e6e..85ebe48 100644 --- a/NWaves/Filters/Elliptic/BandStopFilter.cs +++ b/NWaves/Filters/Elliptic/BandStopFilter.cs @@ -3,7 +3,7 @@ namespace NWaves.Filters.Elliptic { - public class BandStopFilter : IirFilter + public class BandStopFilter : ZiFilter { /// /// Constructor @@ -43,7 +43,7 @@ private static TransferFunction MakeTf(double freq1, double freq2, int order, do /// public void Change(double freq1, double freq2, double ripplePass = 1, double rippleStop = 20) { - Change(MakeTf(freq1, freq2, _b.Length / 2, ripplePass, rippleStop)); + Change(MakeTf(freq1, freq2, (_a.Length - 1) / 2, ripplePass, rippleStop)); } } } diff --git a/NWaves/Filters/Elliptic/HighPassFilter.cs b/NWaves/Filters/Elliptic/HighPassFilter.cs index f81a0c3..a7665da 100644 --- a/NWaves/Filters/Elliptic/HighPassFilter.cs +++ b/NWaves/Filters/Elliptic/HighPassFilter.cs @@ -3,7 +3,7 @@ namespace NWaves.Filters.Elliptic { - public class HighPassFilter : IirFilter + public class HighPassFilter : ZiFilter { /// /// Constructor @@ -40,7 +40,7 @@ private static TransferFunction MakeTf(double freq, int order, double ripplePass /// public void Change(double freq, double ripplePass = 1, double rippleStop = 20) { - Change(MakeTf(freq, _b.Length, ripplePass, rippleStop)); + Change(MakeTf(freq, _a.Length - 1, ripplePass, rippleStop)); } } } diff --git a/NWaves/Filters/Elliptic/LowPassFilter.cs b/NWaves/Filters/Elliptic/LowPassFilter.cs index 98b49aa..2f37881 100644 --- a/NWaves/Filters/Elliptic/LowPassFilter.cs +++ b/NWaves/Filters/Elliptic/LowPassFilter.cs @@ -3,7 +3,7 @@ namespace NWaves.Filters.Elliptic { - public class LowPassFilter : IirFilter + public class LowPassFilter : ZiFilter { /// /// Constructor @@ -40,7 +40,7 @@ private static TransferFunction MakeTf(double freq, int order, double ripplePass /// public void Change(double freq, double ripplePass = 1, double rippleStop = 20) { - Change(MakeTf(freq, _b.Length, ripplePass, rippleStop)); + Change(MakeTf(freq, _a.Length - 1, ripplePass, rippleStop)); } } }