Permalink
Browse files

feat(plotview): Recommend a decimation based on the tuner BW

  • Loading branch information...
1 parent 4833c89 commit d3754785b0344be114c1abdbde787b3e8f8b5804 @schneider42 schneider42 committed Aug 31, 2016
Showing with 24 additions and 2 deletions.
  1. +3 −0 inputsource.h
  2. +1 −1 plotview.cpp
  3. +4 −0 samplebuffer.h
  4. +1 −0 samplesource.h
  5. +2 −1 spectrogramplot.cpp
  6. +10 −0 tunertransform.cpp
  7. +3 −0 tunertransform.h
View
@@ -50,4 +50,7 @@ class InputSource : public SampleSource<std::complex<float>>
};
void setSampleRate(off_t rate);
off_t rate();
+ float relativeBandwidth() {
+ return 1;
+ }
};
View
@@ -248,7 +248,7 @@ void PlotView::exportSamples(std::shared_ptr<AbstractSampleSource> src)
QGroupBox groupBox2("Decimation");
QSpinBox decimation(&groupBox2);
- decimation.setValue(1);
+ decimation.setValue(1 / complexSrc->relativeBandwidth());
QVBoxLayout vbox2;
vbox2.addWidget(&decimation);
View
@@ -43,4 +43,8 @@ class SampleBuffer : public SampleSource<Tout>, public Subscriber
off_t rate() {
return src->rate();
};
+
+ float relativeBandwidth() {
+ return 1;
+ }
};
View
@@ -36,6 +36,7 @@ class SampleSource : public AbstractSampleSource
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();
View
@@ -34,7 +34,7 @@
SpectrogramPlot::SpectrogramPlot(std::shared_ptr<SampleSource<std::complex<float>>> 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();
View
@@ -61,3 +61,13 @@ void TunerTransform::setTaps(std::vector<float> taps)
{
this->taps = taps;
}
+
+float TunerTransform::relativeBandwidth() {
+ return bandwidth;
+}
+
+void TunerTransform::setRelativeBandwith(float bandwidth)
+{
+ this->bandwidth = bandwidth;
+}
+
View
@@ -27,10 +27,13 @@ class TunerTransform : public SampleBuffer<std::complex<float>, std::complex<flo
private:
float frequency;
std::vector<float> taps;
+ float bandwidth;
public:
TunerTransform(SampleSource<std::complex<float>> *src);
void work(void *input, void *output, int count, off_t sampleid) override;
void setFrequency(float frequency);
void setTaps(std::vector<float> taps);
+ void setRelativeBandwith(float bandwidth);
+ float relativeBandwidth();
};

0 comments on commit d375478

Please sign in to comment.