mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-13 00:57:31 -05:00
Converted frequency to long primitive type (from integer) in anticipation of HackRF support which requires frequencies greater than 2.147 GHz, which is the max hertz value that can be represented by an integer primitive.
This commit is contained in:
@@ -50,7 +50,7 @@ public class FilterFactory
|
||||
* @return
|
||||
*/
|
||||
public static double[] getSinc( int sampleRate,
|
||||
int frequency,
|
||||
long frequency,
|
||||
int length,
|
||||
WindowType window )
|
||||
{
|
||||
@@ -129,7 +129,7 @@ public class FilterFactory
|
||||
* @return
|
||||
*/
|
||||
public static double[] getUnityResponseArray( int sampleRate,
|
||||
int frequency,
|
||||
long frequency,
|
||||
int length )
|
||||
{
|
||||
double[] unityArray = new double[ length * 2 ];
|
||||
@@ -215,7 +215,7 @@ public class FilterFactory
|
||||
* @return
|
||||
*/
|
||||
public static double[] getLowPass( int sampleRate,
|
||||
int cutoff,
|
||||
long cutoff,
|
||||
int filterLength,
|
||||
WindowType windowType )
|
||||
{
|
||||
@@ -293,14 +293,14 @@ public class FilterFactory
|
||||
* @return
|
||||
*/
|
||||
public static double[] getHighPass( int sampleRate,
|
||||
int cutoff,
|
||||
long cutoff,
|
||||
int filterLength,
|
||||
WindowType windowType )
|
||||
{
|
||||
//Convert the high frequency cutoff to its low frequency cutoff
|
||||
//equivalent, so that when we generate the low pass filter, prior to
|
||||
//inversion, its at the correct frequency
|
||||
int convertedCutoff = sampleRate / 2 - cutoff;
|
||||
long convertedCutoff = sampleRate / 2 - cutoff;
|
||||
|
||||
return invert( getSinc( sampleRate,
|
||||
convertedCutoff,
|
||||
@@ -309,8 +309,8 @@ public class FilterFactory
|
||||
}
|
||||
|
||||
public static double[] getHighPass( int sampleRate,
|
||||
int stopFrequency,
|
||||
int passFrequency,
|
||||
long stopFrequency,
|
||||
long passFrequency,
|
||||
int attenuation,
|
||||
WindowType windowType,
|
||||
boolean forceOddLength )
|
||||
@@ -376,8 +376,8 @@ public class FilterFactory
|
||||
* @return
|
||||
*/
|
||||
public static int getTapCount( int sampleRate,
|
||||
int pass,
|
||||
int stop,
|
||||
long pass,
|
||||
long stop,
|
||||
int attenuation )
|
||||
{
|
||||
double frequency = ( (double)stop - (double)pass ) / (double)sampleRate;
|
||||
@@ -386,8 +386,10 @@ public class FilterFactory
|
||||
}
|
||||
|
||||
public static ComplexFilter[] getDecimationFilters( int sampleRate,
|
||||
int decimatedRate, int passFrequency, int attenuation,
|
||||
WindowType windowType )
|
||||
int decimatedRate,
|
||||
long passFrequency,
|
||||
int attenuation,
|
||||
WindowType windowType )
|
||||
{
|
||||
ComplexFilter[] filters;
|
||||
|
||||
@@ -480,9 +482,9 @@ public class FilterFactory
|
||||
* @throws - AssertionException if sample rate is not a multiple of 48 kHz
|
||||
*/
|
||||
public static int[] getPolyphaseDecimationRates( int sampleRate,
|
||||
int decimatedRate,
|
||||
int passFrequency,
|
||||
int stopFrequency )
|
||||
int decimatedRate,
|
||||
long passFrequency,
|
||||
long stopFrequency )
|
||||
{
|
||||
int[] rates;
|
||||
|
||||
@@ -609,8 +611,8 @@ public class FilterFactory
|
||||
*/
|
||||
public static int getOptimalStageOneRate( int sampleRate,
|
||||
int decimation,
|
||||
int passFrequency,
|
||||
int stopFrequency )
|
||||
long passFrequency,
|
||||
long stopFrequency )
|
||||
{
|
||||
double ratio = getBandwidthRatio( passFrequency, stopFrequency );
|
||||
|
||||
@@ -637,7 +639,7 @@ public class FilterFactory
|
||||
* Used in conjunction with the optimal stage one decimation rate method
|
||||
* above.
|
||||
*/
|
||||
private static double getBandwidthRatio( int passFrequency, int stopFrequency )
|
||||
private static double getBandwidthRatio( long passFrequency, long stopFrequency )
|
||||
{
|
||||
assert( passFrequency < stopFrequency );
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import dsp.filter.Window.WindowType;
|
||||
public class GoertzelFilter
|
||||
{
|
||||
private int mSampleRate;
|
||||
private int mTargetFrequency;
|
||||
private long mTargetFrequency;
|
||||
private int mBlockSize;
|
||||
private double[] mWindowCoefficients;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class GoertzelFilter
|
||||
* the magnitude
|
||||
*/
|
||||
public GoertzelFilter( int sampleRate,
|
||||
int targetFrequency,
|
||||
long targetFrequency,
|
||||
int blockSize,
|
||||
WindowType window )
|
||||
{
|
||||
@@ -139,15 +139,15 @@ public class GoertzelFilter
|
||||
*/
|
||||
public int getSampleRate()
|
||||
{
|
||||
return mSampleRate;
|
||||
return mSampleRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Target Frequency
|
||||
*/
|
||||
public int getTargetFrequency()
|
||||
public long getTargetFrequency()
|
||||
{
|
||||
return mTargetFrequency;
|
||||
return mTargetFrequency;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,7 +155,7 @@ public class GoertzelFilter
|
||||
*/
|
||||
public int getBlockSize()
|
||||
{
|
||||
return mBlockSize;
|
||||
return mBlockSize;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -58,19 +58,23 @@ final public class IIRBiQuadraticFilter {
|
||||
}
|
||||
|
||||
// constructor without gain setting
|
||||
public IIRBiQuadraticFilter(Type type, double center_freq, double sample_rate, double Q) {
|
||||
public IIRBiQuadraticFilter(Type type, double center_freq, double sample_rate, double Q)
|
||||
{
|
||||
configure(type, center_freq, sample_rate, Q, 0);
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
public void reset()
|
||||
{
|
||||
x1 = x2 = y1 = y2 = 0;
|
||||
}
|
||||
|
||||
public double frequency() {
|
||||
public double frequency()
|
||||
{
|
||||
return center_freq;
|
||||
}
|
||||
|
||||
public void configure(Type type, double center_freq, double sample_rate, double Q, double gainDB) {
|
||||
public void configure(Type type, double center_freq, double sample_rate, double Q, double gainDB)
|
||||
{
|
||||
reset();
|
||||
Q = (Q == 0) ? 1e-9 : Q;
|
||||
this.type = type;
|
||||
@@ -80,7 +84,8 @@ final public class IIRBiQuadraticFilter {
|
||||
reconfigure(center_freq);
|
||||
}
|
||||
|
||||
public void configure(Type type, double center_freq, double sample_rate, double Q) {
|
||||
public void configure(Type type, double center_freq, double sample_rate, double Q)
|
||||
{
|
||||
configure(type, center_freq, sample_rate, Q, 0);
|
||||
}
|
||||
|
||||
@@ -167,7 +172,8 @@ final public class IIRBiQuadraticFilter {
|
||||
}
|
||||
|
||||
// provide a static decibel result for testing
|
||||
public double log_result(double f) {
|
||||
public double log_result(double f)
|
||||
{
|
||||
double r;
|
||||
try {
|
||||
r = 10 * Math.log10(result(f));
|
||||
@@ -181,12 +187,14 @@ final public class IIRBiQuadraticFilter {
|
||||
}
|
||||
|
||||
// return the constant set for this filter
|
||||
public double[] constants() {
|
||||
public double[] constants()
|
||||
{
|
||||
return new double[]{b0, b1, b2, a1, a2};
|
||||
}
|
||||
|
||||
// perform one filtering step
|
||||
public double filter(double x) {
|
||||
public double filter(double x)
|
||||
{
|
||||
y = b0 * x + b1 * x1 + b2 * x2 - a1 * y1 - a2 * y2;
|
||||
x2 = x1;
|
||||
x1 = x;
|
||||
|
||||
Reference in New Issue
Block a user