2014-05-18 11:52:39 -04:00
|
|
|
#ifndef INCLUDE_SPECTRUMVIS_H
|
|
|
|
#define INCLUDE_SPECTRUMVIS_H
|
|
|
|
|
2016-10-02 16:29:04 -04:00
|
|
|
#include <dsp/basebandsamplesink.h>
|
2015-10-21 20:27:56 -04:00
|
|
|
#include <QMutex>
|
2014-05-18 11:52:39 -04:00
|
|
|
#include "dsp/fftengine.h"
|
2017-10-22 13:12:43 -04:00
|
|
|
#include "dsp/fftwindow.h"
|
2018-03-20 08:49:21 -04:00
|
|
|
#include "export.h"
|
2015-08-17 20:47:14 -04:00
|
|
|
#include "util/message.h"
|
2018-06-28 17:47:15 -04:00
|
|
|
#include "util/movingaverage2d.h"
|
2018-06-30 20:16:59 -04:00
|
|
|
#include "util/fixedaverage2d.h"
|
2018-10-12 02:47:14 -04:00
|
|
|
#include "util/max2d.h"
|
2014-05-18 11:52:39 -04:00
|
|
|
|
|
|
|
class GLSpectrum;
|
|
|
|
class MessageQueue;
|
|
|
|
|
2018-03-03 14:23:38 -05:00
|
|
|
class SDRGUI_API SpectrumVis : public BasebandSampleSink {
|
2015-08-17 20:47:14 -04:00
|
|
|
|
2014-05-18 11:52:39 -04:00
|
|
|
public:
|
2018-10-12 02:47:14 -04:00
|
|
|
enum AvgMode
|
2018-06-30 20:16:59 -04:00
|
|
|
{
|
2018-07-01 16:36:36 -04:00
|
|
|
AvgModeNone,
|
2018-10-12 02:47:14 -04:00
|
|
|
AvgModeMovingAvg,
|
|
|
|
AvgModeFixedAvg,
|
|
|
|
AvgModeMax
|
2018-06-30 20:16:59 -04:00
|
|
|
};
|
|
|
|
|
2018-03-03 15:19:59 -05:00
|
|
|
class MsgConfigureSpectrumVis : public Message {
|
2015-08-17 20:47:14 -04:00
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
2018-07-04 17:11:28 -04:00
|
|
|
MsgConfigureSpectrumVis(
|
|
|
|
int fftSize,
|
|
|
|
int overlapPercent,
|
|
|
|
unsigned int averageNb,
|
2019-08-04 19:56:29 -04:00
|
|
|
AvgMode avgMode,
|
2018-07-04 17:11:28 -04:00
|
|
|
FFTWindow::Function window,
|
|
|
|
bool linear) :
|
2015-08-17 20:47:14 -04:00
|
|
|
Message(),
|
|
|
|
m_fftSize(fftSize),
|
|
|
|
m_overlapPercent(overlapPercent),
|
2018-06-30 16:30:42 -04:00
|
|
|
m_averageNb(averageNb),
|
2019-08-04 19:56:29 -04:00
|
|
|
m_avgMode(avgMode),
|
2018-07-04 17:11:28 -04:00
|
|
|
m_window(window),
|
|
|
|
m_linear(linear)
|
2019-08-04 19:56:29 -04:00
|
|
|
{}
|
2015-08-17 20:47:14 -04:00
|
|
|
|
|
|
|
int getFFTSize() const { return m_fftSize; }
|
|
|
|
int getOverlapPercent() const { return m_overlapPercent; }
|
2018-06-30 16:30:42 -04:00
|
|
|
unsigned int getAverageNb() const { return m_averageNb; }
|
2018-10-12 02:47:14 -04:00
|
|
|
SpectrumVis::AvgMode getAvgMode() const { return m_avgMode; }
|
2015-08-17 20:47:14 -04:00
|
|
|
FFTWindow::Function getWindow() const { return m_window; }
|
2018-07-04 17:11:28 -04:00
|
|
|
bool getLinear() const { return m_linear; }
|
2015-08-17 20:47:14 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
int m_fftSize;
|
|
|
|
int m_overlapPercent;
|
2018-06-30 16:30:42 -04:00
|
|
|
unsigned int m_averageNb;
|
2018-10-12 02:47:14 -04:00
|
|
|
SpectrumVis::AvgMode m_avgMode;
|
2015-08-17 20:47:14 -04:00
|
|
|
FFTWindow::Function m_window;
|
2018-07-04 17:11:28 -04:00
|
|
|
bool m_linear;
|
2015-08-17 20:47:14 -04:00
|
|
|
};
|
|
|
|
|
2019-10-26 16:30:53 -04:00
|
|
|
class MsgConfigureScalingFactor : public Message
|
|
|
|
{
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
MsgConfigureScalingFactor(Real scalef) :
|
|
|
|
Message(),
|
|
|
|
m_scalef(scalef)
|
|
|
|
{}
|
|
|
|
|
|
|
|
Real getScalef() const { return m_scalef; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Real m_scalef;
|
|
|
|
};
|
|
|
|
|
2018-01-22 08:07:24 -05:00
|
|
|
SpectrumVis(Real scalef, GLSpectrum* glSpectrum = 0);
|
2015-08-13 23:00:28 -04:00
|
|
|
virtual ~SpectrumVis();
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2018-06-30 20:16:59 -04:00
|
|
|
void configure(MessageQueue* msgQueue,
|
|
|
|
int fftSize,
|
|
|
|
int overlapPercent,
|
|
|
|
unsigned int averagingNb,
|
2019-08-04 19:56:29 -04:00
|
|
|
AvgMode averagingMode,
|
2018-07-04 17:11:28 -04:00
|
|
|
FFTWindow::Function window,
|
|
|
|
bool m_linear);
|
2019-10-26 16:30:53 -04:00
|
|
|
void setScalef(MessageQueue* msgQueue, Real scalef);
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2015-08-25 02:24:23 -04:00
|
|
|
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
|
2017-05-25 14:13:34 -04:00
|
|
|
void feedTriggered(const SampleVector::const_iterator& triggerPoint, const SampleVector::const_iterator& end, bool positiveOnly);
|
2015-08-13 23:00:28 -04:00
|
|
|
virtual void start();
|
|
|
|
virtual void stop();
|
|
|
|
virtual bool handleMessage(const Message& message);
|
2014-05-18 11:52:39 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
FFTEngine* m_fft;
|
|
|
|
FFTWindow m_window;
|
2020-03-12 01:27:38 -04:00
|
|
|
unsigned int m_fftEngineSequence;
|
2014-05-18 11:52:39 -04:00
|
|
|
|
|
|
|
std::vector<Complex> m_fftBuffer;
|
2018-07-05 19:34:05 -04:00
|
|
|
std::vector<Real> m_powerSpectrum;
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2015-08-13 23:00:28 -04:00
|
|
|
std::size_t m_fftSize;
|
|
|
|
std::size_t m_overlapPercent;
|
|
|
|
std::size_t m_overlapSize;
|
|
|
|
std::size_t m_refillSize;
|
|
|
|
std::size_t m_fftBufferFill;
|
2015-07-14 19:19:39 -04:00
|
|
|
bool m_needMoreSamples;
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2018-01-22 08:07:24 -05:00
|
|
|
Real m_scalef;
|
2014-05-18 11:52:39 -04:00
|
|
|
GLSpectrum* m_glSpectrum;
|
2018-06-30 20:16:59 -04:00
|
|
|
MovingAverage2D<double> m_movingAverage;
|
|
|
|
FixedAverage2D<double> m_fixedAverage;
|
2018-10-12 02:47:14 -04:00
|
|
|
Max2D<double> m_max;
|
2018-06-28 17:47:15 -04:00
|
|
|
unsigned int m_averageNb;
|
2018-10-12 02:47:14 -04:00
|
|
|
AvgMode m_avgMode;
|
2018-07-05 19:34:05 -04:00
|
|
|
bool m_linear;
|
2018-06-28 17:47:15 -04:00
|
|
|
|
|
|
|
Real m_ofs;
|
2018-07-05 19:34:05 -04:00
|
|
|
Real m_powFFTDiv;
|
2018-06-28 17:47:15 -04:00
|
|
|
static const Real m_mult;
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2015-10-21 20:27:56 -04:00
|
|
|
QMutex m_mutex;
|
|
|
|
|
2018-06-30 20:16:59 -04:00
|
|
|
void handleConfigure(int fftSize,
|
|
|
|
int overlapPercent,
|
|
|
|
unsigned int averageNb,
|
2018-10-12 02:47:14 -04:00
|
|
|
AvgMode averagingMode,
|
2018-07-05 19:34:05 -04:00
|
|
|
FFTWindow::Function window,
|
|
|
|
bool linear);
|
2019-10-26 16:30:53 -04:00
|
|
|
void handleScalef(Real scalef);
|
2014-05-18 11:52:39 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INCLUDE_SPECTRUMVIS_H
|