1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-25 09:18:54 -05:00

FCD: implemented decimation

This commit is contained in:
f4exb 2019-01-04 15:12:35 +01:00
parent b5a7425f1e
commit 050ae9d2e8
19 changed files with 260 additions and 46 deletions

View File

@ -34,8 +34,8 @@ const char *fcd_traits<ProPlus>::displayedName = "FunCube Dongle Pro+";
const char *fcd_traits<Pro>::pluginDisplayedName = "FunCube Pro Input";
const char *fcd_traits<ProPlus>::pluginDisplayedName = "FunCube Pro+ Input";
const char *fcd_traits<Pro>::pluginVersion = "4.3.2";
const char *fcd_traits<ProPlus>::pluginVersion = "4.3.2";
const char *fcd_traits<Pro>::pluginVersion = "4.4.0";
const char *fcd_traits<ProPlus>::pluginVersion = "4.4.0";
const int64_t fcd_traits<Pro>::loLowLimitFreq = 64000000L;
const int64_t fcd_traits<ProPlus>::loLowLimitFreq = 150000L;

View File

@ -30,7 +30,7 @@ class DeviceSourceAPI;
const PluginDescriptor PlutoSDROutputPlugin::m_pluginDescriptor = {
QString("PlutoSDR Output"),
QString("4.3.2"),
QString("4.4.0"),
QString("(c) Edouard Griffiths, F4EXB"),
QString("https://github.com/f4exb/sdrangel"),
true,

View File

@ -308,6 +308,7 @@ void FCDProGui::displaySettings()
ui->gain4->setCurrentIndex(m_settings.m_gain4Index);
ui->gain5->setCurrentIndex(m_settings.m_gain5Index);
ui->gain6->setCurrentIndex(m_settings.m_gain6Index);
ui->decim->setCurrentIndex(m_settings.m_log2Decim);
ui->rcFilter->setCurrentIndex(m_settings.m_rcFilterIndex);
ui->ifFilter->setCurrentIndex(m_settings.m_ifFilterIndex);
}
@ -439,6 +440,16 @@ void FCDProGui::on_gain6_currentIndexChanged(int index)
sendSettings();
}
void FCDProGui::on_decim_currentIndexChanged(int index)
{
if ((index < 0) || (index > 6)) {
return;
}
m_settings.m_log2Decim = index;
sendSettings();
}
void FCDProGui::on_setDefaults_clicked(bool checked)
{
(void) checked;

View File

@ -96,6 +96,7 @@ private slots:
void on_ifFilter_currentIndexChanged(int index);
void on_gain5_currentIndexChanged(int index);
void on_gain6_currentIndexChanged(int index);
void on_decim_currentIndexChanged(int index);
void on_setDefaults_clicked(bool checked);
void on_startStop_toggled(bool checked);
void on_record_toggled(bool checked);

View File

@ -224,7 +224,7 @@
<string>DC offset auto correction</string>
</property>
<property name="text">
<string>DC offset</string>
<string>DC</string>
</property>
</widget>
</item>
@ -234,10 +234,63 @@
<string>IQ imbalance auto correction</string>
</property>
<property name="text">
<string>IQ imbalance</string>
<string>IQ</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="labelDecim">
<property name="text">
<string>Dec</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="decim">
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Decimation factor</string>
</property>
<item>
<property name="text">
<string>1</string>
</property>
</item>
<item>
<property name="text">
<string>2</string>
</property>
</item>
<item>
<property name="text">
<string>4</string>
</property>
</item>
<item>
<property name="text">
<string>8</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="TransverterButton" name="transverter">
<property name="maximumSize">

View File

@ -235,7 +235,7 @@ const QString& FCDProInput::getDeviceDescription() const
int FCDProInput::getSampleRate() const
{
return fcd_traits<Pro>::sampleRate;
return fcd_traits<Pro>::sampleRate/(1<<m_settings.m_log2Decim);
}
quint64 FCDProInput::getCenterFrequency() const
@ -354,6 +354,18 @@ void FCDProInput::applySettings(const FCDProSettings& settings, bool force)
m_settings.m_centerFrequency = settings.m_centerFrequency;
}
if ((m_settings.m_log2Decim != settings.m_log2Decim) || force)
{
reverseAPIKeys.append("log2Decim");
forwardChange = true;
if (m_FCDThread != 0)
{
m_FCDThread->setLog2Decimation(settings.m_log2Decim);
qDebug() << "FCDProInput::applySettings: set decimation to " << (1<<settings.m_log2Decim);
}
}
if ((m_settings.m_lnaGainIndex != settings.m_lnaGainIndex) || force)
{
reverseAPIKeys.append("lnaGainIndex");
@ -533,7 +545,7 @@ void FCDProInput::applySettings(const FCDProSettings& settings, bool force)
if (forwardChange)
{
DSPSignalNotification *notif = new DSPSignalNotification(fcd_traits<Pro>::sampleRate, m_settings.m_centerFrequency);
DSPSignalNotification *notif = new DSPSignalNotification(fcd_traits<Pro>::sampleRate/(1<<m_settings.m_log2Decim), m_settings.m_centerFrequency);
m_fileSink->handleMessage(*notif); // forward to file sink
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
}

View File

@ -45,6 +45,7 @@ void FCDProSettings::resetToDefaults()
m_ifFilterIndex = 0;
m_gain5Index = 0;
m_gain6Index = 0;
m_log2Decim = 0;
m_transverterMode = false;
m_transverterDeltaFrequency = 0;
m_fileRecordName = "";
@ -77,12 +78,13 @@ QByteArray FCDProSettings::serialize() const
s.writeS32(17, m_ifFilterIndex);
s.writeS32(18, m_gain5Index);
s.writeS32(19, m_gain6Index);
s.writeBool(20, m_transverterMode);
s.writeS64(21, m_transverterDeltaFrequency);
s.writeBool(22, m_useReverseAPI);
s.writeString(23, m_reverseAPIAddress);
s.writeU32(24, m_reverseAPIPort);
s.writeU32(25, m_reverseAPIDeviceIndex);
s.writeU32(20, m_log2Decim);
s.writeBool(21, m_transverterMode);
s.writeS64(22, m_transverterDeltaFrequency);
s.writeBool(23, m_useReverseAPI);
s.writeString(24, m_reverseAPIAddress);
s.writeU32(25, m_reverseAPIPort);
s.writeU32(26, m_reverseAPIDeviceIndex);
return s.final();
}
@ -120,11 +122,12 @@ bool FCDProSettings::deserialize(const QByteArray& data)
d.readS32(17, &m_ifFilterIndex, 0);
d.readS32(18, &m_gain5Index, 0);
d.readS32(19, &m_gain6Index, 0);
d.readBool(20, &m_transverterMode, false);
d.readS64(21, &m_transverterDeltaFrequency, 0);
d.readBool(22, &m_useReverseAPI, false);
d.readString(23, &m_reverseAPIAddress, "127.0.0.1");
d.readU32(24, &uintval, 0);
d.readU32(20, &m_log2Decim, 0);
d.readBool(21, &m_transverterMode, false);
d.readS64(22, &m_transverterDeltaFrequency, 0);
d.readBool(23, &m_useReverseAPI, false);
d.readString(24, &m_reverseAPIAddress, "127.0.0.1");
d.readU32(25, &uintval, 0);
if ((uintval > 1023) && (uintval < 65535)) {
m_reverseAPIPort = uintval;
@ -132,7 +135,7 @@ bool FCDProSettings::deserialize(const QByteArray& data)
m_reverseAPIPort = 8888;
}
d.readU32(25, &uintval, 0);
d.readU32(26, &uintval, 0);
m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval;
return true;

View File

@ -38,6 +38,7 @@ struct FCDProSettings {
qint32 m_ifFilterIndex;
qint32 m_gain5Index;
qint32 m_gain6Index;
quint32 m_log2Decim;
bool m_dcBlock;
bool m_iqCorrection;
bool m_transverterMode;

View File

@ -60,6 +60,11 @@ void FCDProThread::stopWork()
wait();
}
void FCDProThread::setLog2Decimation(unsigned int log2_decim)
{
m_log2Decim = log2_decim;
}
void FCDProThread::run()
{
m_running = true;
@ -79,6 +84,24 @@ void FCDProThread::work(unsigned int n_items)
{
uint32_t nbRead = m_fcdFIFO->read((unsigned char *) m_buf, n_items); // number of samples
SampleVector::iterator it = m_convertBuffer.begin();
m_decimators.decimate1(&it, m_buf, 2*nbRead);
switch (m_log2Decim)
{
case 0:
m_decimators.decimate1(&it, m_buf, 2*nbRead);
break;
case 1:
m_decimators.decimate2_cen(&it, m_buf, 2*nbRead);
break;
case 2:
m_decimators.decimate4_cen(&it, m_buf, 2*nbRead);
break;
case 3:
m_decimators.decimate8_cen(&it, m_buf, 2*nbRead);
break;
default:
break;
}
m_sampleFifo->write(m_convertBuffer.begin(), it);
}

View File

@ -36,6 +36,7 @@ public:
void startWork();
void stopWork();
void setLog2Decimation(unsigned int log2_decim);
private:
AudioFifo* m_fcdFIFO;
@ -43,6 +44,7 @@ private:
QMutex m_startWaitMutex;
QWaitCondition m_startWaiter;
bool m_running;
unsigned int m_log2Decim;
qint16 m_buf[fcd_traits<Pro>::convBufSize*2]; // stereo (I, Q)
SampleVector m_convertBuffer;

View File

@ -209,6 +209,7 @@ void FCDProPlusGui::displaySettings()
ui->transverter->setDeltaFrequencyActive(m_settings.m_transverterMode);
updateFrequencyLimits();
ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000);
ui->decim->setCurrentIndex(m_settings.m_log2Decim);
ui->dcOffset->setChecked(m_settings.m_dcBlock);
ui->iqImbalance->setChecked(m_settings.m_iqImbalance);
ui->checkBoxG->setChecked(m_settings.m_lnaGain);
@ -234,6 +235,16 @@ void FCDProPlusGui::on_centerFrequency_changed(quint64 value)
sendSettings();
}
void FCDProPlusGui::on_decim_currentIndexChanged(int index)
{
if ((index < 0) || (index > 6)) {
return;
}
m_settings.m_log2Decim = index;
sendSettings();
}
void FCDProPlusGui::on_dcOffset_toggled(bool checked)
{
m_settings.m_dcBlock = checked;

View File

@ -75,6 +75,7 @@ private:
private slots:
void handleInputMessages();
void on_centerFrequency_changed(quint64 value);
void on_decim_currentIndexChanged(int index);
void on_dcOffset_toggled(bool checked);
void on_iqImbalance_toggled(bool checked);
void on_checkBoxG_stateChanged(int state);

View File

@ -224,7 +224,7 @@
<string>Automatic DC offset removal</string>
</property>
<property name="text">
<string>DC offset</string>
<string>DC</string>
</property>
</widget>
</item>
@ -234,10 +234,62 @@
<string>Automatic IQ imbalance correction</string>
</property>
<property name="text">
<string>IQ imbalance</string>
<string>IQ</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="labelDecim">
<property name="text">
<string>Dec</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="decim">
<property name="toolTip">
<string>Decimation factor</string>
</property>
<item>
<property name="text">
<string>1</string>
</property>
</item>
<item>
<property name="text">
<string>2</string>
</property>
</item>
<item>
<property name="text">
<string>4</string>
</property>
</item>
<item>
<property name="text">
<string>8</string>
</property>
</item>
<item>
<property name="text">
<string>16</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="TransverterButton" name="transverter">
<property name="maximumSize">

View File

@ -237,7 +237,7 @@ const QString& FCDProPlusInput::getDeviceDescription() const
int FCDProPlusInput::getSampleRate() const
{
return fcd_traits<ProPlus>::sampleRate;
return fcd_traits<ProPlus>::sampleRate/(1<<m_settings.m_log2Decim);
}
quint64 FCDProPlusInput::getCenterFrequency() const
@ -355,6 +355,18 @@ void FCDProPlusInput::applySettings(const FCDProPlusSettings& settings, bool for
m_settings.m_centerFrequency = settings.m_centerFrequency;
}
if ((m_settings.m_log2Decim != settings.m_log2Decim) || force)
{
reverseAPIKeys.append("log2Decim");
forwardChange = true;
if (m_FCDThread != 0)
{
m_FCDThread->setLog2Decimation(settings.m_log2Decim);
qDebug() << "FCDProPlusInput::applySettings: set decimation to " << (1<<settings.m_log2Decim);
}
}
if ((m_settings.m_lnaGain != settings.m_lnaGain) || force)
{
reverseAPIKeys.append("lnaGain");
@ -444,7 +456,7 @@ void FCDProPlusInput::applySettings(const FCDProPlusSettings& settings, bool for
if (forwardChange)
{
DSPSignalNotification *notif = new DSPSignalNotification(fcd_traits<ProPlus>::sampleRate, m_settings.m_centerFrequency);
DSPSignalNotification *notif = new DSPSignalNotification(fcd_traits<ProPlus>::sampleRate/(1<<settings.m_log2Decim), m_settings.m_centerFrequency);
m_fileSink->handleMessage(*notif); // forward to file sink
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
}

View File

@ -34,6 +34,7 @@ void FCDProPlusSettings::resetToDefaults()
m_rfFilterIndex = 0;
m_ifFilterIndex = 0;
m_LOppmTenths = 0;
m_log2Decim = 0;
m_dcBlock = false;
m_iqImbalance = false;
m_transverterMode = false;
@ -54,16 +55,17 @@ QByteArray FCDProPlusSettings::serialize() const
s.writeBool(3, m_mixGain);
s.writeS32(4, m_ifFilterIndex);
s.writeS32(5, m_rfFilterIndex);
s.writeBool(6, m_dcBlock);
s.writeBool(7, m_iqImbalance);
s.writeS32(8, m_LOppmTenths);
s.writeU32(9, m_ifGain);
s.writeBool(10, m_transverterMode);
s.writeS64(11, m_transverterDeltaFrequency);
s.writeBool(12, m_useReverseAPI);
s.writeString(13, m_reverseAPIAddress);
s.writeU32(14, m_reverseAPIPort);
s.writeU32(15, m_reverseAPIDeviceIndex);
s.writeU32(6, m_log2Decim);
s.writeBool(7, m_dcBlock);
s.writeBool(8, m_iqImbalance);
s.writeS32(9, m_LOppmTenths);
s.writeU32(10, m_ifGain);
s.writeBool(11, m_transverterMode);
s.writeS64(12, m_transverterDeltaFrequency);
s.writeBool(13, m_useReverseAPI);
s.writeString(14, m_reverseAPIAddress);
s.writeU32(15, m_reverseAPIPort);
s.writeU32(16, m_reverseAPIDeviceIndex);
return s.final();
}
@ -87,15 +89,16 @@ bool FCDProPlusSettings::deserialize(const QByteArray& data)
d.readBool(3, &m_mixGain, true);
d.readS32(4, &m_ifFilterIndex, 0);
d.readS32(5, &m_rfFilterIndex, 0);
d.readBool(6, &m_dcBlock, false);
d.readBool(7, &m_iqImbalance, false);
d.readS32(8, &m_LOppmTenths, 0);
d.readU32(9, &m_ifGain, 0);
d.readBool(10, &m_transverterMode, false);
d.readS64(11, &m_transverterDeltaFrequency, 0);
d.readBool(12, &m_useReverseAPI, false);
d.readString(13, &m_reverseAPIAddress, "127.0.0.1");
d.readU32(14, &uintval, 0);
d.readU32(6, &m_log2Decim, 0);
d.readBool(7, &m_dcBlock, false);
d.readBool(8, &m_iqImbalance, false);
d.readS32(9, &m_LOppmTenths, 0);
d.readU32(10, &m_ifGain, 0);
d.readBool(11, &m_transverterMode, false);
d.readS64(12, &m_transverterDeltaFrequency, 0);
d.readBool(13, &m_useReverseAPI, false);
d.readString(14, &m_reverseAPIAddress, "127.0.0.1");
d.readU32(15, &uintval, 0);
if ((uintval > 1023) && (uintval < 65535)) {
m_reverseAPIPort = uintval;
@ -103,7 +106,7 @@ bool FCDProPlusSettings::deserialize(const QByteArray& data)
m_reverseAPIPort = 8888;
}
d.readU32(15, &uintval, 0);
d.readU32(16, &uintval, 0);
m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval;
return true;
}

View File

@ -29,6 +29,7 @@ struct FCDProPlusSettings {
qint32 m_ifFilterIndex;
qint32 m_rfFilterIndex;
qint32 m_LOppmTenths;
quint32 m_log2Decim;
bool m_dcBlock;
bool m_iqImbalance;
bool m_transverterMode;

View File

@ -59,6 +59,11 @@ void FCDProPlusThread::stopWork()
wait();
}
void FCDProPlusThread::setLog2Decimation(unsigned int log2_decim)
{
m_log2Decim = log2_decim;
}
void FCDProPlusThread::run()
{
m_running = true;
@ -78,6 +83,27 @@ void FCDProPlusThread::work(unsigned int n_items)
{
uint32_t nbRead = m_fcdFIFO->read((unsigned char *) m_buf, n_items); // number of samples
SampleVector::iterator it = m_convertBuffer.begin();
m_decimators.decimate1(&it, m_buf, 2*nbRead);
switch (m_log2Decim)
{
case 0:
m_decimators.decimate1(&it, m_buf, 2*nbRead);
break;
case 1:
m_decimators.decimate2_cen(&it, m_buf, 2*nbRead);
break;
case 2:
m_decimators.decimate4_cen(&it, m_buf, 2*nbRead);
break;
case 3:
m_decimators.decimate8_cen(&it, m_buf, 2*nbRead);
break;
case 4:
m_decimators.decimate16_cen(&it, m_buf, 2*nbRead);
break;
default:
break;
}
m_sampleFifo->write(m_convertBuffer.begin(), it);
}

View File

@ -37,6 +37,7 @@ public:
void startWork();
void stopWork();
void setLog2Decimation(unsigned int log2_decim);
private:
AudioFifo* m_fcdFIFO;
@ -44,6 +45,7 @@ private:
QMutex m_startWaitMutex;
QWaitCondition m_startWaiter;
bool m_running;
unsigned int m_log2Decim;
qint16 m_buf[fcd_traits<ProPlus>::convBufSize*2]; // stereo (I, Q)
SampleVector m_convertBuffer;

View File

@ -30,7 +30,7 @@ class DeviceSourceAPI;
const PluginDescriptor PlutoSDRInputPlugin::m_pluginDescriptor = {
QString("PlutoSDR Input"),
QString("4.3.2"),
QString("4.4.0"),
QString("(c) Edouard Griffiths, F4EXB"),
QString("https://github.com/f4exb/sdrangel"),
true,