mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-17 02:57:35 -05:00
Updates the heterodyne channelizer's center frequency calculator to
only update the center frequency when needed and to place the set of decoding channels adjacent to the right side of the tuner's center frequency when the complete set of channels fit into the usable half bandwidth of the tuner.
This commit is contained in:
@@ -26,12 +26,15 @@ import io.github.dsheirer.source.ISourceEventProcessor;
|
|||||||
import io.github.dsheirer.source.SourceEvent;
|
import io.github.dsheirer.source.SourceEvent;
|
||||||
import io.github.dsheirer.source.SourceEventListenerToProcessorAdapter;
|
import io.github.dsheirer.source.SourceEventListenerToProcessorAdapter;
|
||||||
import io.github.dsheirer.source.SourceException;
|
import io.github.dsheirer.source.SourceException;
|
||||||
|
import io.github.dsheirer.source.tuner.channel.TunerChannel;
|
||||||
import io.github.dsheirer.source.tuner.configuration.TunerConfiguration;
|
import io.github.dsheirer.source.tuner.configuration.TunerConfiguration;
|
||||||
import io.github.dsheirer.source.tuner.frequency.FrequencyController;
|
import io.github.dsheirer.source.tuner.frequency.FrequencyController;
|
||||||
import io.github.dsheirer.source.tuner.frequency.FrequencyController.Tunable;
|
import io.github.dsheirer.source.tuner.frequency.FrequencyController.Tunable;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.SortedSet;
|
||||||
|
|
||||||
public abstract class TunerController implements Tunable, ISourceEventProcessor, ISourceEventListener,
|
public abstract class TunerController implements Tunable, ISourceEventProcessor, ISourceEventListener,
|
||||||
IReusableComplexBufferProvider, Listener<ReusableComplexBuffer>
|
IReusableComplexBufferProvider, Listener<ReusableComplexBuffer>
|
||||||
{
|
{
|
||||||
@@ -361,4 +364,85 @@ public abstract class TunerController implements Tunable, ISourceEventProcessor,
|
|||||||
{
|
{
|
||||||
broadcast(complexBuffer);
|
broadcast(complexBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if the current center frequency and bandwidth is correct to source the tuner channel
|
||||||
|
*
|
||||||
|
* @param tunerChannel to test
|
||||||
|
* @return true if the current center frequency and bandwidth is correct for the channel
|
||||||
|
*/
|
||||||
|
public boolean isTunedFor(TunerChannel tunerChannel)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if(tunerChannel.getMinFrequency() < getMinTunedFrequency())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(tunerChannel.getMaxFrequency() > getMaxTunedFrequency())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(hasMiddleUnusableBandwidth())
|
||||||
|
{
|
||||||
|
long minAvoid = getFrequency() - getMiddleUnusableHalfBandwidth();
|
||||||
|
long maxAvoid = getFrequency() + getMiddleUnusableHalfBandwidth();
|
||||||
|
|
||||||
|
if(tunerChannel.overlaps(minAvoid, maxAvoid))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(SourceException se)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if the current center frequency and bandwidth is correct to source the tuner channel set
|
||||||
|
*
|
||||||
|
* @param tunerChannels to test
|
||||||
|
* @return true if the current center frequency and bandwidth is correct for the channel set
|
||||||
|
*/
|
||||||
|
public boolean isTunedFor(SortedSet<TunerChannel> tunerChannels)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if(tunerChannels.first().getMinFrequency() < getMinTunedFrequency())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(tunerChannels.last().getMaxFrequency() > getMaxTunedFrequency())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(hasMiddleUnusableBandwidth())
|
||||||
|
{
|
||||||
|
long minAvoid = getFrequency() - getMiddleUnusableHalfBandwidth();
|
||||||
|
long maxAvoid = getFrequency() + getMiddleUnusableHalfBandwidth();
|
||||||
|
|
||||||
|
for(TunerChannel tunerChannel: tunerChannels)
|
||||||
|
{
|
||||||
|
if(tunerChannel.overlaps(minAvoid, maxAvoid))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(SourceException se)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -54,6 +54,13 @@ public class CenterFrequencyCalculator
|
|||||||
//Start by placing the highest frequency channel at the high end of the spectrum
|
//Start by placing the highest frequency channel at the high end of the spectrum
|
||||||
candidateFrequency = maxChannelFrequency - (tunerController.getUsableBandwidth() / 2);
|
candidateFrequency = maxChannelFrequency - (tunerController.getUsableBandwidth() / 2);
|
||||||
|
|
||||||
|
if(maxChannelFrequency - minChannelFrequency <= tunerController.getUsableHalfBandwidth())
|
||||||
|
{
|
||||||
|
candidateFrequency = minChannelFrequency - tunerController.getMiddleUnusableHalfBandwidth();
|
||||||
|
isValidCandidateFrequency = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
//Iterate the channels and make sure that none of them overlap the center DC spike buffer, if one exists
|
//Iterate the channels and make sure that none of them overlap the center DC spike buffer, if one exists
|
||||||
if(tunerController.getMiddleUnusableHalfBandwidth() > 0)
|
if(tunerController.getMiddleUnusableHalfBandwidth() > 0)
|
||||||
{
|
{
|
||||||
@@ -98,6 +105,8 @@ public class CenterFrequencyCalculator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if(isValidCandidateFrequency)
|
if(isValidCandidateFrequency)
|
||||||
{
|
{
|
||||||
return candidateFrequency;
|
return candidateFrequency;
|
||||||
|
|||||||
@@ -107,6 +107,8 @@ public class HeterodyneChannelSourceManager extends ChannelSourceManager
|
|||||||
* Calculates a new center frequency and updates the tuner center frequency
|
* Calculates a new center frequency and updates the tuner center frequency
|
||||||
*/
|
*/
|
||||||
private void updateTunerFrequency()
|
private void updateTunerFrequency()
|
||||||
|
{
|
||||||
|
if(!mTunerController.isTunedFor(getTunerChannels()))
|
||||||
{
|
{
|
||||||
long centerFrequency = CenterFrequencyCalculator.getCenterFrequency(mTunerController, getTunerChannels());
|
long centerFrequency = CenterFrequencyCalculator.getCenterFrequency(mTunerController, getTunerChannels());
|
||||||
|
|
||||||
@@ -128,6 +130,7 @@ public class HeterodyneChannelSourceManager extends ChannelSourceManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(SourceEvent tunerSourceEvent) throws SourceException
|
public void process(SourceEvent tunerSourceEvent) throws SourceException
|
||||||
|
|||||||
Reference in New Issue
Block a user