diff --git a/src/freqshift.hh b/src/freqshift.hh index 7b035ae..c18fe4b 100644 --- a/src/freqshift.hh +++ b/src/freqshift.hh @@ -4,6 +4,7 @@ #include "config.hh" #include "traits.hh" #include "node.hh" +#include "operators.hh" namespace sdr { @@ -95,7 +96,7 @@ protected: protected: /** The size of the LUT. */ - static const size_t _lut_size = 127; + static const size_t _lut_size = 128; }; diff --git a/src/gui/spectrum.cc b/src/gui/spectrum.cc index 7eec3ba..811b5c4 100644 --- a/src/gui/spectrum.cc +++ b/src/gui/spectrum.cc @@ -5,8 +5,25 @@ using namespace sdr; using namespace sdr::gui; +/* ********************************************************************************************* * + * SpectrumProvider + * ********************************************************************************************* */ +SpectrumProvider::SpectrumProvider(QObject *parent) + : QObject(parent) +{ + // pass... +} + +SpectrumProvider::~SpectrumProvider() { + // pass... +} + + +/* ********************************************************************************************* * + * Spectrum + * ********************************************************************************************* */ Spectrum::Spectrum(double rrate, size_t fftsize, size_t max_avg, QObject *parent) : - QObject(parent), _rrate(rrate), _fft_size(fftsize), _fft_buffer(fftsize), + SpectrumProvider(parent), _rrate(rrate), _fft_size(fftsize), _fft_buffer(fftsize), _compute(fftsize), _spectrum(fftsize), _sample_count(0), _N_samples(0), _trafo_count(0), _Ntrafo(max_avg), _samples_left(0), _input_type(Config::Type_UNDEFINED), _sample_rate(0) @@ -69,6 +86,20 @@ Spectrum::isInputReal() const { return false; } +double +Spectrum::sampleRate() const { + return _sample_rate; +} + +size_t +Spectrum::fftSize() const { + return _fft_size; +} + +const Buffer & +Spectrum::spectrum() const { + return _spectrum; +} void Spectrum::handleBuffer(const RawBuffer &buffer, bool allow_overwrite) diff --git a/src/gui/spectrum.hh b/src/gui/spectrum.hh index 2780d77..60ed7e6 100644 --- a/src/gui/spectrum.hh +++ b/src/gui/spectrum.hh @@ -9,9 +9,39 @@ namespace sdr { namespace gui { + +class SpectrumProvider: public QObject +{ + Q_OBJECT + +public: + SpectrumProvider(QObject *parent=0); + + virtual ~SpectrumProvider(); + + /** Returns true if the input is real. */ + virtual bool isInputReal() const = 0; + + /** Retunrs the sample rate. */ + virtual double sampleRate() const = 0; + + /** Returns the FFT size. */ + virtual size_t fftSize() const = 0; + + /** Returns the current spectrum. */ + virtual const Buffer &spectrum() const = 0; + +signals: + /** Gets emitted once the spectrum was updated. */ + void spectrumUpdated(); + /** Gets emitted once the spectrum was reconfigured. */ + void spectrumConfigured(); +}; + + /** Calculates the power spectrum of a singnal. The spectrum gets updated with a specified * rate (if possible). */ -class Spectrum : public QObject, public SinkBase +class Spectrum : public SpectrumProvider, public SinkBase { Q_OBJECT @@ -36,20 +66,13 @@ public: bool isInputReal() const; /** Retunrs the sample rate. */ - inline double sampleRate() const { return _sample_rate; } + double sampleRate() const; /** Returns the FFT size. */ - inline size_t fftSize() const { return _fft_size; } + size_t fftSize() const; /** Returns the current spectrum. */ - inline const Buffer &spectrum() const { return _spectrum; } - - -signals: - /** Gets emitted once the spectrum was updated. */ - void spectrumUpdated(); - /** Gets emitted once the spectrum was reconfigured. */ - void spectrumConfigured(); + const Buffer &spectrum() const; protected: /** Updates the FFT in the _compute buffer. */ diff --git a/src/gui/spectrumview.cc b/src/gui/spectrumview.cc index 395a660..dc98ed0 100644 --- a/src/gui/spectrumview.cc +++ b/src/gui/spectrumview.cc @@ -8,7 +8,7 @@ using namespace sdr; using namespace sdr::gui; -SpectrumView::SpectrumView(Spectrum *spectrum, QWidget *parent) +SpectrumView::SpectrumView(SpectrumProvider *spectrum, QWidget *parent) : QWidget(parent), _spectrum(spectrum), _numXTicks(11), _numYTicks(6), _maxF(std::numeric_limits::infinity()), _mindB(-60) { diff --git a/src/gui/spectrumview.hh b/src/gui/spectrumview.hh index 12cb351..b61205d 100644 --- a/src/gui/spectrumview.hh +++ b/src/gui/spectrumview.hh @@ -18,7 +18,7 @@ Q_OBJECT public: /** @param rrate Specifies the (approx) refreshrate of the FFT plot. */ - explicit SpectrumView(Spectrum *spectrum, QWidget *parent=0); + explicit SpectrumView(SpectrumProvider *spectrum, QWidget *parent=0); inline size_t numXTicks() const { return _numXTicks; } inline void setNumXTicks(size_t N) { _numXTicks=N; update(); } @@ -51,7 +51,7 @@ protected: protected: /** Holds a weak reference to the spectrum recorder object. */ - Spectrum *_spectrum; + SpectrumProvider *_spectrum; /// The font being used for axis labels QFont _axisFont; /// The plot area diff --git a/src/gui/waterfallview.cc b/src/gui/waterfallview.cc index c39ba35..6735ddf 100644 --- a/src/gui/waterfallview.cc +++ b/src/gui/waterfallview.cc @@ -73,7 +73,7 @@ LinearColorMap::map(const double &value) { /* ****************************************************************************************** * * Implementation of WaterFallView * ****************************************************************************************** */ -WaterFallView::WaterFallView(Spectrum *spectrum, size_t height, QWidget *parent) +WaterFallView::WaterFallView(SpectrumProvider *spectrum, size_t height, QWidget *parent) : QWidget(parent), _spectrum(spectrum), _N(_spectrum->fftSize()), _M(height), _waterfall(_N,_M) { setMinimumHeight(height); diff --git a/src/gui/waterfallview.hh b/src/gui/waterfallview.hh index b6af394..c53265b 100644 --- a/src/gui/waterfallview.hh +++ b/src/gui/waterfallview.hh @@ -75,7 +75,7 @@ public: * @param spectrum Specifies the spectrum sink. * @param height Specifies the number of PSDs to display. * @param parent The parent widget. */ - explicit WaterFallView(Spectrum *spectrum, size_t height=100, QWidget *parent = 0); + explicit WaterFallView(SpectrumProvider *spectrum, size_t height=100, QWidget *parent = 0); signals: void click(double f); @@ -93,7 +93,7 @@ protected slots: protected: /** The spectrum sink. */ - Spectrum *_spectrum; + SpectrumProvider *_spectrum; /** The size of the spectrum. */ size_t _N; /** "Height of the spectrum. */ diff --git a/src/subsample.hh b/src/subsample.hh index 7941865..f5ac16d 100644 --- a/src/subsample.hh +++ b/src/subsample.hh @@ -247,11 +247,18 @@ public: } /** Performs the sub-sampling. */ - virtual void process(const Buffer &buffer, bool allow_overwrite) { + virtual void process(const Buffer &buffer, bool allow_overwrite) + { + // Short cut + if (1 == _frac) { + this->send(buffer, allow_overwrite); + return; + } + size_t i=0, o=0; while (i 1) && (i= 1) && (i stop queue.")); - // and signal queue to stop - Queue::get().stop(); + signalEOS(); return; }