Skip to content

Commit

Permalink
final fixes in Butterworth/Bessel/Chebyshev/Elliptic filters
Browse files Browse the repository at this point in the history
  • Loading branch information
ar1st0crat committed Aug 21, 2021
1 parent 474064e commit 70ee2b8
Show file tree
Hide file tree
Showing 20 changed files with 32 additions and 34 deletions.
2 changes: 1 addition & 1 deletion NWaves/Filters/Bessel/BandPassFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ private static TransferFunction MakeTf(double f1, double f2, int order)
/// </summary>
///<param name="f1"></param>
///<param name="f2"></param>
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));
}
}
3 changes: 1 addition & 2 deletions NWaves/Filters/Bessel/BandStopFilter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using NWaves.Filters.Base;
using NWaves.Filters.Fda;
using System;

namespace NWaves.Filters.Bessel
{
Expand Down Expand Up @@ -36,6 +35,6 @@ private static TransferFunction MakeTf(double f1, double f2, int order)
/// </summary>
///<param name="f1"></param>
///<param name="f2"></param>
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));
}
}
3 changes: 1 addition & 2 deletions NWaves/Filters/Bessel/HighPassFilter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using NWaves.Filters.Base;
using NWaves.Filters.Fda;
using System;

namespace NWaves.Filters.Bessel
{
Expand Down Expand Up @@ -34,6 +33,6 @@ private static TransferFunction MakeTf(double freq, int order)
/// Change filter coeffs online
/// </summary>
/// <param name="freq"></param>
public void Change(double freq) => Change(MakeTf(freq, _b.Length));
public void Change(double freq) => Change(MakeTf(freq, _a.Length - 1));
}
}
2 changes: 1 addition & 1 deletion NWaves/Filters/Bessel/LowPassFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ private static TransferFunction MakeTf(double freq, int order)
/// Change filter coeffs online
/// </summary>
/// <param name="freq"></param>
public void Change(double freq) => Change(MakeTf(freq, _b.Length));
public void Change(double freq) => Change(MakeTf(freq, _a.Length - 1));
}
}
2 changes: 1 addition & 1 deletion NWaves/Filters/Butterworth/BandPassFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ private static TransferFunction MakeTf(double f1, double f2, int order)
/// </summary>
///<param name="f1"></param>
///<param name="f2"></param>
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));
}
}
2 changes: 1 addition & 1 deletion NWaves/Filters/Butterworth/BandStopFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ private static TransferFunction MakeTf(double f1, double f2, int order)
/// </summary>
///<param name="f1"></param>
///<param name="f2"></param>
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));
}
}
2 changes: 1 addition & 1 deletion NWaves/Filters/Butterworth/HighPassFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ private static TransferFunction MakeTf(double freq, int order)
/// Change filter coeffs online
/// </summary>
/// <param name="freq"></param>
public void Change(double freq) => Change(MakeTf(freq, _b.Length));
public void Change(double freq) => Change(MakeTf(freq, _a.Length - 1));
}
}
2 changes: 1 addition & 1 deletion NWaves/Filters/Butterworth/LowPassFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ private static TransferFunction MakeTf(double freq, int order)
/// Change filter coeffs online
/// </summary>
/// <param name="freq"></param>
public void Change(double freq) => Change(MakeTf(freq, _b.Length));
public void Change(double freq) => Change(MakeTf(freq, _a.Length - 1));
}
}
4 changes: 2 additions & 2 deletions NWaves/Filters/ChebyshevI/BandPassFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace NWaves.Filters.ChebyshevI
/// <summary>
/// Band-pass Chebyshev-I filter
/// </summary>
public class BandPassFilter : IirFilter
public class BandPassFilter : ZiFilter
{
/// <summary>
/// Constructor
Expand Down Expand Up @@ -36,6 +36,6 @@ private static TransferFunction MakeTf(double f1, double f2, int order, double r
/// <param name="f1"></param>
/// <param name="f2"></param>
/// <param name="ripple"></param>
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));
}
}
4 changes: 2 additions & 2 deletions NWaves/Filters/ChebyshevI/BandStopFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace NWaves.Filters.ChebyshevI
/// <summary>
/// Band-stop Chebyshev-I filter
/// </summary>
public class BandStopFilter : IirFilter
public class BandStopFilter : ZiFilter
{
/// <summary>
/// Constructor
Expand Down Expand Up @@ -36,6 +36,6 @@ private static TransferFunction MakeTf(double f1, double f2, int order, double r
/// <param name="f1"></param>
/// <param name="f2"></param>
/// <param name="ripple"></param>
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));
}
}
4 changes: 2 additions & 2 deletions NWaves/Filters/ChebyshevI/HighPassFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace NWaves.Filters.ChebyshevI
/// <summary>
/// High-pass Chebyshev-I filter
/// </summary>
public class HighPassFilter : IirFilter
public class HighPassFilter : ZiFilter
{
/// <summary>
/// Constructor
Expand Down Expand Up @@ -34,6 +34,6 @@ private static TransferFunction MakeTf(double freq, int order, double ripple = 0
/// </summary>
/// <param name="freq"></param>
/// <param name="ripple"></param>
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));
}
}
4 changes: 2 additions & 2 deletions NWaves/Filters/ChebyshevI/LowPassFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace NWaves.Filters.ChebyshevI
/// <summary>
/// Low-pass Chebyshev-I filter
/// </summary>
public class LowPassFilter : IirFilter
public class LowPassFilter : ZiFilter
{
/// <summary>
/// Constructor
Expand Down Expand Up @@ -34,6 +34,6 @@ private static TransferFunction MakeTf(double freq, int order, double ripple = 0
/// </summary>
/// <param name="freq"></param>
/// <param name="ripple"></param>
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));
}
}
4 changes: 2 additions & 2 deletions NWaves/Filters/ChebyshevII/BandPassFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace NWaves.Filters.ChebyshevII
/// <summary>
/// Band-pass Chebyshev-II filter
/// </summary>
public class BandPassFilter : IirFilter
public class BandPassFilter : ZiFilter
{
/// <summary>
/// Constructor
Expand Down Expand Up @@ -38,6 +38,6 @@ private static TransferFunction MakeTf(double freq1, double freq2, int order, do
/// <param name="f1"></param>
/// <param name="f2"></param>
/// <param name="ripple"></param>
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));
}
}
4 changes: 2 additions & 2 deletions NWaves/Filters/ChebyshevII/BandStopFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace NWaves.Filters.ChebyshevII
/// <summary>
/// Band-stop Chebyshev-II filter
/// </summary>
public class BandStopFilter : IirFilter
public class BandStopFilter : ZiFilter
{
/// <summary>
/// Constructor
Expand Down Expand Up @@ -38,6 +38,6 @@ private static TransferFunction MakeTf(double freq1, double freq2, int order, do
/// <param name="f1"></param>
/// <param name="f2"></param>
/// <param name="ripple"></param>
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));
}
}
4 changes: 2 additions & 2 deletions NWaves/Filters/ChebyshevII/HighPassFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace NWaves.Filters.ChebyshevII
/// <summary>
/// High-pass Chebyshev-II filter
/// </summary>
public class HighPassFilter : IirFilter
public class HighPassFilter : ZiFilter
{
/// <summary>
/// Constructor
Expand Down Expand Up @@ -36,6 +36,6 @@ private static TransferFunction MakeTf(double freq, int order, double ripple = 0
/// </summary>
/// <param name="freq"></param>
/// <param name="ripple"></param>
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));
}
}
4 changes: 2 additions & 2 deletions NWaves/Filters/ChebyshevII/LowPassFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace NWaves.Filters.ChebyshevII
/// <summary>
/// Low-pass Chebyshev-II filter
/// </summary>
public class LowPassFilter : IirFilter
public class LowPassFilter : ZiFilter
{
/// <summary>
/// Constructor
Expand Down Expand Up @@ -36,6 +36,6 @@ private static TransferFunction MakeTf(double freq, int order, double ripple = 0
/// </summary>
/// <param name="freq"></param>
/// <param name="ripple"></param>
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));
}
}
4 changes: 2 additions & 2 deletions NWaves/Filters/Elliptic/BandPassFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace NWaves.Filters.Elliptic
{
public class BandPassFilter : IirFilter
public class BandPassFilter : ZiFilter
{
/// <summary>
/// Constructor
Expand Down Expand Up @@ -43,7 +43,7 @@ private static TransferFunction MakeTf(double freq1, double freq2, int order, do
/// <param name="rippleStop"></param>
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));
}
}
}
4 changes: 2 additions & 2 deletions NWaves/Filters/Elliptic/BandStopFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace NWaves.Filters.Elliptic
{
public class BandStopFilter : IirFilter
public class BandStopFilter : ZiFilter
{
/// <summary>
/// Constructor
Expand Down Expand Up @@ -43,7 +43,7 @@ private static TransferFunction MakeTf(double freq1, double freq2, int order, do
/// <param name="rippleStop"></param>
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));
}
}
}
4 changes: 2 additions & 2 deletions NWaves/Filters/Elliptic/HighPassFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace NWaves.Filters.Elliptic
{
public class HighPassFilter : IirFilter
public class HighPassFilter : ZiFilter
{
/// <summary>
/// Constructor
Expand Down Expand Up @@ -40,7 +40,7 @@ private static TransferFunction MakeTf(double freq, int order, double ripplePass
/// <param name="rippleStop"></param>
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));
}
}
}
4 changes: 2 additions & 2 deletions NWaves/Filters/Elliptic/LowPassFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace NWaves.Filters.Elliptic
{
public class LowPassFilter : IirFilter
public class LowPassFilter : ZiFilter
{
/// <summary>
/// Constructor
Expand Down Expand Up @@ -40,7 +40,7 @@ private static TransferFunction MakeTf(double freq, int order, double ripplePass
/// <param name="rippleStop"></param>
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));
}
}
}

0 comments on commit 70ee2b8

Please sign in to comment.