mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-14 20:31:53 -05:00
Added basic variable decimation
This commit is contained in:
parent
f07934cc80
commit
7ea41283e8
@ -129,6 +129,15 @@ void RTLSDRGui::on_centerFrequency_changed(quint64 value)
|
|||||||
sendSettings();
|
sendSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RTLSDRGui::on_decim_valueChanged(int value)
|
||||||
|
{
|
||||||
|
if ((value <0) || (value > 4))
|
||||||
|
return;
|
||||||
|
ui->decimText->setText(tr("%1").arg(1<<value));
|
||||||
|
m_settings.m_log2Decim = value;
|
||||||
|
sendSettings();
|
||||||
|
}
|
||||||
|
|
||||||
void RTLSDRGui::on_ppm_valueChanged(int value)
|
void RTLSDRGui::on_ppm_valueChanged(int value)
|
||||||
{
|
{
|
||||||
if((value > 99) || (value < -99))
|
if((value > 99) || (value < -99))
|
||||||
|
@ -44,6 +44,7 @@ private:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_centerFrequency_changed(quint64 value);
|
void on_centerFrequency_changed(quint64 value);
|
||||||
|
void on_decim_valueChanged(int value);
|
||||||
void on_ppm_valueChanged(int value);
|
void on_ppm_valueChanged(int value);
|
||||||
void on_gain_valueChanged(int value);
|
void on_gain_valueChanged(int value);
|
||||||
void on_samplerate_valueChanged(int value);
|
void on_samplerate_valueChanged(int value);
|
||||||
|
@ -261,6 +261,59 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="Line" name="line_5">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_4" columnstretch="0,0,0">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_decim">
|
||||||
|
<property name="text">
|
||||||
|
<string>Dec.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QSlider" name="decim">
|
||||||
|
<property name="maximum">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
<property name="pageStep">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QLabel" name="decimText">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>16</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="Line" name="line">
|
<widget class="Line" name="line">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -36,6 +36,7 @@ void RTLSDRInput::Settings::resetToDefaults()
|
|||||||
m_gain = 0;
|
m_gain = 0;
|
||||||
m_samplerate = 1024000;
|
m_samplerate = 1024000;
|
||||||
m_loPpmCorrection = 0;
|
m_loPpmCorrection = 0;
|
||||||
|
m_log2Decim = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray RTLSDRInput::Settings::serialize() const
|
QByteArray RTLSDRInput::Settings::serialize() const
|
||||||
@ -44,6 +45,7 @@ QByteArray RTLSDRInput::Settings::serialize() const
|
|||||||
s.writeS32(1, m_gain);
|
s.writeS32(1, m_gain);
|
||||||
s.writeS32(2, m_samplerate);
|
s.writeS32(2, m_samplerate);
|
||||||
s.writeS32(3, m_loPpmCorrection);
|
s.writeS32(3, m_loPpmCorrection);
|
||||||
|
s.writeU32(4, m_log2Decim);
|
||||||
return s.final();
|
return s.final();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,6 +62,7 @@ bool RTLSDRInput::Settings::deserialize(const QByteArray& data)
|
|||||||
d.readS32(1, &m_gain, 0);
|
d.readS32(1, &m_gain, 0);
|
||||||
//d.readS32(2, &m_samplerate, 0);
|
//d.readS32(2, &m_samplerate, 0);
|
||||||
d.readS32(3, &m_loPpmCorrection, 0);
|
d.readS32(3, &m_loPpmCorrection, 0);
|
||||||
|
d.readU32(4, &m_log2Decim, 4);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
resetToDefaults();
|
resetToDefaults();
|
||||||
@ -186,16 +189,26 @@ const QString& RTLSDRInput::getDeviceDescription() const
|
|||||||
int RTLSDRInput::getSampleRate() const
|
int RTLSDRInput::getSampleRate() const
|
||||||
{
|
{
|
||||||
int rate = m_settings.m_samplerate;
|
int rate = m_settings.m_samplerate;
|
||||||
|
return (rate / (1<<m_settings.m_log2Decim));
|
||||||
|
/*
|
||||||
if (rate < 800000)
|
if (rate < 800000)
|
||||||
return (rate / 4);
|
return (rate / 4);
|
||||||
if ((rate == 1152000) || (rate == 2048000))
|
if ((rate == 1152000) || (rate == 2048000))
|
||||||
return (rate / 8);
|
return (rate / 8);
|
||||||
return (rate / 16);
|
return (rate / 16);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
quint64 RTLSDRInput::getCenterFrequency() const
|
quint64 RTLSDRInput::getCenterFrequency() const
|
||||||
{
|
{
|
||||||
return m_generalSettings.m_centerFrequency;
|
if (m_settings.m_log2Decim == 0) // Little wooby-doop if no decimation
|
||||||
|
{
|
||||||
|
return m_generalSettings.m_centerFrequency + (m_settings.m_samplerate / 4);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return m_generalSettings.m_centerFrequency;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RTLSDRInput::handleMessage(Message* message)
|
bool RTLSDRInput::handleMessage(Message* message)
|
||||||
@ -245,6 +258,13 @@ bool RTLSDRInput::applySettings(const GeneralSettings& generalSettings, const Se
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if((m_settings.m_log2Decim != settings.m_log2Decim) || force) {
|
||||||
|
if(m_dev != NULL) {
|
||||||
|
m_settings.m_log2Decim = settings.m_log2Decim;
|
||||||
|
m_rtlSDRThread->setLog2Decimation(settings.m_log2Decim);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_generalSettings.m_centerFrequency = generalSettings.m_centerFrequency;
|
m_generalSettings.m_centerFrequency = generalSettings.m_centerFrequency;
|
||||||
if(m_dev != NULL) {
|
if(m_dev != NULL) {
|
||||||
if(rtlsdr_set_center_freq( m_dev, m_generalSettings.m_centerFrequency
|
if(rtlsdr_set_center_freq( m_dev, m_generalSettings.m_centerFrequency
|
||||||
|
@ -30,6 +30,7 @@ public:
|
|||||||
qint32 m_gain;
|
qint32 m_gain;
|
||||||
qint32 m_samplerate;
|
qint32 m_samplerate;
|
||||||
qint32 m_loPpmCorrection;
|
qint32 m_loPpmCorrection;
|
||||||
|
quint32 m_log2Decim;
|
||||||
|
|
||||||
Settings();
|
Settings();
|
||||||
void resetToDefaults();
|
void resetToDefaults();
|
||||||
|
@ -28,7 +28,8 @@ RTLSDRThread::RTLSDRThread(rtlsdr_dev_t* dev, SampleFifo* sampleFifo, QObject* p
|
|||||||
m_dev(dev),
|
m_dev(dev),
|
||||||
m_convertBuffer(BLOCKSIZE),
|
m_convertBuffer(BLOCKSIZE),
|
||||||
m_sampleFifo(sampleFifo),
|
m_sampleFifo(sampleFifo),
|
||||||
m_samplerate(288000)
|
m_samplerate(288000),
|
||||||
|
m_log2Decim(4)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,6 +58,11 @@ void RTLSDRThread::setSamplerate(int samplerate)
|
|||||||
m_samplerate = samplerate;
|
m_samplerate = samplerate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RTLSDRThread::setLog2Decimation(unsigned int log2_decim)
|
||||||
|
{
|
||||||
|
m_log2Decim = log2_decim;
|
||||||
|
}
|
||||||
|
|
||||||
void RTLSDRThread::run()
|
void RTLSDRThread::run()
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
@ -74,6 +80,18 @@ void RTLSDRThread::run()
|
|||||||
m_running = false;
|
m_running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RTLSDRThread::decimate1(SampleVector::iterator* it, const quint8* buf, qint32 len)
|
||||||
|
{
|
||||||
|
qint16 xreal, yimag;
|
||||||
|
for (int pos = 0; pos < len; pos += 2) {
|
||||||
|
xreal = buf[pos+0];
|
||||||
|
yimag = buf[pos+1];
|
||||||
|
Sample s( xreal << 3, yimag << 3 );
|
||||||
|
**it = s;
|
||||||
|
(*it)++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RTLSDRThread::decimate2(SampleVector::iterator* it, const quint8* buf, qint32 len)
|
void RTLSDRThread::decimate2(SampleVector::iterator* it, const quint8* buf, qint32 len)
|
||||||
{
|
{
|
||||||
qint16 xreal, yimag;
|
qint16 xreal, yimag;
|
||||||
@ -146,18 +164,40 @@ void RTLSDRThread::decimate16(SampleVector::iterator* it, const quint8* buf, qin
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Decimate everything by 16x, except 288kHz by 4x
|
// Decimate according to specified log2 (ex: log2=4 => decim=16)
|
||||||
// and 1152kHz, 2048kHz by 8x
|
|
||||||
void RTLSDRThread::callback(const quint8* buf, qint32 len)
|
void RTLSDRThread::callback(const quint8* buf, qint32 len)
|
||||||
{
|
{
|
||||||
SampleVector::iterator it = m_convertBuffer.begin();
|
SampleVector::iterator it = m_convertBuffer.begin();
|
||||||
|
|
||||||
|
switch (m_log2Decim)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
decimate1(&it, buf, len);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
decimate2(&it, buf, len);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
decimate4(&it, buf, len);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
decimate8(&it, buf, len);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
decimate16(&it, buf, len);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if (m_samplerate < 800000)
|
if (m_samplerate < 800000)
|
||||||
decimate4(&it, buf, len);
|
decimate4(&it, buf, len);
|
||||||
else if ((m_samplerate == 1152000)||(m_samplerate == 2048000))
|
else if ((m_samplerate == 1152000)||(m_samplerate == 2048000))
|
||||||
decimate8(&it, buf, len);
|
decimate8(&it, buf, len);
|
||||||
else
|
else
|
||||||
decimate16(&it, buf, len);
|
decimate16(&it, buf, len);
|
||||||
|
*/
|
||||||
|
|
||||||
m_sampleFifo->write(m_convertBuffer.begin(), it);
|
m_sampleFifo->write(m_convertBuffer.begin(), it);
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ public:
|
|||||||
void startWork();
|
void startWork();
|
||||||
void stopWork();
|
void stopWork();
|
||||||
void setSamplerate(int samplerate);
|
void setSamplerate(int samplerate);
|
||||||
|
void setLog2Decimation(unsigned int log2_decim);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMutex m_startWaitMutex;
|
QMutex m_startWaitMutex;
|
||||||
@ -46,11 +47,13 @@ private:
|
|||||||
SampleFifo* m_sampleFifo;
|
SampleFifo* m_sampleFifo;
|
||||||
|
|
||||||
int m_samplerate;
|
int m_samplerate;
|
||||||
|
unsigned int m_log2Decim;
|
||||||
|
|
||||||
IntHalfbandFilter m_decimator2;
|
IntHalfbandFilter m_decimator2;
|
||||||
IntHalfbandFilter m_decimator4;
|
IntHalfbandFilter m_decimator4;
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
|
void decimate1(SampleVector::iterator* it, const quint8* buf, qint32 len);
|
||||||
void decimate2(SampleVector::iterator* it, const quint8* buf, qint32 len);
|
void decimate2(SampleVector::iterator* it, const quint8* buf, qint32 len);
|
||||||
void decimate4(SampleVector::iterator* it, const quint8* buf, qint32 len);
|
void decimate4(SampleVector::iterator* it, const quint8* buf, qint32 len);
|
||||||
void decimate8(SampleVector::iterator* it, const quint8* buf, qint32 len);
|
void decimate8(SampleVector::iterator* it, const quint8* buf, qint32 len);
|
||||||
|
Loading…
Reference in New Issue
Block a user