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

Channel analyzer NG: implemented input source selection

This commit is contained in:
f4exb 2018-05-20 18:17:53 +02:00
parent cbda404926
commit f600f78c0f
7 changed files with 63 additions and 5 deletions

View File

@ -52,6 +52,7 @@ ChannelAnalyzerNG::ChannelAnalyzerNG(DeviceSourceAPI *deviceAPI) :
m_inputFrequencyOffset = 0;
SSBFilter = new fftfilt(m_settings.m_lowCutoff / m_inputSampleRate, m_settings.m_bandwidth / m_inputSampleRate, ssbFftLen);
DSBFilter = new fftfilt(m_settings.m_bandwidth / m_inputSampleRate, 2*ssbFftLen);
m_corr = new fftcorr(4*ssbFftLen);
//m_pll.computeCoefficients(0.05f, 0.707f, 1000.0f); // bandwidth, damping factor, loop gain
m_pll.computeCoefficients(0.002f, 0.5f, 10.0f); // bandwidth, damping factor, loop gain
@ -145,8 +146,8 @@ void ChannelAnalyzerNG::processOneSample(Complex& c, fftfilt::cmplx *sideband)
if (!(m_undersampleCount++ & (decim - 1))) // counter LSB bit mask for decimation by 2^(m_scaleLog2 - 1)
{
m_sum /= decim;
Real re = m_sum.real() / SDR_RX_SCALED;
Real im = m_sum.imag() / SDR_RX_SCALED;
Real re = m_sum.real() / SDR_RX_SCALEF;
Real im = m_sum.imag() / SDR_RX_SCALEF;
m_magsq = re*re + im*im;
std::complex<float> mix;
@ -306,7 +307,8 @@ void ChannelAnalyzerNG::applySettings(const ChannelAnalyzerNGSettings& settings,
<< " m_ssb: " << settings.m_ssb
<< " m_pll: " << settings.m_pll
<< " m_fll: " << settings.m_fll
<< " m_pllPskOrder: " << settings.m_pllPskOrder;
<< " m_pllPskOrder: " << settings.m_pllPskOrder
<< " m_inputType: " << (int) settings.m_inputType;
if ((settings.m_downSampleRate != m_settings.m_downSampleRate) || force)
{

View File

@ -24,6 +24,7 @@
#include "channel/channelsinkapi.h"
#include "dsp/interpolator.h"
#include "dsp/ncof.h"
#include "dsp/fftcorr.h"
#include "dsp/fftfilt.h"
#include "dsp/phaselockcomplex.h"
#include "dsp/freqlockcomplex.h"
@ -230,6 +231,7 @@ private:
fftfilt* SSBFilter;
fftfilt* DSBFilter;
fftcorr* m_corr;
BasebandSampleSink* m_sampleSink;
SampleVector m_sampleBuffer;
@ -248,9 +250,20 @@ private:
case ChannelAnalyzerNGSettings::InputPLL:
{
if (m_settings.m_ssb & !m_usb) { // invert spectrum for LSB
m_sampleBuffer.push_back(Sample(pll.imag(), pll.real()));
m_sampleBuffer.push_back(Sample(pll.imag()*SDR_RX_SCALEF, pll.real()*SDR_RX_SCALEF));
} else {
m_sampleBuffer.push_back(Sample(pll.real(), pll.imag()));
m_sampleBuffer.push_back(Sample(pll.real()*SDR_RX_SCALEF, pll.imag()*SDR_RX_SCALEF));
}
}
break;
case ChannelAnalyzerNGSettings::InputAutoCorr:
{
std::complex<float> a = m_corr->run(s/(SDR_RX_SCALEF/1024.0f), 0);
if (m_settings.m_ssb & !m_usb) { // invert spectrum for LSB
m_sampleBuffer.push_back(Sample(a.imag(), a.real()));
} else {
m_sampleBuffer.push_back(Sample(a.real(), a.imag()));
}
}
break;

View File

@ -277,6 +277,12 @@ int ChannelAnalyzerNGGUI::getRequestedChannelSampleRate()
}
}
void ChannelAnalyzerNGGUI::on_signalSelect_currentIndexChanged(int index)
{
m_settings.m_inputType = (ChannelAnalyzerNGSettings::InputType) index;
applySettings();
}
void ChannelAnalyzerNGGUI::on_deltaFrequency_changed(qint64 value)
{
m_channelMarker.setCenterFrequency(value);

View File

@ -98,6 +98,7 @@ private slots:
void on_pll_toggled(bool checked);
void on_pllPskOrder_currentIndexChanged(int index);
void on_useRationalDownsampler_toggled(bool checked);
void on_signalSelect_currentIndexChanged(int index);
void on_BW_valueChanged(int value);
void on_lowCut_valueChanged(int value);
void on_spanLog2_currentIndexChanged(int index);

View File

@ -356,6 +356,28 @@
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="signalSelect">
<property name="toolTip">
<string>Select input signal</string>
</property>
<item>
<property name="text">
<string>Sig</string>
</property>
</item>
<item>
<property name="text">
<string>Lock</string>
</property>
</item>
<item>
<property name="text">
<string>ACorr</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>

View File

@ -45,6 +45,7 @@ void fftcorr::init_fft()
inptrA = 0;
inptrB = 0;
outptr = 0;
}
fftcorr::fftcorr(int len) : flen(len), flen2(len>>1)
@ -110,3 +111,14 @@ int fftcorr::run(const cmplx& inA, const cmplx* inB, cmplx **out)
*out = output;
return flen2;
}
const fftcorr::cmplx& fftcorr::run(const cmplx& inA, const cmplx* inB)
{
cmplx *dummy;
if (run(inA, inB, &dummy)) {
outptr = 0;
}
return output[outptr++];
}

View File

@ -36,6 +36,7 @@ public:
~fftcorr();
int run(const cmplx& inA, const cmplx* inB, cmplx **out); //!< if inB = 0 then run auto-correlation
const cmplx& run(const cmplx& inA, const cmplx* inB);
private:
void init_fft();
@ -51,6 +52,7 @@ private:
cmplx *output;
int inptrA;
int inptrB;
int outptr;
};