mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
[WIP] Updating dsp modules to accept variable sample rate I/Q streams
and creating a new audio resampler.
This commit is contained in:
@@ -180,15 +180,18 @@ public abstract class TunerChannelSource extends ComplexSource implements ISourc
|
||||
case NOTIFICATION_SAMPLE_RATE_CHANGE:
|
||||
setSampleRate(sourceEvent.getValue().doubleValue());
|
||||
break;
|
||||
|
||||
case NOTIFICATION_FREQUENCY_AND_SAMPLE_RATE_LOCKED:
|
||||
case NOTIFICATION_FREQUENCY_AND_SAMPLE_RATE_UNLOCKED:
|
||||
case NOTIFICATION_FREQUENCY_CORRECTION_CHANGE:
|
||||
//no-op
|
||||
break;
|
||||
//Request events from the consumer
|
||||
case REQUEST_CHANNEL_FREQUENCY_CORRECTION_CHANGE:
|
||||
setFrequencyCorrection(sourceEvent.getValue().longValue());
|
||||
break;
|
||||
|
||||
default:
|
||||
mLog.error("Ignoring unrecognized source event: " + sourceEvent.getEvent() + " from [" +
|
||||
sourceEvent.getSource().getClass() + "]");
|
||||
(sourceEvent.hasSource() ? sourceEvent.getSource().getClass() : "") + "]");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,18 +181,39 @@ public class TunerChannelSourceManager extends ChannelSourceManager
|
||||
|
||||
long bestIntegralFrequency = getIntegralFrequency(channels);
|
||||
|
||||
//See if we can reuse the current frequency
|
||||
//Strategy 1: reuse the current frequency if it's a good integral and the channels fit
|
||||
if(isIntegralSpacing(currentCenterFrequency, bestIntegralFrequency) &&
|
||||
isValidCenterFrequency(channels, currentCenterFrequency))
|
||||
{
|
||||
return currentCenterFrequency;
|
||||
}
|
||||
|
||||
//Start by placing the first channel at the minimum location within the tuner bandwidth
|
||||
double usableHalfBandwidth = mTunerController.getUsableHalfBandwidth();
|
||||
|
||||
//Strategy 2: start by placing the center frequency exactly one channel width below the first channel frequency
|
||||
//and iteratively increase it one channel width at a time. This optimally places the channels nearest to the
|
||||
//center of the bandwidth
|
||||
long start = channels.first().getFrequency() - (int)mPolyphaseChannelManager.getChannelBandwidth();
|
||||
|
||||
if(isValidCenterFrequency(channels, start))
|
||||
{
|
||||
return start;
|
||||
}
|
||||
|
||||
while(start - channels.first().getMinFrequency() < usableHalfBandwidth)
|
||||
{
|
||||
start += (int)mPolyphaseChannelManager.getChannelBandwidth();
|
||||
|
||||
if(isValidCenterFrequency(channels, start))
|
||||
{
|
||||
return start;
|
||||
}
|
||||
}
|
||||
|
||||
//Strategy 3: start by placing the first channel at the minimum location within the tuner bandwidth
|
||||
double startFrequency = channels.first().getMinFrequency() + usableHalfBandwidth;
|
||||
|
||||
//Align the test frequency to the next greater integral frequency placing to place the first channel at the
|
||||
//Align the test frequency to the next greater integral frequency placing the first channel at the
|
||||
// minimum extreme of the available bandwidth as a starting location
|
||||
double delta = Math.abs(startFrequency - bestIntegralFrequency);
|
||||
double adjustment = delta % mPolyphaseChannelManager.getChannelBandwidth();
|
||||
@@ -221,7 +242,8 @@ public class TunerChannelSourceManager extends ChannelSourceManager
|
||||
currentChannel++;
|
||||
}
|
||||
|
||||
//If we can't find an integral center frequency, choose a frequency that will fit the channels
|
||||
//Strategy 4: brute force walk across the spectrum 1 hertz at a time looking for a center frequency that will
|
||||
//fit all channels
|
||||
long testFrequency = channels.first().getMinFrequency() + mTunerController.getUsableHalfBandwidth();
|
||||
long minimumFrequency = testFrequency - availableTestBandwidth;
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ public class TestTunerController extends TunerController
|
||||
public static final long MINIMUM_FREQUENCY = 1l;
|
||||
public static final long MAXIMUM_FREQUENCY = 1000000000l;
|
||||
public static final int SAMPLE_RATE = 100000;
|
||||
public static final int DC_NOISE_BANDWIDTH = 5000;
|
||||
public static final double USABLE_BANDWIDTH_PERCENTAGE = .90;
|
||||
public static final int DC_NOISE_BANDWIDTH = 0;
|
||||
public static final double USABLE_BANDWIDTH_PERCENTAGE = 1.00;
|
||||
|
||||
public static final int SPECTRAL_FRAME_RATE = 20;
|
||||
public static final long SAMPLE_GENERATION_INTERVAL = 1000 / SPECTRAL_FRAME_RATE;
|
||||
|
||||
Reference in New Issue
Block a user