From 057a8f94bb85b44459768ecedcb0ad9d2fe6bbbf Mon Sep 17 00:00:00 2001 From: f4exb Date: Sat, 20 Jan 2018 03:28:30 +0100 Subject: [PATCH] Airspy, BladeRF, HackRF, PlutoSDR, RTLSDR, SDRPlay: fixed frequency setting when changing decimation with fc position change --- plugins/samplesource/airspy/airspyinput.cpp | 17 +-- plugins/samplesource/airspy/airspyplugin.cpp | 2 +- .../bladerfinput/bladerfinput.cpp | 124 +++++++++--------- .../bladerfinput/bladerfinputplugin.cpp | 2 +- .../samplesource/hackrfinput/hackrfinput.cpp | 9 +- .../limesdrinput/limesdrinputsettings.h | 6 - .../limesdrinput/limesdrinputthread.cpp | 113 ++++------------ .../limesdrinput/limesdrinputthread.h | 2 - .../plutosdrinput/plutosdrinput.cpp | 11 +- .../plutosdrinput/plutosdrinputplugin.cpp | 2 +- plugins/samplesource/rtlsdr/rtlsdrinput.cpp | 11 +- plugins/samplesource/sdrplay/sdrplayinput.cpp | 42 +++--- .../samplesource/sdrplay/sdrplayplugin.cpp | 2 +- .../testsource/testsourceinput.cpp | 20 ++- 14 files changed, 144 insertions(+), 219 deletions(-) diff --git a/plugins/samplesource/airspy/airspyinput.cpp b/plugins/samplesource/airspy/airspyinput.cpp index 926309a5a..f9e070e6c 100644 --- a/plugins/samplesource/airspy/airspyinput.cpp +++ b/plugins/samplesource/airspy/airspyinput.cpp @@ -393,23 +393,24 @@ bool AirspyInput::applySettings(const AirspySettings& settings, bool force) if ((m_settings.m_log2Decim != settings.m_log2Decim) || force) { - m_settings.m_log2Decim = settings.m_log2Decim; forwardChange = true; if (m_airspyThread != 0) { - m_airspyThread->setLog2Decimation(m_settings.m_log2Decim); - qDebug() << "AirspyInput: set decimation to " << (1<setLog2Decimation(settings.m_log2Decim); + qDebug() << "AirspyInput: set decimation to " << (1<setLog2Decimation(m_settings.m_log2Decim); - qDebug() << "BladerfInput::applySettings: set decimation to " << (1<setFcPos((int) m_settings.m_fcPos); - qDebug() << "BladerfInput::applySettings: set fc pos (enum) to " << (int) m_settings.m_fcPos; + m_bladerfThread->setFcPos((int) settings.m_fcPos); + qDebug() << "BladerfInput::applySettings: set fc pos (enum) to " << (int) settings.m_fcPos; } } - if (m_settings.m_centerFrequency != settings.m_centerFrequency) - { - forwardChange = true; - } + if ((m_settings.m_log2Decim != settings.m_log2Decim) || force) + { + m_settings.m_log2Decim = settings.m_log2Decim; + forwardChange = true; - m_settings.m_centerFrequency = settings.m_centerFrequency; + if (m_bladerfThread != 0) + { + m_bladerfThread->setLog2Decimation(m_settings.m_log2Decim); + qDebug() << "BladerfInput::applySettings: set decimation to " << (1<getDeviceEngineInputMessageQueue()->push(notif); } - qDebug() << "BladerfInput::applySettings: center freq: " << m_settings.m_centerFrequency << " Hz" - << " device center freq: " << deviceCenterFrequency << " Hz" - << " device sample rate: " << m_settings.m_devSampleRate << "S/s" - << " Actual sample rate: " << m_settings.m_devSampleRate/(1<write(m_convertBuffer.begin(), it); diff --git a/plugins/samplesource/limesdrinput/limesdrinputthread.h b/plugins/samplesource/limesdrinput/limesdrinputthread.h index 57577d78f..dd5fb3772 100644 --- a/plugins/samplesource/limesdrinput/limesdrinputthread.h +++ b/plugins/samplesource/limesdrinput/limesdrinputthread.h @@ -42,7 +42,6 @@ public: virtual void setDeviceSampleRate(int sampleRate __attribute__((unused))) {} virtual bool isRunning() { return m_running; } void setLog2Decimation(unsigned int log2_decim); - void setFcPos(int fcPos); private: QMutex m_startWaitMutex; @@ -55,7 +54,6 @@ private: SampleSinkFifo* m_sampleFifo; unsigned int m_log2Decim; // soft decimation - int m_fcPos; Decimators m_decimators; diff --git a/plugins/samplesource/plutosdrinput/plutosdrinput.cpp b/plugins/samplesource/plutosdrinput/plutosdrinput.cpp index 4e96fdf93..e0cd8d6f3 100644 --- a/plugins/samplesource/plutosdrinput/plutosdrinput.cpp +++ b/plugins/samplesource/plutosdrinput/plutosdrinput.cpp @@ -451,17 +451,18 @@ bool PlutoSDRInput::applySettings(const PlutoSDRInputSettings& settings, bool fo std::vector params; bool paramsToSet = false; - if (force || (m_settings.m_centerFrequency != settings.m_centerFrequency) - || (m_settings.m_fcPos != settings.m_fcPos) - || (m_settings.m_transverterMode != settings.m_transverterMode) - || (m_settings.m_transverterDeltaFrequency != settings.m_transverterDeltaFrequency)) + if ((m_settings.m_centerFrequency != settings.m_centerFrequency) + || (m_settings.m_fcPos != settings.m_fcPos) + || (m_settings.m_log2Decim != settings.m_log2Decim) + || (m_settings.m_transverterMode != settings.m_transverterMode) + || (m_settings.m_transverterDeltaFrequency != settings.m_transverterDeltaFrequency) || force) { qint64 deviceCenterFrequency = settings.m_centerFrequency; deviceCenterFrequency -= settings.m_transverterMode ? settings.m_transverterDeltaFrequency : 0; qint64 f_img = deviceCenterFrequency; quint32 devSampleRate = settings.m_devSampleRate; - if ((m_settings.m_log2Decim == 0) || (settings.m_fcPos == PlutoSDRInputSettings::FC_POS_CENTER)) + if ((settings.m_log2Decim == 0) || (settings.m_fcPos == PlutoSDRInputSettings::FC_POS_CENTER)) { f_img = deviceCenterFrequency; } diff --git a/plugins/samplesource/plutosdrinput/plutosdrinputplugin.cpp b/plugins/samplesource/plutosdrinput/plutosdrinputplugin.cpp index 7fedd308a..b8acbeb77 100644 --- a/plugins/samplesource/plutosdrinput/plutosdrinputplugin.cpp +++ b/plugins/samplesource/plutosdrinput/plutosdrinputplugin.cpp @@ -28,7 +28,7 @@ class DeviceSourceAPI; const PluginDescriptor PlutoSDRInputPlugin::m_pluginDescriptor = { QString("PlutoSDR Input"), - QString("3.10.1"), + QString("3.11.1"), QString("(c) Edouard Griffiths, F4EXB"), QString("https://github.com/f4exb/sdrangel"), true, diff --git a/plugins/samplesource/rtlsdr/rtlsdrinput.cpp b/plugins/samplesource/rtlsdr/rtlsdrinput.cpp index 43fbe80b3..1a36da5f7 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrinput.cpp +++ b/plugins/samplesource/rtlsdr/rtlsdrinput.cpp @@ -428,7 +428,6 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, bool force) if ((m_settings.m_log2Decim != settings.m_log2Decim) || force) { - m_settings.m_log2Decim = settings.m_log2Decim; forwardChange = true; if (m_rtlSDRThread != 0) @@ -439,14 +438,16 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, bool force) qDebug("RTLSDRInput::applySettings: log2decim set to %d", m_settings.m_log2Decim); } - if (force || (m_settings.m_centerFrequency != settings.m_centerFrequency) - || (m_settings.m_fcPos != settings.m_fcPos) - || (m_settings.m_transverterMode != settings.m_transverterMode) - || (m_settings.m_transverterDeltaFrequency != settings.m_transverterDeltaFrequency)) + if ((m_settings.m_centerFrequency != settings.m_centerFrequency) + || (m_settings.m_fcPos != settings.m_fcPos) + || (m_settings.m_log2Decim != settings.m_log2Decim) + || (m_settings.m_transverterMode != settings.m_transverterMode) + || (m_settings.m_transverterDeltaFrequency != settings.m_transverterDeltaFrequency) || force) { m_settings.m_centerFrequency = settings.m_centerFrequency; m_settings.m_transverterMode = settings.m_transverterMode; m_settings.m_transverterDeltaFrequency = settings.m_transverterDeltaFrequency; + m_settings.m_log2Decim = settings.m_log2Decim; qint64 deviceCenterFrequency = m_settings.m_centerFrequency; deviceCenterFrequency -= m_settings.m_transverterMode ? m_settings.m_transverterDeltaFrequency : 0; deviceCenterFrequency = deviceCenterFrequency < 0 ? 0 : deviceCenterFrequency; diff --git a/plugins/samplesource/sdrplay/sdrplayinput.cpp b/plugins/samplesource/sdrplay/sdrplayinput.cpp index 2ee858de0..0a029a366 100644 --- a/plugins/samplesource/sdrplay/sdrplayinput.cpp +++ b/plugins/samplesource/sdrplay/sdrplayinput.cpp @@ -512,31 +512,36 @@ bool SDRPlayInput::applySettings(const SDRPlaySettings& settings, bool forwardCh if ((m_settings.m_log2Decim != settings.m_log2Decim) || force) { - m_settings.m_log2Decim = settings.m_log2Decim; - forwardChange = true; - if (m_sdrPlayThread != 0) { m_sdrPlayThread->setLog2Decimation(m_settings.m_log2Decim); - qDebug() << "SDRPlayInput::applySettings: set decimation to " << (1<setFcPos((int) m_settings.m_fcPos); + qDebug() << "SDRPlayInput: set fc pos (enum) to " << (int) settings.m_fcPos; + } } - qint64 deviceCenterFrequency = m_settings.m_centerFrequency; - qint64 f_img = deviceCenterFrequency; - quint32 devSampleRate = SDRPlaySampleRates::getRate(m_settings.m_devSampleRateIndex); - - if (force || (m_settings.m_centerFrequency != settings.m_centerFrequency) - || (m_settings.m_LOppmTenths != settings.m_LOppmTenths) - || (m_settings.m_fcPos != settings.m_fcPos)) + if ((m_settings.m_centerFrequency != settings.m_centerFrequency) + || (m_settings.m_LOppmTenths != settings.m_LOppmTenths) + || (m_settings.m_fcPos != settings.m_fcPos) + || (m_settings.m_log2Decim != settings.m_log2Decim) || force) { m_settings.m_centerFrequency = settings.m_centerFrequency; m_settings.m_LOppmTenths = settings.m_LOppmTenths; + m_settings.m_fcPos = settings.m_fcPos; + m_settings.m_log2Decim = settings.m_log2Decim; + qint64 deviceCenterFrequency = m_settings.m_centerFrequency; + qint64 f_img = deviceCenterFrequency; + quint32 devSampleRate = SDRPlaySampleRates::getRate(m_settings.m_devSampleRateIndex); + + forwardChange = true; if ((m_settings.m_log2Decim == 0) || (settings.m_fcPos == SDRPlaySettings::FC_POS_CENTER)) { @@ -570,17 +575,6 @@ bool SDRPlayInput::applySettings(const SDRPlaySettings& settings, bool forwardCh } } - if ((m_settings.m_fcPos != settings.m_fcPos) || force) - { - m_settings.m_fcPos = settings.m_fcPos; - - if (m_sdrPlayThread != 0) - { - m_sdrPlayThread->setFcPos((int) m_settings.m_fcPos); - qDebug() << "SDRPlayInput: set fc pos (enum) to " << (int) m_settings.m_fcPos; - } - } - if ((m_settings.m_frequencyBandIndex != settings.m_frequencyBandIndex) || force) { m_settings.m_frequencyBandIndex = settings.m_frequencyBandIndex; diff --git a/plugins/samplesource/sdrplay/sdrplayplugin.cpp b/plugins/samplesource/sdrplay/sdrplayplugin.cpp index 5486eca00..ee861911e 100644 --- a/plugins/samplesource/sdrplay/sdrplayplugin.cpp +++ b/plugins/samplesource/sdrplay/sdrplayplugin.cpp @@ -25,7 +25,7 @@ const PluginDescriptor SDRPlayPlugin::m_pluginDescriptor = { QString("SDRPlay RSP1 Input"), - QString("3.9.0"), + QString("3.11.0"), QString("(c) Edouard Griffiths, F4EXB"), QString("https://github.com/f4exb/sdrangel"), true, diff --git a/plugins/samplesource/testsource/testsourceinput.cpp b/plugins/samplesource/testsource/testsourceinput.cpp index d4d66112a..57d092d7d 100644 --- a/plugins/samplesource/testsource/testsourceinput.cpp +++ b/plugins/samplesource/testsource/testsourceinput.cpp @@ -250,36 +250,34 @@ bool TestSourceInput::applySettings(const TestSourceSettings& settings, bool for if (force || (m_settings.m_centerFrequency != settings.m_centerFrequency) || (m_settings.m_fcPos != settings.m_fcPos) - || (m_settings.m_frequencyShift != settings.m_frequencyShift)) + || (m_settings.m_frequencyShift != settings.m_frequencyShift) + || (m_settings.m_log2Decim != settings.m_log2Decim) || force) { qint64 deviceCenterFrequency = settings.m_centerFrequency; deviceCenterFrequency = deviceCenterFrequency < 0 ? 0 : deviceCenterFrequency; - qint64 f_img = 0; + qint64 f_img = deviceCenterFrequency; quint32 devSampleRate = settings.m_sampleRate; - if ((settings.m_log2Decim == 0) || (settings.m_fcPos == TestSourceSettings::FC_POS_CENTER)) - { - f_img = 0; - } - else + if (settings.m_log2Decim != 0) { if (settings.m_fcPos == TestSourceSettings::FC_POS_INFRA) { deviceCenterFrequency += (devSampleRate / 4); - f_img = devSampleRate/2; + f_img = deviceCenterFrequency + devSampleRate/2; } else if (settings.m_fcPos == TestSourceSettings::FC_POS_SUPRA) { deviceCenterFrequency -= (devSampleRate / 4); - f_img = devSampleRate/2; + f_img = deviceCenterFrequency - devSampleRate/2; } } if (m_testSourceThread != 0) { m_testSourceThread->setFcPos((int) settings.m_fcPos); - m_testSourceThread->setFrequencyShift(f_img + settings.m_frequencyShift); - qDebug() << "TestSourceInput::applySettings: center freq: " << settings.m_centerFrequency << " Hz" + m_testSourceThread->setFrequencyShift(deviceCenterFrequency - settings.m_centerFrequency + settings.m_frequencyShift); + qDebug() << "TestSourceInput::applySettings:" + << " center freq: " << settings.m_centerFrequency << " Hz" << " device center freq: " << deviceCenterFrequency << " Hz" << " device sample rate: " << devSampleRate << "Hz" << " Actual sample rate: " << devSampleRate/(1<