From 131290fcd28dbcb10de90a7a3ca46b97dc12aa3a Mon Sep 17 00:00:00 2001 From: Denny Date: Sat, 11 Mar 2017 06:08:23 -0500 Subject: [PATCH] WIP - experiments --- src/dsp/filter/design/FilterViewer.java | 23 ++++++++++++++---- .../PolyphaseChannelizerFilterFactory.java | 24 +++++++------------ 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/dsp/filter/design/FilterViewer.java b/src/dsp/filter/design/FilterViewer.java index 9bdf1ac0..2ea1f536 100644 --- a/src/dsp/filter/design/FilterViewer.java +++ b/src/dsp/filter/design/FilterViewer.java @@ -1,6 +1,7 @@ package dsp.filter.design; import dsp.filter.FilterFactory; +import dsp.filter.Window; import dsp.filter.fir.FIRFilterSpecification; import dsp.filter.fir.remez.PolyphaseChannelizerFilterFactory; import dsp.filter.fir.remez.RemezFIRFilterDesigner; @@ -25,11 +26,20 @@ public class FilterViewer extends Application @Override public void start(Stage primaryStage) throws Exception { - Scene scene = new Scene(new FilterView(getFilter())); + float[] taps = getFilter(); - primaryStage.setTitle("Filter Viewer"); - primaryStage.setScene(scene); - primaryStage.show(); + if(taps != null) + { + Scene scene = new Scene(new FilterView(taps)); + + primaryStage.setTitle("Filter Viewer"); + primaryStage.setScene(scene); + primaryStage.show(); + } + else + { + throw new Exception("Couldn't start application - filter error"); + } } public static void main(String[] args) @@ -93,7 +103,10 @@ public class FilterViewer extends Application // mLog.error("Filter design error", fde); // } - taps = PolyphaseChannelizerFilterFactory.getFilter(10000000, 312500, 0.21); +// taps = PolyphaseChannelizerFilterFactory.getFilter(2000000, 12500, 0.3); + + taps = FilterFactory.getSinc(10000000, 12500, 450, Window.WindowType.HANNING); + return taps; } } diff --git a/src/dsp/filter/fir/remez/PolyphaseChannelizerFilterFactory.java b/src/dsp/filter/fir/remez/PolyphaseChannelizerFilterFactory.java index 7e21f6fa..6b0ea0ff 100644 --- a/src/dsp/filter/fir/remez/PolyphaseChannelizerFilterFactory.java +++ b/src/dsp/filter/fir/remez/PolyphaseChannelizerFilterFactory.java @@ -30,10 +30,10 @@ public class PolyphaseChannelizerFilterFactory public static float[] getFilter(int sampleRate, int channelBandwidth, double alpha) { - FIRLinearPhaseFilterType type = FIRLinearPhaseFilterType.TYPE_1_ODD_LENGTH_EVEN_ORDER_SYMMETRICAL; + FIRLinearPhaseFilterType type = FIRLinearPhaseFilterType.TYPE_2_EVEN_LENGTH_ODD_ORDER_SYMMETRICAL; int passBandStart = 0; - int gridDensity = 50; + int gridDensity = 60; int rolloffFrequency = (int)(alpha * (double)channelBandwidth); @@ -43,13 +43,16 @@ public class PolyphaseChannelizerFilterFactory int stopBandStart = channelBandwidth + rolloffFrequency; double passRipple = 0.01d; + double transitionRipple = 0.02d; double stopRipple = 0.001d; //Approximately 90 dB of attenuation int order = FIRFilterSpecification.estimateFilterOrder( sampleRate, passBandStop, stopBandStart, passRipple, stopRipple ); - // Ensure even order since we're designing a Type 1 filter - if(order % 2 == 1) +// order = 1001; + + // Ensure odd order since we're designing a Type 2 filter + if(order % 2 == 0) { order++; } @@ -62,10 +65,10 @@ public class PolyphaseChannelizerFilterFactory passBandStop, 1.0, passRipple, 1.0); //Use the filter order as the weighting for the pass band edge frequency - double weight = order; +// double weight = order; FIRFilterSpecification.FrequencyBand transitionBand = new FIRFilterSpecification.FrequencyBand(sampleRate, - channelBandwidth, channelBandwidth, OBJECTIVE_BAND_EDGE_COEFFICIENT_AMPLITUDE, passRipple, weight); + channelBandwidth, channelBandwidth, OBJECTIVE_BAND_EDGE_COEFFICIENT_AMPLITUDE, transitionRipple, 5.0); FIRFilterSpecification.FrequencyBand stopBand = new FIRFilterSpecification.FrequencyBand(sampleRate, stopBandStart, (int)(sampleRate / 2), 0.0, stopRipple); @@ -91,13 +94,4 @@ public class PolyphaseChannelizerFilterFactory return filter; } - - public static void main(String[] args) - { - mLog.debug("Starting ..."); - - float[] filter = getFilter(200000, 12500, 0.21); - - mLog.debug("Finished ..."); - } }