diff --git a/mainwindow.cpp b/mainwindow.cpp index f2defed..b2e5692 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -33,6 +33,8 @@ MainWindow::MainWindow() plots = new PlotView(); setCentralWidget(plots); + + connect(dock, SIGNAL(fftSizeChanged(int)), plots, SLOT(setFFTSize(int))); } void MainWindow::openFile(QString fileName) diff --git a/plotview.cpp b/plotview.cpp index 6fd9d4d..fdb75a7 100644 --- a/plotview.cpp +++ b/plotview.cpp @@ -29,7 +29,6 @@ #include "grsamplebuffer.h" #include "memory_sink.h" #include "memory_source.h" -#include "spectrogramplot.h" #include "traceplot.h" PlotView::PlotView() @@ -41,16 +40,16 @@ void PlotView::refreshSources() { plots.clear(); - auto sp = new SpectrogramPlot(mainSampleSource); - plots.emplace_back(sp); + spectrogramPlot = new SpectrogramPlot(mainSampleSource); + plots.emplace_back(spectrogramPlot); gr::top_block_sptr iq_tb = gr::make_top_block("multiply"); auto iq_mem_source = gr::blocks::memory_source::make(8); auto iq_mem_sink = gr::blocks::memory_sink::make(8); auto multiply = gr::blocks::multiply_const_cc::make(20); - if (selection) { - float centre = (selectionFreq.first + selectionFreq.second) / 2; - float cutoff = std::abs(selectionFreq.first - centre); + if (selection || true) { + float centre = -0.05; //(selectionFreq.first + selectionFreq.second) / 2; + float cutoff = 0.02; //std::abs(selectionFreq.first - centre); auto lp_taps = gr::filter::firdes::low_pass(1.0, 1.0, cutoff, cutoff / 2); auto filter = gr::filter::freq_xlating_fir_filter_ccf::make(1, lp_taps, centre, 1.0); @@ -109,12 +108,19 @@ void PlotView::selectionCleared() refreshSources(); } +void PlotView::setFFTSize(int size) +{ + fftSize = size; + spectrogramPlot->setFFTSize(size); + viewport()->update(); +} + void PlotView::paintEvent(QPaintEvent *event) { if (mainSampleSource == nullptr) return; off_t firstSample = horizontalScrollBar()->value(); // TODO: don't hardcode width - off_t lastSample = firstSample + 10240; + off_t lastSample = firstSample + fftSize * width(); QRect rect = QRect(0, 0, width(), height()); QPainter painter(viewport()); diff --git a/plotview.h b/plotview.h index 72ead19..ffa5ed2 100644 --- a/plotview.h +++ b/plotview.h @@ -23,6 +23,7 @@ #include #include "inputsource.h" #include "plot.h" +#include "spectrogramplot.h" class PlotView : public QAbstractScrollArea { @@ -35,16 +36,20 @@ public slots: void inputSourceChanged(AbstractSampleSource *input); void selectionChanged(std::pair selectionTime, std::pair selectionFreq); void selectionCleared(); + void setFFTSize(int size); protected: void paintEvent(QPaintEvent *event); private: SampleSource> *mainSampleSource = nullptr; + SpectrogramPlot *spectrogramPlot; std::vector> plots; bool selection = false; std::pair selectionTime; std::pair selectionFreq; + int fftSize; + void refreshSources(); }; \ No newline at end of file