SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
spectrumvis.h
Go to the documentation of this file.
1 #ifndef INCLUDE_SPECTRUMVIS_H
2 #define INCLUDE_SPECTRUMVIS_H
3 
5 #include <QMutex>
6 #include "dsp/fftengine.h"
7 #include "dsp/fftwindow.h"
8 #include "export.h"
9 #include "util/message.h"
10 #include "util/movingaverage2d.h"
11 #include "util/fixedaverage2d.h"
12 #include "util/max2d.h"
13 
14 class GLSpectrum;
15 class MessageQueue;
16 
18 
19 public:
20  enum AvgMode
21  {
25  AvgModeMax
26  };
27 
30 
31  public:
33  int fftSize,
34  int overlapPercent,
35  unsigned int averageNb,
36  int preProcessMode,
37  FFTWindow::Function window,
38  bool linear) :
39  Message(),
40  m_fftSize(fftSize),
41  m_overlapPercent(overlapPercent),
42  m_averageNb(averageNb),
43  m_window(window),
44  m_linear(linear)
45  {
46  m_avgMode = preProcessMode < 0 ? AvgModeNone : preProcessMode > 3 ? AvgModeMax : (SpectrumVis::AvgMode) preProcessMode;
47  }
48 
49  int getFFTSize() const { return m_fftSize; }
50  int getOverlapPercent() const { return m_overlapPercent; }
51  unsigned int getAverageNb() const { return m_averageNb; }
52  SpectrumVis::AvgMode getAvgMode() const { return m_avgMode; }
53  FFTWindow::Function getWindow() const { return m_window; }
54  bool getLinear() const { return m_linear; }
55 
56  private:
57  int m_fftSize;
59  unsigned int m_averageNb;
62  bool m_linear;
63  };
64 
65  SpectrumVis(Real scalef, GLSpectrum* glSpectrum = 0);
66  virtual ~SpectrumVis();
67 
68  void configure(MessageQueue* msgQueue,
69  int fftSize,
70  int overlapPercent,
71  unsigned int averagingNb,
72  int averagingMode,
73  FFTWindow::Function window,
74  bool m_linear);
75 
76  virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
77  void feedTriggered(const SampleVector::const_iterator& triggerPoint, const SampleVector::const_iterator& end, bool positiveOnly);
78  virtual void start();
79  virtual void stop();
80  virtual bool handleMessage(const Message& message);
81 
82 private:
85 
86  std::vector<Complex> m_fftBuffer;
87  std::vector<Real> m_powerSpectrum;
88 
89  std::size_t m_fftSize;
90  std::size_t m_overlapPercent;
91  std::size_t m_overlapSize;
92  std::size_t m_refillSize;
93  std::size_t m_fftBufferFill;
95 
101  unsigned int m_averageNb;
103  bool m_linear;
104 
107  static const Real m_mult;
108 
109  QMutex m_mutex;
110 
111  void handleConfigure(int fftSize,
112  int overlapPercent,
113  unsigned int averageNb,
114  AvgMode averagingMode,
115  FFTWindow::Function window,
116  bool linear);
117 };
118 
119 #endif // INCLUDE_SPECTRUMVIS_H
SpectrumVis::AvgMode m_avgMode
Definition: spectrumvis.h:60
QMutex m_mutex
Definition: spectrumvis.h:109
GLSpectrum * m_glSpectrum
Definition: spectrumvis.h:97
MsgConfigureSpectrumVis(int fftSize, int overlapPercent, unsigned int averageNb, int preProcessMode, FFTWindow::Function window, bool linear)
Definition: spectrumvis.h:32
std::size_t m_overlapSize
Definition: spectrumvis.h:91
bool m_needMoreSamples
Definition: spectrumvis.h:94
FixedAverage2D< double > m_fixedAverage
Definition: spectrumvis.h:99
std::size_t m_overlapPercent
Definition: spectrumvis.h:90
Real m_scalef
Definition: spectrumvis.h:96
Real m_powFFTDiv
Definition: spectrumvis.h:106
SpectrumVis::AvgMode getAvgMode() const
Definition: spectrumvis.h:52
std::size_t m_refillSize
Definition: spectrumvis.h:92
FFTEngine * m_fft
Definition: spectrumvis.h:83
#define SDRGUI_API
Definition: export.h:52
#define MESSAGE_CLASS_DECLARATION
Definition: message.h:43
unsigned int m_averageNb
Definition: spectrumvis.h:101
std::vector< Real > m_powerSpectrum
Definition: spectrumvis.h:87
std::size_t m_fftBufferFill
Definition: spectrumvis.h:93
std::size_t m_fftSize
Definition: spectrumvis.h:89
static const Real m_mult
Definition: spectrumvis.h:107
Max2D< double > m_max
Definition: spectrumvis.h:100
AvgMode m_avgMode
Definition: spectrumvis.h:102
FFTWindow m_window
Definition: spectrumvis.h:84
MovingAverage2D< double > m_movingAverage
Definition: spectrumvis.h:98
float Real
Definition: dsptypes.h:42
FFTWindow::Function getWindow() const
Definition: spectrumvis.h:53
unsigned int getAverageNb() const
Definition: spectrumvis.h:51
std::vector< Complex > m_fftBuffer
Definition: spectrumvis.h:86