2014-05-18 15:52:39 +00:00
|
|
|
#ifndef INCLUDE_SPECTRUMVIS_H
|
|
|
|
#define INCLUDE_SPECTRUMVIS_H
|
|
|
|
|
2016-10-02 20:29:04 +00:00
|
|
|
#include <dsp/basebandsamplesink.h>
|
2015-10-22 00:27:56 +00:00
|
|
|
#include <QMutex>
|
2014-05-18 15:52:39 +00:00
|
|
|
#include "dsp/fftengine.h"
|
2017-10-22 17:12:43 +00:00
|
|
|
#include "dsp/fftwindow.h"
|
2014-05-18 15:52:39 +00:00
|
|
|
#include "util/export.h"
|
2015-08-18 00:47:14 +00:00
|
|
|
#include "util/message.h"
|
2014-05-18 15:52:39 +00:00
|
|
|
|
|
|
|
class GLSpectrum;
|
|
|
|
class MessageQueue;
|
|
|
|
|
2018-03-03 19:23:38 +00:00
|
|
|
class SDRGUI_API SpectrumVis : public BasebandSampleSink {
|
2015-08-18 00:47:14 +00:00
|
|
|
|
2014-05-18 15:52:39 +00:00
|
|
|
public:
|
2018-03-03 20:19:59 +00:00
|
|
|
class MsgConfigureSpectrumVis : public Message {
|
2015-08-18 00:47:14 +00:00
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
MsgConfigureSpectrumVis(int fftSize, int overlapPercent, FFTWindow::Function window) :
|
|
|
|
Message(),
|
|
|
|
m_fftSize(fftSize),
|
|
|
|
m_overlapPercent(overlapPercent),
|
|
|
|
m_window(window)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
int getFFTSize() const { return m_fftSize; }
|
|
|
|
int getOverlapPercent() const { return m_overlapPercent; }
|
|
|
|
FFTWindow::Function getWindow() const { return m_window; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
int m_fftSize;
|
|
|
|
int m_overlapPercent;
|
|
|
|
FFTWindow::Function m_window;
|
|
|
|
};
|
|
|
|
|
2018-01-22 13:07:24 +00:00
|
|
|
SpectrumVis(Real scalef, GLSpectrum* glSpectrum = 0);
|
2015-08-14 03:00:28 +00:00
|
|
|
virtual ~SpectrumVis();
|
2014-05-18 15:52:39 +00:00
|
|
|
|
|
|
|
void configure(MessageQueue* msgQueue, int fftSize, int overlapPercent, FFTWindow::Function window);
|
|
|
|
|
2015-08-25 06:24:23 +00:00
|
|
|
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
|
2017-05-25 18:13:34 +00:00
|
|
|
void feedTriggered(const SampleVector::const_iterator& triggerPoint, const SampleVector::const_iterator& end, bool positiveOnly);
|
2015-08-14 03:00:28 +00:00
|
|
|
virtual void start();
|
|
|
|
virtual void stop();
|
|
|
|
virtual bool handleMessage(const Message& message);
|
2014-05-18 15:52:39 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
FFTEngine* m_fft;
|
|
|
|
FFTWindow m_window;
|
|
|
|
|
|
|
|
std::vector<Complex> m_fftBuffer;
|
|
|
|
std::vector<Real> m_logPowerSpectrum;
|
|
|
|
|
2015-08-14 03:00:28 +00: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 23:19:39 +00:00
|
|
|
bool m_needMoreSamples;
|
2014-05-18 15:52:39 +00:00
|
|
|
|
2018-01-22 13:07:24 +00:00
|
|
|
Real m_scalef;
|
2014-05-18 15:52:39 +00:00
|
|
|
GLSpectrum* m_glSpectrum;
|
|
|
|
|
2015-10-22 00:27:56 +00:00
|
|
|
QMutex m_mutex;
|
|
|
|
|
2014-05-18 15:52:39 +00:00
|
|
|
void handleConfigure(int fftSize, int overlapPercent, FFTWindow::Function window);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INCLUDE_SPECTRUMVIS_H
|