WIP - experiments

This commit is contained in:
Denny
2017-03-11 06:08:23 -05:00
parent e2fe06638b
commit 131290fcd2
2 changed files with 27 additions and 20 deletions

View File

@@ -1,6 +1,7 @@
package dsp.filter.design; package dsp.filter.design;
import dsp.filter.FilterFactory; import dsp.filter.FilterFactory;
import dsp.filter.Window;
import dsp.filter.fir.FIRFilterSpecification; import dsp.filter.fir.FIRFilterSpecification;
import dsp.filter.fir.remez.PolyphaseChannelizerFilterFactory; import dsp.filter.fir.remez.PolyphaseChannelizerFilterFactory;
import dsp.filter.fir.remez.RemezFIRFilterDesigner; import dsp.filter.fir.remez.RemezFIRFilterDesigner;
@@ -25,11 +26,20 @@ public class FilterViewer extends Application
@Override @Override
public void start(Stage primaryStage) throws Exception public void start(Stage primaryStage) throws Exception
{ {
Scene scene = new Scene(new FilterView(getFilter())); float[] taps = getFilter();
primaryStage.setTitle("Filter Viewer"); if(taps != null)
primaryStage.setScene(scene); {
primaryStage.show(); 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) public static void main(String[] args)
@@ -93,7 +103,10 @@ public class FilterViewer extends Application
// mLog.error("Filter design error", fde); // 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; return taps;
} }
} }

View File

@@ -30,10 +30,10 @@ public class PolyphaseChannelizerFilterFactory
public static float[] getFilter(int sampleRate, int channelBandwidth, double alpha) 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 passBandStart = 0;
int gridDensity = 50; int gridDensity = 60;
int rolloffFrequency = (int)(alpha * (double)channelBandwidth); int rolloffFrequency = (int)(alpha * (double)channelBandwidth);
@@ -43,13 +43,16 @@ public class PolyphaseChannelizerFilterFactory
int stopBandStart = channelBandwidth + rolloffFrequency; int stopBandStart = channelBandwidth + rolloffFrequency;
double passRipple = 0.01d; double passRipple = 0.01d;
double transitionRipple = 0.02d;
double stopRipple = 0.001d; //Approximately 90 dB of attenuation double stopRipple = 0.001d; //Approximately 90 dB of attenuation
int order = FIRFilterSpecification.estimateFilterOrder( sampleRate, passBandStop, stopBandStart, int order = FIRFilterSpecification.estimateFilterOrder( sampleRate, passBandStop, stopBandStart,
passRipple, stopRipple ); passRipple, stopRipple );
// Ensure even order since we're designing a Type 1 filter // order = 1001;
if(order % 2 == 1)
// Ensure odd order since we're designing a Type 2 filter
if(order % 2 == 0)
{ {
order++; order++;
} }
@@ -62,10 +65,10 @@ public class PolyphaseChannelizerFilterFactory
passBandStop, 1.0, passRipple, 1.0); passBandStop, 1.0, passRipple, 1.0);
//Use the filter order as the weighting for the pass band edge frequency //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, 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, FIRFilterSpecification.FrequencyBand stopBand = new FIRFilterSpecification.FrequencyBand(sampleRate,
stopBandStart, (int)(sampleRate / 2), 0.0, stopRipple); stopBandStart, (int)(sampleRate / 2), 0.0, stopRipple);
@@ -91,13 +94,4 @@ public class PolyphaseChannelizerFilterFactory
return filter; return filter;
} }
public static void main(String[] args)
{
mLog.debug("Starting ...");
float[] filter = getFilter(200000, 12500, 0.21);
mLog.debug("Finished ...");
}
} }