diff --git a/inputsource.h b/inputsource.h index 552264a..ff7ea76 100644 --- a/inputsource.h +++ b/inputsource.h @@ -50,4 +50,7 @@ public: }; void setSampleRate(off_t rate); off_t rate(); + float relativeBandwidth() { + return 1; + } }; diff --git a/plotview.cpp b/plotview.cpp index ad12c35..7210d21 100644 --- a/plotview.cpp +++ b/plotview.cpp @@ -248,7 +248,7 @@ void PlotView::exportSamples(std::shared_ptr src) QGroupBox groupBox2("Decimation"); QSpinBox decimation(&groupBox2); - decimation.setValue(1); + decimation.setValue(1 / complexSrc->relativeBandwidth()); QVBoxLayout vbox2; vbox2.addWidget(&decimation); diff --git a/samplebuffer.h b/samplebuffer.h index 32847ec..8cb4438 100644 --- a/samplebuffer.h +++ b/samplebuffer.h @@ -43,4 +43,8 @@ public: off_t rate() { return src->rate(); }; + + float relativeBandwidth() { + return 1; + } }; diff --git a/samplesource.h b/samplesource.h index 14243ef..7662b09 100644 --- a/samplesource.h +++ b/samplesource.h @@ -36,6 +36,7 @@ public: virtual void invalidateEvent() { }; virtual off_t count() = 0; virtual off_t rate() = 0; + virtual float relativeBandwidth() = 0; std::type_index sampleType() override; void subscribe(Subscriber *subscriber); int subscriberCount(); diff --git a/spectrogramplot.cpp b/spectrogramplot.cpp index 330f1ca..f1091a1 100644 --- a/spectrogramplot.cpp +++ b/spectrogramplot.cpp @@ -34,7 +34,7 @@ SpectrogramPlot::SpectrogramPlot(std::shared_ptr>> src) : Plot(src), inputSource(src), tuner(this) { setFFTSize(512); - zoomLevel = 0; + zoomLevel = 1; powerMax = 0.0f; powerMin = -50.0f; @@ -236,6 +236,7 @@ void SpectrogramPlot::tunerMoved() { tunerTransform->setFrequency(getTunerPhaseInc()); tunerTransform->setTaps(getTunerTaps()); + tunerTransform->setRelativeBandwith(tuner.deviation() * 2.0 / getStride()); // TODO: for invalidating traceplot cache, this shouldn't really go here QPixmapCache::clear(); diff --git a/tunertransform.cpp b/tunertransform.cpp index e5f9842..daa1aa3 100644 --- a/tunertransform.cpp +++ b/tunertransform.cpp @@ -61,3 +61,13 @@ void TunerTransform::setTaps(std::vector taps) { this->taps = taps; } + +float TunerTransform::relativeBandwidth() { + return bandwidth; +} + +void TunerTransform::setRelativeBandwith(float bandwidth) +{ + this->bandwidth = bandwidth; +} + diff --git a/tunertransform.h b/tunertransform.h index 0655b7c..abc77f6 100644 --- a/tunertransform.h +++ b/tunertransform.h @@ -27,10 +27,13 @@ class TunerTransform : public SampleBuffer, std::complex taps; + float bandwidth; public: TunerTransform(SampleSource> *src); void work(void *input, void *output, int count, off_t sampleid) override; void setFrequency(float frequency); void setTaps(std::vector taps); + void setRelativeBandwith(float bandwidth); + float relativeBandwidth(); };