1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-15 21:01:45 -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; m_inputFrequencyOffset = 0;
SSBFilter = new fftfilt(m_settings.m_lowCutoff / m_inputSampleRate, m_settings.m_bandwidth / m_inputSampleRate, ssbFftLen); 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); 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.05f, 0.707f, 1000.0f); // bandwidth, damping factor, loop gain
m_pll.computeCoefficients(0.002f, 0.5f, 10.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) if (!(m_undersampleCount++ & (decim - 1))) // counter LSB bit mask for decimation by 2^(m_scaleLog2 - 1)
{ {
m_sum /= decim; m_sum /= decim;
Real re = m_sum.real() / SDR_RX_SCALED; Real re = m_sum.real() / SDR_RX_SCALEF;
Real im = m_sum.imag() / SDR_RX_SCALED; Real im = m_sum.imag() / SDR_RX_SCALEF;
m_magsq = re*re + im*im; m_magsq = re*re + im*im;
std::complex<float> mix; std::complex<float> mix;
@ -306,7 +307,8 @@ void ChannelAnalyzerNG::applySettings(const ChannelAnalyzerNGSettings& settings,
<< " m_ssb: " << settings.m_ssb << " m_ssb: " << settings.m_ssb
<< " m_pll: " << settings.m_pll << " m_pll: " << settings.m_pll
<< " m_fll: " << settings.m_fll << " 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) if ((settings.m_downSampleRate != m_settings.m_downSampleRate) || force)
{ {

View File

@ -24,6 +24,7 @@
#include "channel/channelsinkapi.h" #include "channel/channelsinkapi.h"
#include "dsp/interpolator.h" #include "dsp/interpolator.h"
#include "dsp/ncof.h" #include "dsp/ncof.h"
#include "dsp/fftcorr.h"
#include "dsp/fftfilt.h" #include "dsp/fftfilt.h"
#include "dsp/phaselockcomplex.h" #include "dsp/phaselockcomplex.h"
#include "dsp/freqlockcomplex.h" #include "dsp/freqlockcomplex.h"
@ -230,6 +231,7 @@ private:
fftfilt* SSBFilter; fftfilt* SSBFilter;
fftfilt* DSBFilter; fftfilt* DSBFilter;
fftcorr* m_corr;
BasebandSampleSink* m_sampleSink; BasebandSampleSink* m_sampleSink;
SampleVector m_sampleBuffer; SampleVector m_sampleBuffer;
@ -248,9 +250,20 @@ private:
case ChannelAnalyzerNGSettings::InputPLL: case ChannelAnalyzerNGSettings::InputPLL:
{ {
if (m_settings.m_ssb & !m_usb) { // invert spectrum for LSB 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 { } 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; 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) void ChannelAnalyzerNGGUI::on_deltaFrequency_changed(qint64 value)
{ {
m_channelMarker.setCenterFrequency(value); m_channelMarker.setCenterFrequency(value);

View File

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

View File

@ -356,6 +356,28 @@
</property> </property>
</widget> </widget>
</item> </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> </layout>
</item> </item>
<item> <item>

View File

@ -45,6 +45,7 @@ void fftcorr::init_fft()
inptrA = 0; inptrA = 0;
inptrB = 0; inptrB = 0;
outptr = 0;
} }
fftcorr::fftcorr(int len) : flen(len), flen2(len>>1) 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; *out = output;
return flen2; 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(); ~fftcorr();
int run(const cmplx& inA, const cmplx* inB, cmplx **out); //!< if inB = 0 then run auto-correlation 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: private:
void init_fft(); void init_fft();
@ -51,6 +52,7 @@ private:
cmplx *output; cmplx *output;
int inptrA; int inptrA;
int inptrB; int inptrB;
int outptr;
}; };