Specify Scope and Spectrum Vis floating point sample scale

pull/136/head
f4exb 2018-01-22 14:07:24 +01:00
rodzic 61a16eade9
commit a47587e16f
17 zmienionych plików z 45 dodań i 29 usunięć

Wyświetl plik

@ -338,8 +338,8 @@ ChannelAnalyzerGUI::ChannelAnalyzerGUI(PluginAPI* pluginAPI, DeviceUISet *device
setAttribute(Qt::WA_DeleteOnClose, true);
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
m_spectrumVis = new SpectrumVis(ui->glSpectrum);
m_scopeVis = new ScopeVis(ui->glScope);
m_spectrumVis = new SpectrumVis(SDR_RX_SCALEF, ui->glSpectrum);
m_scopeVis = new ScopeVis(SDR_RX_SCALEF, ui->glScope);
m_spectrumScopeComboVis = new SpectrumScopeComboVis(m_spectrumVis, m_scopeVis);
m_channelAnalyzer = (ChannelAnalyzer*) rxChannel; //new ChannelAnalyzer(m_deviceUISet->m_deviceSourceAPI);
m_channelAnalyzer->setSampleSink(m_spectrumScopeComboVis);

Wyświetl plik

@ -395,7 +395,7 @@ ChannelAnalyzerNGGUI::ChannelAnalyzerNGGUI(PluginAPI* pluginAPI, DeviceUISet *de
setAttribute(Qt::WA_DeleteOnClose, true);
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
m_spectrumVis = new SpectrumVis(ui->glSpectrum);
m_spectrumVis = new SpectrumVis(SDR_RX_SCALEF, ui->glSpectrum);
m_scopeVis = new ScopeVisNG(ui->glScope);
m_spectrumScopeComboVis = new SpectrumScopeNGComboVis(m_spectrumVis, m_scopeVis);
m_channelAnalyzer = (ChannelAnalyzerNG*) rxChannel; //new ChannelAnalyzerNG(m_deviceUISet->m_deviceSourceAPI);

Wyświetl plik

@ -344,7 +344,7 @@ BFMDemodGUI::BFMDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
m_spectrumVis = new SpectrumVis(ui->glSpectrum);
m_spectrumVis = new SpectrumVis(SDR_RX_SCALEF, ui->glSpectrum);
m_bfmDemod = (BFMDemod*) rxChannel; //new BFMDemod(m_deviceUISet->m_deviceSourceAPI);
m_bfmDemod->setMessageQueueToGUI(getInputMessageQueue());
m_bfmDemod->setSampleSink(m_spectrumVis);

Wyświetl plik

@ -269,7 +269,7 @@ DSDDemodGUI::DSDDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
m_scopeVis = new ScopeVis(ui->glScope);
m_scopeVis = new ScopeVis(SDR_RX_SCALEF, ui->glScope);
m_dsdDemod = (DSDDemod*) rxChannel; //new DSDDemod(m_deviceUISet->m_deviceSourceAPI);
m_dsdDemod->setScopeSink(m_scopeVis);
m_dsdDemod->setMessageQueueToGUI(getInputMessageQueue());

Wyświetl plik

@ -117,7 +117,7 @@ LoRaDemodGUI::LoRaDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseb
setAttribute(Qt::WA_DeleteOnClose, true);
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
m_spectrumVis = new SpectrumVis(ui->glSpectrum);
m_spectrumVis = new SpectrumVis(SDR_RX_SCALEF, ui->glSpectrum);
m_LoRaDemod = (LoRaDemod*) rxChannel; //new LoRaDemod(m_deviceUISet->m_deviceSourceAPI);
m_LoRaDemod->setSpectrumSink(m_spectrumVis);

Wyświetl plik

@ -244,7 +244,7 @@ SSBDemodGUI::SSBDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
m_spectrumVis = new SpectrumVis(ui->glSpectrum);
m_spectrumVis = new SpectrumVis(SDR_RX_SCALEF, ui->glSpectrum);
m_ssbDemod = (SSBDemod*) rxChannel; //new SSBDemod(m_deviceUISet->m_deviceSourceAPI);
m_ssbDemod->setMessageQueueToGUI(getInputMessageQueue());
m_ssbDemod->setSampleSink(m_spectrumVis);

Wyświetl plik

@ -132,7 +132,7 @@ TCPSrcGUI::TCPSrcGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSam
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
setAttribute(Qt::WA_DeleteOnClose, true);
m_spectrumVis = new SpectrumVis(ui->glSpectrum);
m_spectrumVis = new SpectrumVis(SDR_RX_SCALEF, ui->glSpectrum);
m_tcpSrc = (TCPSrc*) rxChannel; //new TCPSrc(m_deviceUISet->m_deviceSourceAPI);
m_tcpSrc->setSpectrum(m_spectrumVis);

Wyświetl plik

@ -147,7 +147,7 @@ UDPSrcGUI::UDPSrcGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSam
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
setAttribute(Qt::WA_DeleteOnClose, true);
m_spectrumVis = new SpectrumVis(ui->glSpectrum);
m_spectrumVis = new SpectrumVis(SDR_RX_SCALEF, ui->glSpectrum);
m_udpSrc = (UDPSrc*) rxChannel; //new UDPSrc(m_deviceUISet->m_deviceSourceAPI);
m_udpSrc->setSpectrum(m_spectrumVis);

Wyświetl plik

@ -364,7 +364,7 @@ SSBModGUI::SSBModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSam
setAttribute(Qt::WA_DeleteOnClose, true);
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
m_spectrumVis = new SpectrumVis(ui->glSpectrum);
m_spectrumVis = new SpectrumVis(SDR_TX_SCALEF, ui->glSpectrum);
m_ssbMod = (SSBMod*) channelTx; //new SSBMod(m_deviceUISet->m_deviceSinkAPI);
m_ssbMod->setSpectrumSampleSink(m_spectrumVis);
m_ssbMod->setMessageQueueToGUI(getInputMessageQueue());

Wyświetl plik

@ -119,7 +119,7 @@ UDPSinkGUI::UDPSinkGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandS
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
setAttribute(Qt::WA_DeleteOnClose, true);
m_spectrumVis = new SpectrumVis(ui->glSpectrum);
m_spectrumVis = new SpectrumVis(SDR_TX_SCALEF, ui->glSpectrum);
m_udpSink = (UDPSink*) channelTx; //new UDPSink(m_deviceUISet->m_deviceSinkAPI);
m_udpSink->setSpectrumSink(m_spectrumVis);
m_udpSink->setMessageQueueToGUI(getInputMessageQueue());

Wyświetl plik

@ -35,7 +35,11 @@
DeviceUISet::DeviceUISet(int tabIndex, bool rxElseTx, QTimer& timer)
{
m_spectrum = new GLSpectrum;
m_spectrumVis = new SpectrumVis(m_spectrum);
if (rxElseTx) {
m_spectrumVis = new SpectrumVis(SDR_RX_SCALEF, m_spectrum);
} else {
m_spectrumVis = new SpectrumVis(SDR_TX_SCALEF, m_spectrum);
}
m_spectrum->connectTimer(timer);
m_spectrumGUI = new GLSpectrumGUI;
m_spectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, m_spectrum);

Wyświetl plik

@ -17,8 +17,9 @@ MESSAGE_CLASS_DEFINITION(ScopeVis::MsgConfigureScopeVis, Message)
const uint ScopeVis::m_traceChunkSize = 4800;
ScopeVis::ScopeVis(GLScope* glScope) :
ScopeVis::ScopeVis(Real scalef, GLScope* glScope) :
m_glScope(glScope),
m_scalef(scalef),
m_tracebackCount(0),
m_fill(0),
m_triggerState(Untriggered),
@ -111,7 +112,7 @@ void ScopeVis::feed(const SampleVector::const_iterator& cbegin, const SampleVect
for(int i = 0; i < count; ++i)
{
*it++ = Complex(begin->real() / SDR_RX_SCALEF, begin->imag() / SDR_RX_SCALEF);
*it++ = Complex(begin->real() / m_scalef, begin->imag() / m_scalef);
++begin;
}
@ -234,7 +235,7 @@ void ScopeVis::feed(const SampleVector::const_iterator& cbegin, const SampleVect
for(int i = 0; i < count; ++i)
{
*it++ = Complex(begin->real() / SDR_RX_SCALEF, begin->imag() / SDR_RX_SCALEF);
*it++ = Complex(begin->real() / m_scalef, begin->imag() / m_scalef);
++begin;
}
@ -341,7 +342,7 @@ void ScopeVis::setSampleRate(int sampleRate)
bool ScopeVis::triggerCondition(SampleVector::const_iterator& it)
{
Complex c(it->real()/SDR_RX_SCALEF, it->imag()/SDR_RX_SCALEF);
Complex c(it->real()/m_scalef, it->imag()/m_scalef);
m_traceback.push_back(c); // store into trace memory FIFO
if (m_tracebackCount < m_traceback.size())

Wyświetl plik

@ -24,7 +24,7 @@ public:
static const uint m_traceChunkSize;
static const uint m_nbTriggers = 10;
ScopeVis(GLScope* glScope = NULL);
ScopeVis(Real scalef, GLScope* glScope = 0);
virtual ~ScopeVis();
void configure(MessageQueue* msgQueue,
@ -140,6 +140,7 @@ private:
};
GLScope* m_glScope;
Real m_scalef; //!< Sample scale factor from [-1,+1] to integer sample size range
std::vector<Complex> m_trace; //!< Raw trace to be used by GLScope
boost::circular_buffer<Complex> m_traceback; //!< FIFO for samples prior to triggering point to support pre-trigger (when in triggered mode)
uint m_tracebackCount; //!< Count of samples stored into trace memory since triggering is active up to trace memory size

Wyświetl plik

@ -560,14 +560,18 @@ private:
break;
case ProjectionMagLin:
{
uint32_t magsq = s.m_real*s.m_real + s.m_imag*s.m_imag;
v = std::sqrt(magsq/1073741824.0f);
Real re = s.m_real / SDR_RX_SCALEF;
Real im = s.m_imag / SDR_RX_SCALEF;
Real magsq = re*re + im*im;
v = std::sqrt(magsq);
}
break;
case ProjectionMagDB:
{
uint32_t magsq = s.m_real*s.m_real + s.m_imag*s.m_imag;
v = log10f(magsq/1073741824.0f) * 10.0f;
Real re = s.m_real / SDR_RX_SCALEF;
Real im = s.m_imag / SDR_RX_SCALEF;
Real magsq = re*re + im*im;
v = log10f(magsq) * 10.0f;
}
break;
case ProjectionPhase:

Wyświetl plik

@ -549,14 +549,18 @@ private:
break;
case ProjectionMagLin:
{
uint32_t magsq = s.m_real*s.m_real + s.m_imag*s.m_imag;
v = std::sqrt(magsq/1073741824.0f);
Real re = s.m_real / SDR_RX_SCALEF;
Real im = s.m_imag / SDR_RX_SCALEF;
Real magsq = re*re + im*im;
v = std::sqrt(magsq);
}
break;
case ProjectionMagDB:
{
uint32_t magsq = s.m_real*s.m_real + s.m_imag*s.m_imag;
v = log10f(magsq/1073741824.0f) * 10.0f;
Real re = s.m_real / SDR_RX_SCALEF;
Real im = s.m_imag / SDR_RX_SCALEF;
Real magsq = re*re + im*im;
v = log10f(magsq) * 10.0f;
}
break;
case ProjectionPhase:

Wyświetl plik

@ -14,13 +14,14 @@ inline double log2f(double n)
MESSAGE_CLASS_DEFINITION(SpectrumVis::MsgConfigureSpectrumVis, Message)
SpectrumVis::SpectrumVis(GLSpectrum* glSpectrum) :
SpectrumVis::SpectrumVis(Real scalef, GLSpectrum* glSpectrum) :
BasebandSampleSink(),
m_fft(FFTEngine::create()),
m_fftBuffer(MAX_FFT_SIZE),
m_logPowerSpectrum(MAX_FFT_SIZE),
m_fftBufferFill(0),
m_needMoreSamples(false),
m_scalef(scalef),
m_glSpectrum(glSpectrum),
m_mutex(QMutex::Recursive)
{
@ -85,7 +86,7 @@ void SpectrumVis::feed(const SampleVector::const_iterator& cbegin, const SampleV
for (std::size_t i = 0; i < samplesNeeded; ++i, ++begin)
{
*it++ = Complex(begin->real() / SDR_RX_SCALEF, begin->imag() / SDR_RX_SCALEF);
*it++ = Complex(begin->real() / m_scalef, begin->imag() / m_scalef);
}
// apply fft window (and copy from m_fftBuffer to m_fftIn)
@ -144,7 +145,7 @@ void SpectrumVis::feed(const SampleVector::const_iterator& cbegin, const SampleV
// not enough samples for FFT - just fill in new data and return
for(std::vector<Complex>::iterator it = m_fftBuffer.begin() + m_fftBufferFill; begin < end; ++begin)
{
*it++ = Complex(begin->real() / SDR_RX_SCALEF, begin->imag() / SDR_RX_SCALEF);
*it++ = Complex(begin->real() / m_scalef, begin->imag() / m_scalef);
}
m_fftBufferFill += todo;

Wyświetl plik

@ -35,7 +35,7 @@ public:
FFTWindow::Function m_window;
};
SpectrumVis(GLSpectrum* glSpectrum = NULL);
SpectrumVis(Real scalef, GLSpectrum* glSpectrum = 0);
virtual ~SpectrumVis();
void configure(MessageQueue* msgQueue, int fftSize, int overlapPercent, FFTWindow::Function window);
@ -60,6 +60,7 @@ private:
std::size_t m_fftBufferFill;
bool m_needMoreSamples;
Real m_scalef;
GLSpectrum* m_glSpectrum;
QMutex m_mutex;