Frequency limit for Automatic Frequency Control to prevent the controller from walking too far.

Defaults to a maximum of 3kHz, but can be set to as high as 15 kHz.
This commit is contained in:
dennis.sheirer
2014-10-26 22:36:06 +00:00
parent 08f321fda4
commit d1ab661754
5 changed files with 71 additions and 9 deletions

View File

@@ -24,6 +24,7 @@ public class AutomaticFrequencyControl implements SimplexSampleListener,
private int mSkipThreshold = 4;
private int mErrorCorrection = 0;
private long mCurrentFrequency;
private int mMaximumCorrection;
private FrequencyChangeListener mListener;
public enum Mode
@@ -31,9 +32,11 @@ public class AutomaticFrequencyControl implements SimplexSampleListener,
NORMAL,FAST;
}
public AutomaticFrequencyControl( FrequencyChangeListener listener )
public AutomaticFrequencyControl( FrequencyChangeListener listener,
int maximumCorrection )
{
mListener = listener;
mMaximumCorrection = maximumCorrection;
}
public void dispose()
@@ -150,6 +153,14 @@ public class AutomaticFrequencyControl implements SimplexSampleListener,
if( correction != 0 )
{
mErrorCorrection -= correction;
if( Math.abs( mErrorCorrection ) > mMaximumCorrection )
{
mErrorCorrection = ( mErrorCorrection < 0 ) ?
-mMaximumCorrection :
mMaximumCorrection;
}
dispatch();
}
else