1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-25 17:28:50 -05:00

Series of shifted decimators matching shifted interpolators. Applied to HackRF input

This commit is contained in:
f4exb 2019-04-02 01:10:03 +02:00
parent 6db002bbe3
commit e2ac286458
15 changed files with 2123 additions and 38 deletions

View File

@ -446,6 +446,7 @@ bool AirspyInput::applySettings(const AirspySettings& settings, bool force)
settings.m_log2Decim,
(DeviceSampleSource::fcPos_t) settings.m_fcPos,
m_sampleRates[settings.m_devSampleRateIndex],
DeviceSampleSource::FrequencyShiftScheme::FSHIFT_STD,
settings.m_transverterMode);
if (m_dev != 0) {

View File

@ -542,7 +542,9 @@ bool Bladerf1Input::applySettings(const BladeRF1InputSettings& settings, bool fo
0,
settings.m_log2Decim,
(DeviceSampleSource::fcPos_t) settings.m_fcPos,
settings.m_devSampleRate);
settings.m_devSampleRate,
DeviceSampleSource::FrequencyShiftScheme::FSHIFT_STD,
false);
forwardChange = true;

View File

@ -676,7 +676,9 @@ bool BladeRF2Input::handleMessage(const Message& message)
0,
settings.m_log2Decim,
(DeviceSampleSource::fcPos_t) settings.m_fcPos,
settings.m_devSampleRate);
settings.m_devSampleRate,
DeviceSampleSource::FrequencyShiftScheme::FSHIFT_STD,
false);
if (setDeviceCenterFrequency(dev, requestedChannel, deviceCenterFrequency, settings.m_LOppmTenths))
{
@ -888,7 +890,9 @@ bool BladeRF2Input::applySettings(const BladeRF2InputSettings& settings, bool fo
0,
settings.m_log2Decim,
(DeviceSampleSource::fcPos_t) settings.m_fcPos,
settings.m_devSampleRate);
settings.m_devSampleRate,
DeviceSampleSource::FrequencyShiftScheme::FSHIFT_STD,
false);
forwardChangeOwnDSP = true;
forwardChangeRxBuddies = true;

View File

@ -349,6 +349,7 @@ void FCDProInput::applySettings(const FCDProSettings& settings, bool force)
settings.m_log2Decim,
(DeviceSampleSource::fcPos_t) settings.m_fcPos,
fcd_traits<Pro>::sampleRate,
DeviceSampleSource::FrequencyShiftScheme::FSHIFT_STD,
settings.m_transverterMode);
if (m_dev != 0)

View File

@ -351,6 +351,7 @@ void FCDProPlusInput::applySettings(const FCDProPlusSettings& settings, bool for
settings.m_log2Decim,
(DeviceSampleSource::fcPos_t) settings.m_fcPos,
fcd_traits<ProPlus>::sampleRate,
DeviceSampleSource::FrequencyShiftScheme::FSHIFT_STD,
settings.m_transverterMode);
if (m_dev != 0) {

View File

@ -319,7 +319,8 @@ bool HackRFInput::handleMessage(const Message& message)
0,
m_settings.m_log2Decim,
(DeviceSampleSource::fcPos_t) m_settings.m_fcPos,
m_settings.m_devSampleRate);
m_settings.m_devSampleRate,
DeviceSampleSource::FSHIFT_TXSYNC);
qDebug("HackRFInput::handleMessage: MsgSynchronizeFrequency: centerFrequency: %lld Hz", centerFrequency);
HackRFInputSettings settings = m_settings;
settings.m_centerFrequency = centerFrequency;
@ -441,7 +442,9 @@ bool HackRFInput::applySettings(const HackRFInputSettings& settings, bool force)
0,
settings.m_log2Decim,
(DeviceSampleSource::fcPos_t) settings.m_fcPos,
settings.m_devSampleRate);
settings.m_devSampleRate,
DeviceSampleSource::FrequencyShiftScheme::FSHIFT_TXSYNC,
false);
setDeviceCenterFrequency(deviceCenterFrequency, settings.m_LOppmTenths);
if (m_deviceAPI->getSinkBuddies().size() > 0) // forward to buddy if necessary

View File

@ -139,19 +139,19 @@ void HackRFInputThread::callback(const qint8* buf, qint32 len)
m_decimators.decimate2_inf(&it, buf, len);
break;
case 2:
m_decimators.decimate4_inf(&it, buf, len);
m_decimators.decimate4_inf_txsync(&it, buf, len);
break;
case 3:
m_decimators.decimate8_inf(&it, buf, len);
m_decimators.decimate8_inf_txsync(&it, buf, len);
break;
case 4:
m_decimators.decimate16_inf(&it, buf, len);
m_decimators.decimate16_inf_txsync(&it, buf, len);
break;
case 5:
m_decimators.decimate32_inf(&it, buf, len);
m_decimators.decimate32_inf_txsync(&it, buf, len);
break;
case 6:
m_decimators.decimate64_inf(&it, buf, len);
m_decimators.decimate64_inf_txsync(&it, buf, len);
break;
default:
break;
@ -165,19 +165,19 @@ void HackRFInputThread::callback(const qint8* buf, qint32 len)
m_decimators.decimate2_sup(&it, buf, len);
break;
case 2:
m_decimators.decimate4_sup(&it, buf, len);
m_decimators.decimate4_sup_txsync(&it, buf, len);
break;
case 3:
m_decimators.decimate8_sup(&it, buf, len);
m_decimators.decimate8_sup_txsync(&it, buf, len);
break;
case 4:
m_decimators.decimate16_sup(&it, buf, len);
m_decimators.decimate16_sup_txsync(&it, buf, len);
break;
case 5:
m_decimators.decimate32_sup(&it, buf, len);
m_decimators.decimate32_sup_txsync(&it, buf, len);
break;
case 6:
m_decimators.decimate64_sup(&it, buf, len);
m_decimators.decimate64_sup_txsync(&it, buf, len);
break;
default:
break;

View File

@ -546,6 +546,7 @@ bool PlutoSDRInput::applySettings(const PlutoSDRInputSettings& settings, bool fo
settings.m_log2Decim,
(DeviceSampleSource::fcPos_t) settings.m_fcPos,
settings.m_devSampleRate,
DeviceSampleSource::FrequencyShiftScheme::FSHIFT_STD,
settings.m_transverterMode);
params.push_back(QString(tr("out_altvoltage0_RX_LO_frequency=%1").arg(deviceCenterFrequency)).toStdString());

View File

@ -489,6 +489,7 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, bool force)
settings.m_log2Decim,
(DeviceSampleSource::fcPos_t) settings.m_fcPos,
settings.m_devSampleRate,
DeviceSampleSource::FrequencyShiftScheme::FSHIFT_STD,
settings.m_transverterMode);
forwardChange = true;

View File

@ -555,7 +555,9 @@ bool SDRPlayInput::applySettings(const SDRPlaySettings& settings, bool forwardCh
0,
settings.m_log2Decim,
(DeviceSampleSource::fcPos_t) settings.m_fcPos,
SDRPlaySampleRates::getRate(settings.m_devSampleRateIndex));
SDRPlaySampleRates::getRate(settings.m_devSampleRateIndex),
DeviceSampleSource::FrequencyShiftScheme::FSHIFT_STD,
false);
forwardChange = true;

View File

@ -1018,7 +1018,9 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
0,
settings.m_log2Decim,
(DeviceSampleSource::fcPos_t) settings.m_fcPos,
settings.m_devSampleRate);
settings.m_devSampleRate,
DeviceSampleSource::FrequencyShiftScheme::FSHIFT_STD,
false);
forwardChangeOwnDSP = true;
forwardChangeToBuddies = true;

View File

@ -295,7 +295,9 @@ bool TestSourceInput::applySettings(const TestSourceSettings& settings, bool for
0, // no transverter mode
settings.m_log2Decim,
(DeviceSampleSource::fcPos_t) settings.m_fcPos,
settings.m_sampleRate);
settings.m_sampleRate,
DeviceSampleSource::FrequencyShiftScheme::FSHIFT_STD,
false);
int frequencyShift = settings.m_frequencyShift;
quint32 devSampleRate = settings.m_sampleRate;
@ -305,7 +307,8 @@ bool TestSourceInput::applySettings(const TestSourceSettings& settings, bool for
frequencyShift += DeviceSampleSource::calculateFrequencyShift(
settings.m_log2Decim,
(DeviceSampleSource::fcPos_t) settings.m_fcPos,
settings.m_sampleRate);
settings.m_sampleRate,
DeviceSampleSource::FSHIFT_STD);
}
if (m_testSourceThread != 0)

File diff suppressed because it is too large Load Diff

View File

@ -47,6 +47,7 @@ qint64 DeviceSampleSource::calculateDeviceCenterFrequency(
int log2Decim,
fcPos_t fcPos,
quint32 devSampleRate,
FrequencyShiftScheme frequencyShiftScheme,
bool transverterMode)
{
qint64 deviceCenterFrequency = centerFrequency;
@ -54,10 +55,11 @@ qint64 DeviceSampleSource::calculateDeviceCenterFrequency(
deviceCenterFrequency = deviceCenterFrequency < 0 ? 0 : deviceCenterFrequency;
qint64 f_img = deviceCenterFrequency;
deviceCenterFrequency -= calculateFrequencyShift(log2Decim, fcPos, devSampleRate);
f_img -= 2*calculateFrequencyShift(log2Decim, fcPos, devSampleRate);
deviceCenterFrequency -= calculateFrequencyShift(log2Decim, fcPos, devSampleRate, frequencyShiftScheme);
f_img -= 2*calculateFrequencyShift(log2Decim, fcPos, devSampleRate, frequencyShiftScheme);
qDebug() << "DeviceSampleSource::calculateDeviceCenterFrequency:"
<< " frequencyShiftScheme: " << frequencyShiftScheme
<< " desired center freq: " << centerFrequency << " Hz"
<< " device center freq: " << deviceCenterFrequency << " Hz"
<< " device sample rate: " << devSampleRate << "S/s"
@ -74,14 +76,16 @@ qint64 DeviceSampleSource::calculateCenterFrequency(
int log2Decim,
fcPos_t fcPos,
quint32 devSampleRate,
FrequencyShiftScheme frequencyShiftScheme,
bool transverterMode)
{
qint64 centerFrequency = deviceCenterFrequency;
centerFrequency += calculateFrequencyShift(log2Decim, fcPos, devSampleRate);
centerFrequency += calculateFrequencyShift(log2Decim, fcPos, devSampleRate, frequencyShiftScheme);
centerFrequency += transverterMode ? transverterDeltaFrequency : 0;
centerFrequency = centerFrequency < 0 ? 0 : centerFrequency;
qDebug() << "DeviceSampleSource::calculateCenterFrequency:"
<< " frequencyShiftScheme: " << frequencyShiftScheme
<< " desired center freq: " << centerFrequency << " Hz"
<< " device center freq: " << deviceCenterFrequency << " Hz"
<< " device sample rate: " << devSampleRate << "S/s"
@ -109,25 +113,60 @@ qint64 DeviceSampleSource::calculateCenterFrequency(
qint32 DeviceSampleSource::calculateFrequencyShift(
int log2Decim,
fcPos_t fcPos,
quint32 devSampleRate)
quint32 devSampleRate,
FrequencyShiftScheme frequencyShiftScheme)
{
if (log2Decim == 0) { // no shift at all
return 0;
} else if (log2Decim < 3) {
if (fcPos == FC_POS_INFRA) { // shift in the square next to center frequency
return -(devSampleRate / (1<<(log2Decim+1)));
} else if (fcPos == FC_POS_SUPRA) {
return devSampleRate / (1<<(log2Decim+1));
if (frequencyShiftScheme == FSHIFT_STD)
{
if (log2Decim == 0) { // no shift at all
return 0;
} else if (log2Decim < 3) {
if (fcPos == FC_POS_INFRA) { // shift in the square next to center frequency
return -(devSampleRate / (1<<(log2Decim+1)));
} else if (fcPos == FC_POS_SUPRA) {
return devSampleRate / (1<<(log2Decim+1));
} else {
return 0;
}
} else {
if (fcPos == FC_POS_INFRA) { // shift centered in the square next to center frequency
return -(devSampleRate / (1<<(log2Decim)));
} else if (fcPos == FC_POS_SUPRA) {
return devSampleRate / (1<<(log2Decim));
} else {
return 0;
}
}
}
else if (frequencyShiftScheme == FSHIFT_TXSYNC)
{
if (fcPos == FC_POS_CENTER) {
return 0;
}
} else {
if (fcPos == FC_POS_INFRA) { // shift centered in the square next to center frequency
return -(devSampleRate / (1<<(log2Decim)));
} else if (fcPos == FC_POS_SUPRA) {
return devSampleRate / (1<<(log2Decim));
int sign = fcPos == FC_POS_INFRA ? -1 : 1;
int halfSampleRate = devSampleRate / 2; // fractions are relative to sideband thus based on half the sample rate
if (log2Decim == 0) {
return 0;
} else if (log2Decim == 1) {
return sign * (halfSampleRate / 2); // inf or sup: 1/2
} else if (log2Decim == 2) {
return sign * ((halfSampleRate * 3) / 4); // inf, inf or sup, sup: 1/2 + 1/4
} else if (log2Decim == 3) {
return sign * ((halfSampleRate * 5) / 8); // inf, inf, sup or sup, sup, inf: 1/2 + 1/4 - 1/8 = 5/8
} else if (log2Decim == 4) {
return sign * ((halfSampleRate * 11) / 16); // inf, inf, sup, inf or sup, sup, inf, sup: 1/2 + 1/4 - 1/8 + 1/16 = 11/16
} else if (log2Decim == 5) {
return sign * ((halfSampleRate * 21) / 32); // inf, inf, sup, inf, sup or sup, sup, inf, sup, inf: 1/2 + 1/4 - 1/8 + 1/16 - 1/32 = 21/32
} else if (log2Decim == 6) {
return sign * ((halfSampleRate * 21) / 64); // inf, sup, inf, sup, inf, sup or sup, inf, sup, inf, sup, inf: 1/2 - 1/4 + 1/8 -1/16 + 1/32 - 1/64 = 21/64
} else {
return 0;
}
}
else
{
return 0;
}
}

View File

@ -42,6 +42,11 @@ public:
FC_POS_CENTER
} fcPos_t;
typedef enum {
FSHIFT_STD = 0, // Standard Rx independent
FSHIFT_TXSYNC // Follows same scheme as Tx
} FrequencyShiftScheme;
DeviceSampleSource();
virtual ~DeviceSampleSource();
virtual void destroy() = 0;
@ -121,7 +126,9 @@ public:
int log2Decim,
fcPos_t fcPos,
quint32 devSampleRate,
bool transverterMode = false);
FrequencyShiftScheme frequencyShiftScheme,
bool transverterMode = false
);
static qint64 calculateCenterFrequency(
quint64 deviceCenterFrequency,
@ -129,12 +136,16 @@ public:
int log2Decim,
fcPos_t fcPos,
quint32 devSampleRate,
bool transverterMode = false);
FrequencyShiftScheme frequencyShiftScheme,
bool transverterMode = false
);
static qint32 calculateFrequencyShift(
int log2Decim,
fcPos_t fcPos,
quint32 devSampleRate);
quint32 devSampleRate,
FrequencyShiftScheme frequencyShiftScheme
);
protected slots:
void handleInputMessages();