summaryrefslogtreecommitdiff
path: root/gr-qtgui/lib
diff options
context:
space:
mode:
Diffstat (limited to 'gr-qtgui/lib')
-rw-r--r--gr-qtgui/lib/CMakeLists.txt20
-rw-r--r--gr-qtgui/lib/ConstellationDisplayPlot.h1
-rw-r--r--gr-qtgui/lib/DisplayPlot.h2
-rw-r--r--gr-qtgui/lib/FrequencyDisplayPlot.h1
-rw-r--r--gr-qtgui/lib/TimeDomainDisplayPlot.h1
-rw-r--r--gr-qtgui/lib/WaterfallDisplayPlot.h1
-rw-r--r--gr-qtgui/lib/const_sink_c_impl.cc233
-rw-r--r--gr-qtgui/lib/const_sink_c_impl.h81
-rw-r--r--gr-qtgui/lib/freq_sink_c_impl.cc371
-rw-r--r--gr-qtgui/lib/freq_sink_c_impl.h110
-rw-r--r--gr-qtgui/lib/freq_sink_f_impl.cc366
-rw-r--r--gr-qtgui/lib/freq_sink_f_impl.h110
-rw-r--r--gr-qtgui/lib/freqdisplayform.cc12
-rw-r--r--gr-qtgui/lib/freqdisplayform.h4
-rw-r--r--gr-qtgui/lib/qtgui_const_sink_c.cc214
-rw-r--r--gr-qtgui/lib/qtgui_freq_sink_c.cc345
-rw-r--r--gr-qtgui/lib/qtgui_freq_sink_f.cc336
-rw-r--r--gr-qtgui/lib/qtgui_time_sink_c.cc215
-rw-r--r--gr-qtgui/lib/qtgui_time_sink_f.cc205
-rw-r--r--gr-qtgui/lib/qtgui_util.cc2
-rw-r--r--gr-qtgui/lib/qtgui_waterfall_sink_c.cc304
-rw-r--r--gr-qtgui/lib/qtgui_waterfall_sink_f.cc298
-rw-r--r--gr-qtgui/lib/time_sink_c_impl.cc235
-rw-r--r--gr-qtgui/lib/time_sink_c_impl.h82
-rw-r--r--gr-qtgui/lib/time_sink_f_impl.cc233
-rw-r--r--gr-qtgui/lib/time_sink_f_impl.h82
-rw-r--r--gr-qtgui/lib/waterfall_sink_c_impl.cc354
-rw-r--r--gr-qtgui/lib/waterfall_sink_c_impl.h106
-rw-r--r--gr-qtgui/lib/waterfall_sink_f_impl.cc350
-rw-r--r--gr-qtgui/lib/waterfall_sink_f_impl.h107
-rw-r--r--gr-qtgui/lib/waterfalldisplayform.cc12
-rw-r--r--gr-qtgui/lib/waterfalldisplayform.h4
32 files changed, 2865 insertions, 1932 deletions
diff --git a/gr-qtgui/lib/CMakeLists.txt b/gr-qtgui/lib/CMakeLists.txt
index a8b38b98ce..1ecfab961b 100644
--- a/gr-qtgui/lib/CMakeLists.txt
+++ b/gr-qtgui/lib/CMakeLists.txt
@@ -62,15 +62,15 @@ set(qtgui_srcs
SpectrumGUIClass.cc
spectrumUpdateEvents.cc
plot_waterfall.cc
- qtgui_sink_c.cc
- qtgui_sink_f.cc
- qtgui_time_sink_c.cc
- qtgui_time_sink_f.cc
- qtgui_freq_sink_c.cc
- qtgui_freq_sink_f.cc
- qtgui_const_sink_c.cc
- qtgui_waterfall_sink_c.cc
- qtgui_waterfall_sink_f.cc
+# qtgui_sink_c.cc
+# qtgui_sink_f.cc
+ time_sink_c_impl.cc
+ time_sink_f_impl.cc
+ freq_sink_c_impl.cc
+ freq_sink_f_impl.cc
+ const_sink_c_impl.cc
+ waterfall_sink_c_impl.cc
+ waterfall_sink_f_impl.cc
qtgui_util.cc
)
@@ -80,6 +80,7 @@ set(qtgui_srcs
include_directories(
${GNURADIO_CORE_INCLUDE_DIRS}
${GR_FFT_INCLUDE_DIRS}
+ ${GR_FILTER_INCLUDE_DIRS}
${GR_QTGUI_INCLUDE_DIRS}
${VOLK_INCLUDE_DIRS}
)
@@ -102,6 +103,7 @@ include_directories(${PYTHON_INCLUDE_PATH}) #deprecated for dirs (cmake 2.6)
list(APPEND qtgui_libs
gnuradio-core
gnuradio-fft
+ gnuradio-filter
volk
${QT_LIBRARIES}
${QWT_LIBRARIES}
diff --git a/gr-qtgui/lib/ConstellationDisplayPlot.h b/gr-qtgui/lib/ConstellationDisplayPlot.h
index 261ac3b2c3..f3cbeef1cb 100644
--- a/gr-qtgui/lib/ConstellationDisplayPlot.h
+++ b/gr-qtgui/lib/ConstellationDisplayPlot.h
@@ -26,7 +26,6 @@
#include <stdint.h>
#include <cstdio>
#include <vector>
-#include <qtgui_util.h>
#include "DisplayPlot.h"
class ConstellationDisplayPlot : public DisplayPlot
diff --git a/gr-qtgui/lib/DisplayPlot.h b/gr-qtgui/lib/DisplayPlot.h
index 9cf276bc35..975a92a18d 100644
--- a/gr-qtgui/lib/DisplayPlot.h
+++ b/gr-qtgui/lib/DisplayPlot.h
@@ -37,7 +37,7 @@
#include <qwt_plot_magnifier.h>
#include <qwt_plot_marker.h>
#include <qwt_symbol.h>
-#include <qtgui_util.h>
+#include <qtgui/utils.h>
#if QWT_VERSION >= 0x060000
#include <qwt_compat.h>
diff --git a/gr-qtgui/lib/FrequencyDisplayPlot.h b/gr-qtgui/lib/FrequencyDisplayPlot.h
index ba2b686e64..17bb9d2391 100644
--- a/gr-qtgui/lib/FrequencyDisplayPlot.h
+++ b/gr-qtgui/lib/FrequencyDisplayPlot.h
@@ -26,7 +26,6 @@
#include <stdint.h>
#include <cstdio>
#include <vector>
-#include <qtgui_util.h>
#include "DisplayPlot.h"
class FrequencyDisplayPlot: public DisplayPlot
diff --git a/gr-qtgui/lib/TimeDomainDisplayPlot.h b/gr-qtgui/lib/TimeDomainDisplayPlot.h
index 538e0e8c0b..9c07e96ba0 100644
--- a/gr-qtgui/lib/TimeDomainDisplayPlot.h
+++ b/gr-qtgui/lib/TimeDomainDisplayPlot.h
@@ -26,7 +26,6 @@
#include <stdint.h>
#include <cstdio>
#include <vector>
-#include <qtgui_util.h>
#include "DisplayPlot.h"
class TimeDomainDisplayPlot: public DisplayPlot
diff --git a/gr-qtgui/lib/WaterfallDisplayPlot.h b/gr-qtgui/lib/WaterfallDisplayPlot.h
index ba1e864dc5..abc663dec7 100644
--- a/gr-qtgui/lib/WaterfallDisplayPlot.h
+++ b/gr-qtgui/lib/WaterfallDisplayPlot.h
@@ -27,7 +27,6 @@
#include <cstdio>
#include <vector>
#include <qwt_plot_spectrogram.h>
-#include <qtgui_util.h>
#include "DisplayPlot.h"
#include "waterfallGlobalData.h"
#include <gruel/high_res_timer.h>
diff --git a/gr-qtgui/lib/const_sink_c_impl.cc b/gr-qtgui/lib/const_sink_c_impl.cc
new file mode 100644
index 0000000000..06d2aef99e
--- /dev/null
+++ b/gr-qtgui/lib/const_sink_c_impl.cc
@@ -0,0 +1,233 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "const_sink_c_impl.h"
+#include <gr_io_signature.h>
+#include <string.h>
+#include <volk/volk.h>
+#include <fft/fft.h>
+
+namespace gr {
+ namespace qtgui {
+
+ const_sink_c::sptr const_sink_c::make(int size,
+ const std::string &name,
+ int nconnections,
+ QWidget *parent)
+ {
+ return gnuradio::get_initial_sptr
+ (new const_sink_c_impl(size, name, nconnections, parent));
+ }
+
+ const_sink_c_impl::const_sink_c_impl(int size,
+ const std::string &name,
+ int nconnections,
+ QWidget *parent)
+ : gr_sync_block("const_sink_c",
+ gr_make_io_signature(nconnections, nconnections, sizeof(gr_complex)),
+ gr_make_io_signature(0, 0, 0)),
+ d_size(size), d_name(name),
+ d_nconnections(nconnections), d_parent(parent)
+ {
+ d_main_gui = NULL;
+
+ d_index = 0;
+
+ for(int i = 0; i < d_nconnections; i++) {
+ d_residbufs_real.push_back(gr::fft::malloc_double(d_size));
+ d_residbufs_imag.push_back(gr::fft::malloc_double(d_size));
+ }
+
+ // Set alignment properties for VOLK
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(gr_complex);
+ set_alignment(std::max(1,alignment_multiple));
+
+ initialize();
+ }
+
+ const_sink_c_impl::~const_sink_c_impl()
+ {
+ // d_main_gui is a qwidget destroyed with its parent
+ for(int i = 0; i < d_nconnections; i++) {
+ gr::fft::free(d_residbufs_real[i]);
+ gr::fft::free(d_residbufs_imag[i]);
+ }
+ }
+
+ void
+ const_sink_c_impl::initialize()
+ {
+ if(qApp != NULL) {
+ d_qApplication = qApp;
+ }
+ else {
+ int argc=0;
+ char **argv = NULL;
+ d_qApplication = new QApplication(argc, argv);
+ }
+
+ d_main_gui = new ConstellationDisplayForm(d_nconnections, d_parent);
+
+ // initialize update time to 10 times a second
+ set_update_time(0.1);
+ d_last_time = 0;
+ }
+
+ void
+ const_sink_c_impl::exec_()
+ {
+ d_qApplication->exec();
+ }
+
+ QWidget*
+ const_sink_c_impl::qwidget()
+ {
+ return d_main_gui;
+ }
+
+ PyObject*
+ const_sink_c_impl::pyqwidget()
+ {
+ PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui);
+ PyObject *retarg = Py_BuildValue("N", w);
+ return retarg;
+ }
+
+ void
+ const_sink_c_impl::set_update_time(double t)
+ {
+ //convert update time to ticks
+ gruel::high_res_timer_type tps = gruel::high_res_timer_tps();
+ d_update_time = t * tps;
+ d_main_gui->setUpdateTime(t);
+ }
+
+ void
+ const_sink_c_impl::set_title(int which, const std::string &title)
+ {
+ d_main_gui->setTitle(which, title.c_str());
+ }
+
+ void
+ const_sink_c_impl::set_color(int which, const std::string &color)
+ {
+ d_main_gui->setColor(which, color.c_str());
+ }
+
+ void
+ const_sink_c_impl::set_line_width(int which, int width)
+ {
+ d_main_gui->setLineWidth(which, width);
+ }
+
+ void
+ const_sink_c_impl::set_line_style(int which, Qt::PenStyle style)
+ {
+ d_main_gui->setLineStyle(which, style);
+ }
+
+ void
+ const_sink_c_impl::set_line_marker(int which, QwtSymbol::Style marker)
+ {
+ d_main_gui->setLineMarker(which, marker);
+ }
+
+ void
+ const_sink_c_impl::set_size(int width, int height)
+ {
+ d_main_gui->resize(QSize(width, height));
+ }
+
+ int
+ const_sink_c_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ int n=0, j=0, idx=0;
+ const gr_complex *in = (const gr_complex*)input_items[idx];
+
+ for(int i=0; i < noutput_items; i+=d_size) {
+ unsigned int datasize = noutput_items - i;
+ unsigned int resid = d_size-d_index;
+ idx = 0;
+
+ // If we have enough input for one full plot, do it
+ if(datasize >= resid) {
+
+ // Fill up residbufs with d_size number of items
+ for(n = 0; n < d_nconnections; n++) {
+ in = (const gr_complex*)input_items[idx++];
+ if(is_unaligned()) {
+ volk_32fc_deinterleave_64f_x2_u(&d_residbufs_real[n][d_index],
+ &d_residbufs_imag[n][d_index],
+ &in[j], resid);
+ }
+ else {
+ volk_32fc_deinterleave_64f_x2_a(&d_residbufs_real[n][d_index],
+ &d_residbufs_imag[n][d_index],
+ &in[j], resid);
+ }
+ }
+
+ // Update the plot if its time
+ if(gruel::high_res_timer_now() - d_last_time > d_update_time) {
+ d_last_time = gruel::high_res_timer_now();
+ d_qApplication->postEvent(d_main_gui,
+ new ConstUpdateEvent(d_residbufs_real,
+ d_residbufs_imag,
+ d_size));
+ }
+
+ d_index = 0;
+ j += resid;
+ }
+
+ // Otherwise, copy what we received into the residbufs for next time
+ else {
+ for(n = 0; n < d_nconnections; n++) {
+ in = (const gr_complex*)input_items[idx++];
+ if(is_unaligned()) {
+ volk_32fc_deinterleave_64f_x2_u(&d_residbufs_real[n][d_index],
+ &d_residbufs_imag[n][d_index],
+ &in[j], datasize);
+ }
+ else {
+ volk_32fc_deinterleave_64f_x2_a(&d_residbufs_real[n][d_index],
+ &d_residbufs_imag[n][d_index],
+ &in[j], datasize);
+ }
+ }
+ d_index += datasize;
+ j += datasize;
+ }
+ }
+
+ return noutput_items;
+ }
+
+ } /* namespace qtgui */
+} /* namespace gr */
diff --git a/gr-qtgui/lib/const_sink_c_impl.h b/gr-qtgui/lib/const_sink_c_impl.h
new file mode 100644
index 0000000000..52a128f3cc
--- /dev/null
+++ b/gr-qtgui/lib/const_sink_c_impl.h
@@ -0,0 +1,81 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_QTGUI_CONST_SINK_C_IMPL_H
+#define INCLUDED_QTGUI_CONST_SINK_C_IMPL_H
+
+#include <qtgui/const_sink_c.h>
+#include <gruel/high_res_timer.h>
+#include <gruel/thread.h>
+#include <constellationdisplayform.h>
+
+namespace gr {
+ namespace qtgui {
+
+ class QTGUI_API const_sink_c_impl : public const_sink_c
+ {
+ private:
+ void initialize();
+
+ int d_size;
+ std::string d_name;
+ int d_nconnections;
+
+ int d_index;
+ std::vector<double*> d_residbufs_real;
+ std::vector<double*> d_residbufs_imag;
+
+ QWidget *d_parent;
+ ConstellationDisplayForm *d_main_gui;
+
+ gruel::high_res_timer_type d_update_time;
+ gruel::high_res_timer_type d_last_time;
+
+ public:
+ const_sink_c_impl(int size,
+ const std::string &name,
+ int nconnections,
+ QWidget *parent=NULL);
+ ~const_sink_c_impl();
+
+ void exec_();
+ QWidget* qwidget();
+ PyObject* pyqwidget();
+
+ void set_update_time(double t);
+ void set_title(int which, const std::string &title);
+ void set_color(int which, const std::string &color);
+ void set_line_width(int which, int width);
+ void set_line_style(int which, Qt::PenStyle style);
+ void set_line_marker(int which, QwtSymbol::Style marker);
+
+ void set_size(int width, int height);
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace qtgui */
+} /* namespace gr */
+
+#endif /* INCLUDED_QTGUI_CONST_SINK_C_IMPL_H */
diff --git a/gr-qtgui/lib/freq_sink_c_impl.cc b/gr-qtgui/lib/freq_sink_c_impl.cc
new file mode 100644
index 0000000000..8d3a2d037e
--- /dev/null
+++ b/gr-qtgui/lib/freq_sink_c_impl.cc
@@ -0,0 +1,371 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "freq_sink_c_impl.h"
+#include <gr_io_signature.h>
+#include <string.h>
+#include <volk/volk.h>
+#include <fft/fft.h>
+
+namespace gr {
+ namespace qtgui {
+
+ freq_sink_c::sptr freq_sink_c::make(int fftsize, int wintype,
+ double fc, double bw,
+ const std::string &name,
+ int nconnections,
+ QWidget *parent)
+ {
+ return gnuradio::get_initial_sptr
+ (new freq_sink_c_impl(fftsize, wintype,
+ fc, bw, name,
+ nconnections,
+ parent));
+ }
+
+ freq_sink_c_impl::freq_sink_c_impl(int fftsize, int wintype,
+ double fc, double bw,
+ const std::string &name,
+ int nconnections,
+ QWidget *parent)
+ : gr_sync_block("freq_sink_c",
+ gr_make_io_signature(1, -1, sizeof(gr_complex)),
+ gr_make_io_signature(0, 0, 0)),
+ d_fftsize(fftsize), d_fftavg(1.0),
+ d_wintype((filter::firdes::win_type)(wintype)),
+ d_center_freq(fc), d_bandwidth(bw), d_name(name),
+ d_nconnections(nconnections), d_parent(parent)
+ {
+ d_main_gui = NULL;
+
+ // Perform fftshift operation;
+ // this is usually desired when plotting
+ d_shift = true;
+
+ d_fft = new gr::fft::fft_complex(d_fftsize, true);
+ d_fbuf = gr::fft::malloc_float(d_fftsize);
+
+ d_index = 0;
+ for(int i = 0; i < d_nconnections; i++) {
+ d_residbufs.push_back(gr::fft::malloc_complex(d_fftsize));
+ d_magbufs.push_back(gr::fft::malloc_double(d_fftsize));
+ }
+
+ buildwindow();
+
+ initialize();
+ }
+
+ freq_sink_c_impl::~freq_sink_c_impl()
+ {
+ for(int i = 0; i < d_nconnections; i++) {
+ gr::fft::free(d_residbufs[i]);
+ gr::fft::free(d_magbufs[i]);
+ }
+ delete d_fft;
+ delete d_fbuf;
+ }
+
+ void
+ freq_sink_c_impl::forecast(int noutput_items, gr_vector_int &ninput_items_required)
+ {
+ unsigned int ninputs = ninput_items_required.size();
+ for (unsigned int i = 0; i < ninputs; i++) {
+ ninput_items_required[i] = std::min(d_fftsize, 8191);
+ }
+ }
+
+ void
+ freq_sink_c_impl::initialize()
+ {
+ if(qApp != NULL) {
+ d_qApplication = qApp;
+ }
+ else {
+ int argc=0;
+ char **argv = NULL;
+ d_qApplication = new QApplication(argc, argv);
+ }
+
+ d_main_gui = new FreqDisplayForm(d_nconnections, d_parent);
+ d_main_gui->SetFFTSize(d_fftsize);
+ d_main_gui->SetFFTWindowType(d_wintype);
+ d_main_gui->SetFrequencyRange(d_center_freq,
+ d_center_freq - d_bandwidth/2.0,
+ d_center_freq + d_bandwidth/2.0);
+
+ // initialize update time to 10 times a second
+ set_update_time(0.1);
+ d_last_time = 0;
+ }
+
+ void
+ freq_sink_c_impl::exec_()
+ {
+ d_qApplication->exec();
+ }
+
+ QWidget*
+ freq_sink_c_impl::qwidget()
+ {
+ return d_main_gui;
+ }
+
+ PyObject*
+ freq_sink_c_impl::pyqwidget()
+ {
+ PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui);
+ PyObject *retarg = Py_BuildValue("N", w);
+ return retarg;
+ }
+
+ void
+ freq_sink_c_impl::set_fft_size(const int fftsize)
+ {
+ d_fftsize = fftsize;
+ d_main_gui->SetFFTSize(fftsize);
+ }
+
+ int
+ freq_sink_c_impl::fft_size() const
+ {
+ return d_fftsize;
+ }
+
+ void
+ freq_sink_c_impl::set_fft_average(const float fftavg)
+ {
+ d_fftavg = fftavg;
+ d_main_gui->SetFFTAverage(fftavg);
+ }
+
+ float
+ freq_sink_c_impl::fft_average() const
+ {
+ return d_fftavg;
+ }
+
+ void
+ freq_sink_c_impl::set_frequency_range(const double centerfreq,
+ const double bandwidth)
+ {
+ d_center_freq = centerfreq;
+ d_bandwidth = bandwidth;
+ d_main_gui->SetFrequencyRange(d_center_freq,
+ -d_bandwidth/2.0,
+ d_bandwidth/2.0);
+ }
+
+ void
+ freq_sink_c_impl::set_fft_power_db(double min, double max)
+ {
+ d_main_gui->SetFrequencyAxis(min, max);
+ }
+
+ void
+ freq_sink_c_impl::set_update_time(double t)
+ {
+ //convert update time to ticks
+ gruel::high_res_timer_type tps = gruel::high_res_timer_tps();
+ d_update_time = t * tps;
+ d_main_gui->setUpdateTime(t);
+ }
+
+ void
+ freq_sink_c_impl::set_title(int which, const std::string &title)
+ {
+ d_main_gui->setTitle(which, title.c_str());
+ }
+
+ void
+ freq_sink_c_impl::set_color(int which, const std::string &color)
+ {
+ d_main_gui->setColor(which, color.c_str());
+ }
+
+ void
+ freq_sink_c_impl::set_line_width(int which, int width)
+ {
+ d_main_gui->setLineWidth(which, width);
+ }
+
+ void
+ freq_sink_c_impl::set_line_style(int which, Qt::PenStyle style)
+ {
+ d_main_gui->setLineStyle(which, style);
+ }
+
+ void
+ freq_sink_c_impl::set_line_marker(int which, QwtSymbol::Style marker)
+ {
+ d_main_gui->setLineMarker(which, marker);
+ }
+
+ void
+ freq_sink_c_impl::set_size(int width, int height)
+ {
+ d_main_gui->resize(QSize(width, height));
+ }
+
+ void
+ freq_sink_c_impl::fft(float *data_out, const gr_complex *data_in, int size)
+ {
+ if(d_window.size()) {
+ volk_32fc_32f_multiply_32fc_a(d_fft->get_inbuf(), data_in,
+ &d_window.front(), size);
+ }
+ else {
+ memcpy(d_fft->get_inbuf(), data_in, sizeof(gr_complex)*size);
+ }
+
+ d_fft->execute(); // compute the fft
+
+ volk_32fc_s32f_x2_power_spectral_density_32f_a(data_out, d_fft->get_outbuf(),
+ size, 1.0, size);
+
+ // Perform shift operation
+ unsigned int len = (unsigned int)(floor(size/2.0));
+ float *tmp = (float*)malloc(sizeof(float)*len);
+ memcpy(tmp, &data_out[0], sizeof(float)*len);
+ memcpy(&data_out[0], &data_out[len], sizeof(float)*(size - len));
+ memcpy(&data_out[size - len], tmp, sizeof(float)*len);
+ free(tmp);
+ }
+
+ void
+ freq_sink_c_impl::windowreset()
+ {
+ filter::firdes::win_type newwintype;
+ newwintype = d_main_gui->GetFFTWindowType();
+ if(d_wintype != newwintype) {
+ d_wintype = newwintype;
+ buildwindow();
+ }
+ }
+
+ void
+ freq_sink_c_impl::buildwindow()
+ {
+ d_window.clear();
+ if(d_wintype != 0) {
+ d_window = filter::firdes::window(d_wintype, d_fftsize, 6.76);
+ }
+ }
+
+ void
+ freq_sink_c_impl::fftresize()
+ {
+ gruel::scoped_lock lock(d_mutex);
+
+ int newfftsize = d_main_gui->GetFFTSize();
+ d_fftavg = d_main_gui->GetFFTAverage();
+
+ if(newfftsize != d_fftsize) {
+ // Resize residbuf and replace data
+ for(int i = 0; i < d_nconnections; i++) {
+ gr::fft::free(d_residbufs[i]);
+ gr::fft::free(d_magbufs[i]);
+
+ d_residbufs[i] = gr::fft::malloc_complex(newfftsize);
+ d_magbufs[i] = gr::fft::malloc_double(newfftsize);
+
+ memset(d_magbufs[i], 0, newfftsize*sizeof(double));
+ }
+
+ // Set new fft size and reset buffer index
+ // (throws away any currently held data, but who cares?)
+ d_fftsize = newfftsize;
+ d_index = 0;
+
+ // Reset window to reflect new size
+ buildwindow();
+
+ // Reset FFTW plan for new size
+ delete d_fft;
+ d_fft = new gr::fft::fft_complex(d_fftsize, true);
+
+ gr::fft::free(d_fbuf);
+ d_fbuf = gr::fft::malloc_float(d_fftsize);
+ }
+ }
+
+ int
+ freq_sink_c_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ int j=0;
+ const gr_complex *in = (const gr_complex*)input_items[0];
+
+ // Update the FFT size from the application
+ fftresize();
+ windowreset();
+
+ for(int i=0; i < noutput_items; i+=d_fftsize) {
+ unsigned int datasize = noutput_items - i;
+ unsigned int resid = d_fftsize-d_index;
+
+ // If we have enough input for one full FFT, do it
+ if(datasize >= resid) {
+
+ for(int n = 0; n < d_nconnections; n++) {
+ // Fill up residbuf with d_fftsize number of items
+ in = (const gr_complex*)input_items[n];
+ memcpy(d_residbufs[n]+d_index, &in[j], sizeof(gr_complex)*resid);
+
+ fft(d_fbuf, d_residbufs[n], d_fftsize);
+ for(int x = 0; x < d_fftsize; x++) {
+ d_magbufs[n][x] = (double)((1.0-d_fftavg)*d_magbufs[n][x] + (d_fftavg)*d_fbuf[x]);
+ }
+
+ //volk_32f_convert_64f_a(d_magbufs[n], d_fbuf, d_fftsize);
+ }
+
+ if(gruel::high_res_timer_now() - d_last_time > d_update_time) {
+ d_last_time = gruel::high_res_timer_now();
+ d_qApplication->postEvent(d_main_gui,
+ new FreqUpdateEvent(d_magbufs, d_fftsize));
+ }
+
+ d_index = 0;
+ j += resid;
+ }
+ // Otherwise, copy what we received into the residbuf for next time
+ else {
+ for(int n = 0; n < d_nconnections; n++) {
+ in = (const gr_complex*)input_items[n];
+ memcpy(d_residbufs[n]+d_index, &in[j], sizeof(gr_complex)*datasize);
+ }
+ d_index += datasize;
+ j += datasize;
+ }
+ }
+
+ return noutput_items;
+ }
+
+ } /* namespace qtgui */
+} /* namespace gr */
diff --git a/gr-qtgui/lib/freq_sink_c_impl.h b/gr-qtgui/lib/freq_sink_c_impl.h
new file mode 100644
index 0000000000..ab2bc8c075
--- /dev/null
+++ b/gr-qtgui/lib/freq_sink_c_impl.h
@@ -0,0 +1,110 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_QTGUI_FREQ_SINK_C_IMPL_H
+#define INCLUDED_QTGUI_FREQ_SINK_C_IMPL_H
+
+#include <qtgui/freq_sink_c.h>
+#include <filter/firdes.h>
+#include <fft/fft.h>
+#include <gruel/high_res_timer.h>
+#include <gruel/thread.h>
+#include <freqdisplayform.h>
+
+namespace gr {
+ namespace qtgui {
+
+ class QTGUI_API freq_sink_c_impl : public freq_sink_c
+ {
+ private:
+ void forecast(int noutput_items, gr_vector_int &ninput_items_required);
+
+ void initialize();
+
+ gruel::mutex d_mutex;
+
+ int d_fftsize;
+ float d_fftavg;
+ filter::firdes::win_type d_wintype;
+ std::vector<float> d_window;
+ double d_center_freq;
+ double d_bandwidth;
+ std::string d_name;
+ int d_nconnections;
+
+ bool d_shift;
+ gr::fft::fft_complex *d_fft;
+
+ int d_index;
+ std::vector<gr_complex*> d_residbufs;
+ std::vector<double*> d_magbufs;
+ float *d_fbuf;
+
+ QWidget *d_parent;
+ FreqDisplayForm *d_main_gui;
+
+ gruel::high_res_timer_type d_update_time;
+ gruel::high_res_timer_type d_last_time;
+
+ void windowreset();
+ void buildwindow();
+ void fftresize();
+ void fft(float *data_out, const gr_complex *data_in, int size);
+
+ public:
+ freq_sink_c_impl(int size, int wintype,
+ double fc, double bw,
+ const std::string &name,
+ int nconnections,
+ QWidget *parent=NULL);
+ ~freq_sink_c_impl();
+
+ void exec_();
+ QWidget* qwidget();
+ PyObject* pyqwidget();
+
+ void set_fft_size(const int fftsize);
+ int fft_size() const;
+ void set_fft_average(const float fftavg);
+ float fft_average() const;
+
+ void set_frequency_range(const double centerfreq, const double bandwidth);
+ void set_fft_power_db(double min, double max);
+
+ void set_update_time(double t);
+ void set_title(int which, const std::string &title);
+ void set_color(int which, const std::string &color);
+ void set_line_width(int which, int width);
+ void set_line_style(int which, Qt::PenStyle style);
+ void set_line_marker(int which, QwtSymbol::Style marker);
+
+ void set_size(int width, int height);
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace qtgui */
+} /* namespace gr */
+
+#endif /* INCLUDED_QTGUI_FREQ_SINK_C_IMPL_H */
diff --git a/gr-qtgui/lib/freq_sink_f_impl.cc b/gr-qtgui/lib/freq_sink_f_impl.cc
new file mode 100644
index 0000000000..a876c259c1
--- /dev/null
+++ b/gr-qtgui/lib/freq_sink_f_impl.cc
@@ -0,0 +1,366 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "freq_sink_f_impl.h"
+#include <gr_io_signature.h>
+#include <string.h>
+#include <volk/volk.h>
+#include <fft/fft.h>
+
+namespace gr {
+ namespace qtgui {
+
+ freq_sink_f::sptr freq_sink_f::make(int fftsize, int wintype,
+ double fc, double bw,
+ const std::string &name,
+ int nconnections,
+ QWidget *parent)
+ {
+ return gnuradio::get_initial_sptr
+ (new freq_sink_f_impl(fftsize, wintype,
+ fc, bw, name,
+ nconnections,
+ parent));
+ }
+
+ freq_sink_f_impl::freq_sink_f_impl(int fftsize, int wintype,
+ double fc, double bw,
+ const std::string &name,
+ int nconnections,
+ QWidget *parent)
+ : gr_sync_block("freq_sink_f",
+ gr_make_io_signature(1, -1, sizeof(float)),
+ gr_make_io_signature(0, 0, 0)),
+ d_fftsize(fftsize), d_fftavg(1.0),
+ d_wintype((filter::firdes::win_type)(wintype)),
+ d_center_freq(fc), d_bandwidth(bw), d_name(name),
+ d_nconnections(nconnections), d_parent(parent)
+ {
+ d_main_gui = NULL;
+
+ // Perform fftshift operation;
+ // this is usually desired when plotting
+ d_shift = true;
+
+ d_fft = new gr::fft::fft_complex(d_fftsize, true);
+ d_fbuf = gr::fft::malloc_float(d_fftsize);
+
+ d_index = 0;
+ for(int i = 0; i < d_nconnections; i++) {
+ d_residbufs.push_back(gr::fft::malloc_float(d_fftsize));
+ d_magbufs.push_back(gr::fft::malloc_double(d_fftsize));
+ }
+
+ buildwindow();
+
+ initialize();
+ }
+
+ freq_sink_f_impl::~freq_sink_f_impl()
+ {
+ for(int i = 0; i < d_nconnections; i++) {
+ gr::fft::free(d_residbufs[i]);
+ gr::fft::free(d_magbufs[i]);
+ }
+ delete d_fft;
+ gr::fft::free(d_fbuf);
+ }
+
+ void
+ freq_sink_f_impl::forecast(int noutput_items, gr_vector_int &ninput_items_required)
+ {
+ unsigned int ninputs = ninput_items_required.size();
+ for (unsigned int i = 0; i < ninputs; i++) {
+ ninput_items_required[i] = std::min(d_fftsize, 8191);
+ }
+ }
+
+ void
+ freq_sink_f_impl::initialize()
+ {
+ if(qApp != NULL) {
+ d_qApplication = qApp;
+ }
+ else {
+ int argc=0;
+ char **argv = NULL;
+ d_qApplication = new QApplication(argc, argv);
+ }
+
+ d_main_gui = new FreqDisplayForm(d_nconnections, d_parent);
+ d_main_gui->SetFFTSize(d_fftsize);
+ d_main_gui->SetFFTWindowType(d_wintype);
+ d_main_gui->SetFrequencyRange(d_center_freq,
+ d_center_freq - d_bandwidth/2.0,
+ d_center_freq + d_bandwidth/2.0);
+
+ // initialize update time to 10 times a second
+ set_update_time(0.1);
+ d_last_time = 0;
+ }
+
+ void
+ freq_sink_f_impl::exec_()
+ {
+ d_qApplication->exec();
+ }
+
+ QWidget*
+ freq_sink_f_impl::qwidget()
+ {
+ return d_main_gui;
+ }
+
+ PyObject*
+ freq_sink_f_impl::pyqwidget()
+ {
+ PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui);
+ PyObject *retarg = Py_BuildValue("N", w);
+ return retarg;
+ }
+
+ void
+ freq_sink_f_impl::set_fft_size(const int fftsize)
+ {
+ d_fftsize = fftsize;
+ d_main_gui->SetFFTSize(fftsize);
+ }
+
+ int
+ freq_sink_f_impl::fft_size() const
+ {
+ return d_fftsize;
+ }
+
+ void
+ freq_sink_f_impl::set_fft_average(const float fftavg)
+ {
+ d_fftavg = fftavg;
+ d_main_gui->SetFFTAverage(fftavg);
+ }
+
+ float
+ freq_sink_f_impl::fft_average() const
+ {
+ return d_fftavg;
+ }
+
+ void
+ freq_sink_f_impl::set_frequency_range(const double centerfreq,
+ const double bandwidth)
+ {
+ d_center_freq = centerfreq;
+ d_bandwidth = bandwidth;
+ d_main_gui->SetFrequencyRange(d_center_freq,
+ -d_bandwidth/2.0,
+ d_bandwidth/2.0);
+ }
+
+ void
+ freq_sink_f_impl::set_fft_power_db(double min, double max)
+ {
+ d_main_gui->SetFrequencyAxis(min, max);
+ }
+
+ void
+ freq_sink_f_impl::set_update_time(double t)
+ {
+ //convert update time to ticks
+ gruel::high_res_timer_type tps = gruel::high_res_timer_tps();
+ d_update_time = t * tps;
+ d_main_gui->setUpdateTime(t);
+ }
+
+ void
+ freq_sink_f_impl::set_title(int which, const std::string &title)
+ {
+ d_main_gui->setTitle(which, title.c_str());
+ }
+
+ void
+ freq_sink_f_impl::set_color(int which, const std::string &color)
+ {
+ d_main_gui->setColor(which, color.c_str());
+ }
+
+ void
+ freq_sink_f_impl::set_line_width(int which, int width)
+ {
+ d_main_gui->setLineWidth(which, width);
+ }
+
+ void
+ freq_sink_f_impl::set_line_style(int which, Qt::PenStyle style)
+ {
+ d_main_gui->setLineStyle(which, style);
+ }
+
+ void
+ freq_sink_f_impl::set_line_marker(int which, QwtSymbol::Style marker)
+ {
+ d_main_gui->setLineMarker(which, marker);
+ }
+
+
+ void
+ freq_sink_f_impl::set_size(int width, int height)
+ {
+ d_main_gui->resize(QSize(width, height));
+ }
+
+ void
+ freq_sink_f_impl::fft(float *data_out, const float *data_in, int size)
+ {
+ // float to complex conversion
+ gr_complex *dst = d_fft->get_inbuf();
+ for (int i = 0; i < size; i++)
+ dst[i] = data_in[i];
+
+ if(d_window.size()) {
+ volk_32fc_32f_multiply_32fc_a(d_fft->get_inbuf(), dst,
+ &d_window.front(), size);
+ }
+
+ d_fft->execute(); // compute the fft
+ volk_32fc_s32f_x2_power_spectral_density_32f_a(data_out, d_fft->get_outbuf(),
+ size, 1.0, size);
+ }
+
+ void
+ freq_sink_f_impl::windowreset()
+ {
+ gruel::scoped_lock lock(d_mutex);
+
+ filter::firdes::win_type newwintype;
+ newwintype = d_main_gui->GetFFTWindowType();
+ if(d_wintype != newwintype) {
+ d_wintype = newwintype;
+ buildwindow();
+ }
+ }
+
+ void
+ freq_sink_f_impl::buildwindow()
+ {
+ d_window.clear();
+ if(d_wintype != 0) {
+ d_window = filter::firdes::window(d_wintype, d_fftsize, 6.76);
+ }
+ }
+
+ void
+ freq_sink_f_impl::fftresize()
+ {
+ gruel::scoped_lock lock(d_mutex);
+
+ int newfftsize = d_main_gui->GetFFTSize();
+ d_fftavg = d_main_gui->GetFFTAverage();
+
+ if(newfftsize != d_fftsize) {
+ // Resize residbuf and replace data
+ for(int i = 0; i < d_nconnections; i++) {
+ gr::fft::free(d_residbufs[i]);
+ gr::fft::free(d_magbufs[i]);
+
+ d_residbufs[i] = gr::fft::malloc_float(newfftsize);
+ d_magbufs[i] = gr::fft::malloc_double(newfftsize);
+
+ memset(d_magbufs[i], 0, newfftsize*sizeof(double));
+ }
+
+ // Set new fft size and reset buffer index
+ // (throws away any currently held data, but who cares?)
+ d_fftsize = newfftsize;
+ d_index = 0;
+
+ // Reset window to reflect new size
+ buildwindow();
+
+ // Reset FFTW plan for new size
+ delete d_fft;
+ d_fft = new gr::fft::fft_complex(d_fftsize, true);
+
+ gr::fft::free(d_fbuf);
+ d_fbuf = gr::fft::malloc_float(d_fftsize);
+ }
+ }
+
+ int
+ freq_sink_f_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ int j=0;
+ const float *in = (const float*)input_items[0];
+
+ // Update the FFT size from the application
+ fftresize();
+ windowreset();
+
+ for(int i=0; i < noutput_items; i+=d_fftsize) {
+ unsigned int datasize = noutput_items - i;
+ unsigned int resid = d_fftsize-d_index;
+
+ // If we have enough input for one full FFT, do it
+ if(datasize >= resid) {
+
+ for(int n = 0; n < d_nconnections; n++) {
+ // Fill up residbuf with d_fftsize number of items
+ in = (const float*)input_items[n];
+ memcpy(d_residbufs[n]+d_index, &in[j], sizeof(float)*resid);
+
+ fft(d_fbuf, d_residbufs[n], d_fftsize);
+ for(int x = 0; x < d_fftsize; x++) {
+ d_magbufs[n][x] = (double)((1.0-d_fftavg)*d_magbufs[n][x] + (d_fftavg)*d_fbuf[x]);
+ }
+ //volk_32f_convert_64f_a(d_magbufs[n], d_fbuf, d_fftsize);
+ }
+
+ if(gruel::high_res_timer_now() - d_last_time > d_update_time) {
+ d_last_time = gruel::high_res_timer_now();
+ d_qApplication->postEvent(d_main_gui,
+ new FreqUpdateEvent(d_magbufs, d_fftsize));
+ }
+
+ d_index = 0;
+ j += resid;
+ }
+ // Otherwise, copy what we received into the residbuf for next time
+ else {
+ for(int n = 0; n < d_nconnections; n++) {
+ in = (const float*)input_items[n];
+ memcpy(d_residbufs[n]+d_index, &in[j], sizeof(float)*datasize);
+ }
+ d_index += datasize;
+ j += datasize;
+ }
+ }
+
+ return noutput_items;
+ }
+
+ } /* namespace qtgui */
+} /* namespace gr */
diff --git a/gr-qtgui/lib/freq_sink_f_impl.h b/gr-qtgui/lib/freq_sink_f_impl.h
new file mode 100644
index 0000000000..d1cc3728ad
--- /dev/null
+++ b/gr-qtgui/lib/freq_sink_f_impl.h
@@ -0,0 +1,110 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_QTGUI_FREQ_SINK_F_IMPL_H
+#define INCLUDED_QTGUI_FREQ_SINK_F_IMPL_H
+
+#include <qtgui/freq_sink_f.h>
+#include <filter/firdes.h>
+#include <fft/fft.h>
+#include <gruel/high_res_timer.h>
+#include <gruel/thread.h>
+#include <freqdisplayform.h>
+
+namespace gr {
+ namespace qtgui {
+
+ class QTGUI_API freq_sink_f_impl : public freq_sink_f
+ {
+ private:
+ void forecast(int noutput_items, gr_vector_int &ninput_items_required);
+
+ void initialize();
+
+ gruel::mutex d_mutex;
+
+ int d_fftsize;
+ float d_fftavg;
+ filter::firdes::win_type d_wintype;
+ std::vector<float> d_window;
+ double d_center_freq;
+ double d_bandwidth;
+ std::string d_name;
+ int d_nconnections;
+
+ bool d_shift;
+ gr::fft::fft_complex *d_fft;
+
+ int d_index;
+ std::vector<float*> d_residbufs;
+ std::vector<double*> d_magbufs;
+ float *d_fbuf;
+
+ QWidget *d_parent;
+ FreqDisplayForm *d_main_gui;
+
+ gruel::high_res_timer_type d_update_time;
+ gruel::high_res_timer_type d_last_time;
+
+ void windowreset();
+ void buildwindow();
+ void fftresize();
+ void fft(float *data_out, const float *data_in, int size);
+
+ public:
+ freq_sink_f_impl(int size, int wintype,
+ double fc, double bw,
+ const std::string &name,
+ int nconnections,
+ QWidget *parent=NULL);
+ ~freq_sink_f_impl();
+
+ void exec_();
+ QWidget* qwidget();
+ PyObject* pyqwidget();
+
+ void set_fft_size(const int fftsize);
+ int fft_size() const;
+ void set_fft_average(const float fftavg);
+ float fft_average() const;
+
+ void set_frequency_range(const double centerfreq, const double bandwidth);
+ void set_fft_power_db(double min, double max);
+
+ void set_update_time(double t);
+ void set_title(int which, const std::string &title);
+ void set_color(int which, const std::string &color);
+ void set_line_width(int which, int width);
+ void set_line_style(int which, Qt::PenStyle style);
+ void set_line_marker(int which, QwtSymbol::Style marker);
+
+ void set_size(int width, int height);
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace qtgui */
+} /* namespace gr */
+
+#endif /* INCLUDED_QTGUI_FREQ_SINK_F_IMPL_H */
diff --git a/gr-qtgui/lib/freqdisplayform.cc b/gr-qtgui/lib/freqdisplayform.cc
index d186a5a33e..e8d4ac475d 100644
--- a/gr-qtgui/lib/freqdisplayform.cc
+++ b/gr-qtgui/lib/freqdisplayform.cc
@@ -101,6 +101,12 @@ FreqDisplayForm::GetFFTAverage() const
return _fftavg;
}
+gr::filter::firdes::win_type
+FreqDisplayForm::GetFFTWindowType() const
+{
+ return _fftwintype;
+}
+
void
FreqDisplayForm::SetFFTSize(const int newsize)
{
@@ -115,6 +121,12 @@ FreqDisplayForm::SetFFTAverage(const float newavg)
}
void
+FreqDisplayForm::SetFFTWindowType(const gr::filter::firdes::win_type newwin)
+{
+ _fftwintype = newwin;
+}
+
+void
FreqDisplayForm::SetFrequencyRange(const double newCenterFrequency,
const double newStartFrequency,
const double newStopFrequency)
diff --git a/gr-qtgui/lib/freqdisplayform.h b/gr-qtgui/lib/freqdisplayform.h
index 5039ecc6d7..ffce317c4f 100644
--- a/gr-qtgui/lib/freqdisplayform.h
+++ b/gr-qtgui/lib/freqdisplayform.h
@@ -27,6 +27,7 @@
#include <FrequencyDisplayPlot.h>
#include <QtGui/QtGui>
#include <vector>
+#include <filter/firdes.h>
#include "displayform.h"
@@ -42,12 +43,14 @@ class FreqDisplayForm : public DisplayForm
int GetFFTSize() const;
float GetFFTAverage() const;
+ gr::filter::firdes::win_type GetFFTWindowType() const;
public slots:
void customEvent(QEvent *e);
void SetFFTSize(const int);
void SetFFTAverage(const float);
+ void SetFFTWindowType(const gr::filter::firdes::win_type);
void SetFrequencyRange(const double newCenterFrequency,
const double newStartFrequency,
@@ -66,6 +69,7 @@ private:
int _fftsize;
float _fftavg;
+ gr::filter::firdes::win_type _fftwintype;
};
#endif /* FREQ_DISPLAY_FORM_H */
diff --git a/gr-qtgui/lib/qtgui_const_sink_c.cc b/gr-qtgui/lib/qtgui_const_sink_c.cc
deleted file mode 100644
index 2e74930fa2..0000000000
--- a/gr-qtgui/lib/qtgui_const_sink_c.cc
+++ /dev/null
@@ -1,214 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <qtgui_const_sink_c.h>
-#include <gr_io_signature.h>
-#include <string.h>
-#include <volk/volk.h>
-#include <fft/fft.h>
-
-#include <QTimer>
-
-qtgui_const_sink_c_sptr
-qtgui_make_const_sink_c(int size,
- const std::string &name,
- int nconnections,
- QWidget *parent)
-{
- return gnuradio::get_initial_sptr
- (new qtgui_const_sink_c(size, name, nconnections, parent));
-}
-
-qtgui_const_sink_c::qtgui_const_sink_c(int size,
- const std::string &name,
- int nconnections,
- QWidget *parent)
- : gr_sync_block("const_sink_c",
- gr_make_io_signature(nconnections, nconnections, sizeof(gr_complex)),
- gr_make_io_signature(0, 0, 0)),
- d_size(size), d_name(name),
- d_nconnections(nconnections), d_parent(parent)
-{
- d_main_gui = NULL;
-
- d_index = 0;
-
- for(int i = 0; i < d_nconnections; i++) {
- d_residbufs_real.push_back(gr::fft::malloc_double(d_size));
- d_residbufs_imag.push_back(gr::fft::malloc_double(d_size));
- }
-
- // Set alignment properties for VOLK
- const int alignment_multiple =
- volk_get_alignment() / sizeof(gr_complex);
- set_alignment(std::max(1,alignment_multiple));
-
- initialize();
-}
-
-qtgui_const_sink_c::~qtgui_const_sink_c()
-{
- // d_main_gui is a qwidget destroyed with its parent
- for(int i = 0; i < d_nconnections; i++) {
- gr::fft::free(d_residbufs_real[i]);
- gr::fft::free(d_residbufs_imag[i]);
- }
-}
-
-void
-qtgui_const_sink_c::initialize()
-{
- if(qApp != NULL) {
- d_qApplication = qApp;
- }
- else {
- int argc=0;
- char **argv = NULL;
- d_qApplication = new QApplication(argc, argv);
- }
-
- d_main_gui = new ConstellationDisplayForm(d_nconnections, d_parent);
-
- // initialize update time to 10 times a second
- set_update_time(0.1);
- d_last_time = 0;
-}
-
-
-void
-qtgui_const_sink_c::exec_()
-{
- d_qApplication->exec();
-}
-
-QWidget*
-qtgui_const_sink_c::qwidget()
-{
- return d_main_gui;
-}
-
-PyObject*
-qtgui_const_sink_c::pyqwidget()
-{
- PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui);
- PyObject *retarg = Py_BuildValue("N", w);
- return retarg;
-}
-
-void
-qtgui_const_sink_c::set_update_time(double t)
-{
- //convert update time to ticks
- gruel::high_res_timer_type tps = gruel::high_res_timer_tps();
- d_update_time = t * tps;
- d_main_gui->setUpdateTime(t);
-}
-
-void
-qtgui_const_sink_c::set_title(int which, const std::string &title)
-{
- d_main_gui->setTitle(which, title.c_str());
-}
-
-void
-qtgui_const_sink_c::set_color(int which, const std::string &color)
-{
- d_main_gui->setColor(which, color.c_str());
-}
-
-void
-qtgui_const_sink_c::set_resize(int width, int height)
-{
- d_main_gui->resize(QSize(width, height));
-}
-
-int
-qtgui_const_sink_c::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- int n=0, j=0, idx=0;
- const gr_complex *in = (const gr_complex*)input_items[idx];
-
- for(int i=0; i < noutput_items; i+=d_size) {
- unsigned int datasize = noutput_items - i;
- unsigned int resid = d_size-d_index;
- idx = 0;
-
- // If we have enough input for one full plot, do it
- if(datasize >= resid) {
- d_current_time = gruel::high_res_timer_now();
-
- // Fill up residbufs with d_size number of items
- for(n = 0; n < d_nconnections; n++) {
- in = (const gr_complex*)input_items[idx++];
- if(is_unaligned()) {
- volk_32fc_deinterleave_64f_x2_u(d_residbufs_real[n],
- d_residbufs_imag[n],
- &in[j], resid);
- }
- else {
- volk_32fc_deinterleave_64f_x2_a(d_residbufs_real[n],
- d_residbufs_imag[n],
- &in[j], resid);
- }
- }
-
- // Update the plot if its time
- if(gruel::high_res_timer_now() - d_last_time > d_update_time) {
- d_last_time = gruel::high_res_timer_now();
- d_qApplication->postEvent(d_main_gui,
- new ConstUpdateEvent(d_residbufs_real,
- d_residbufs_imag,
- d_size));
- }
-
- d_index = 0;
- j += resid;
- }
-
- // Otherwise, copy what we received into the residbufs for next time
- else {
- for(n = 0; n < d_nconnections; n++) {
- in = (const gr_complex*)input_items[idx++];
- if(is_unaligned()) {
- volk_32fc_deinterleave_64f_x2_u(&d_residbufs_real[n][d_index],
- &d_residbufs_imag[n][d_index],
- &in[j], resid);
- }
- else {
- volk_32fc_deinterleave_64f_x2_a(&d_residbufs_real[n][d_index],
- &d_residbufs_imag[n][d_index],
- &in[j], resid);
- }
- }
- d_index += datasize;
- j += datasize;
- }
- }
-
- return noutput_items;
-}
diff --git a/gr-qtgui/lib/qtgui_freq_sink_c.cc b/gr-qtgui/lib/qtgui_freq_sink_c.cc
deleted file mode 100644
index 7d6c3d7c00..0000000000
--- a/gr-qtgui/lib/qtgui_freq_sink_c.cc
+++ /dev/null
@@ -1,345 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <qtgui_freq_sink_c.h>
-#include <gr_io_signature.h>
-#include <string.h>
-
-#include <QTimer>
-#include <volk/volk.h>
-
-qtgui_freq_sink_c_sptr
-qtgui_make_freq_sink_c(int fftsize, int wintype,
- double fc, double bw,
- const std::string &name,
- int nconnections,
- QWidget *parent)
-{
- return gnuradio::get_initial_sptr
- (new qtgui_freq_sink_c(fftsize, wintype,
- fc, bw, name,
- nconnections,
- parent));
-}
-
-qtgui_freq_sink_c::qtgui_freq_sink_c(int fftsize, int wintype,
- double fc, double bw,
- const std::string &name,
- int nconnections,
- QWidget *parent)
- : gr_sync_block("freq_sink_c",
- gr_make_io_signature(1, -1, sizeof(gr_complex)),
- gr_make_io_signature(0, 0, 0)),
- d_fftsize(fftsize), d_fftavg(1.0),
- d_wintype((gr_firdes::win_type)(wintype)),
- d_center_freq(fc), d_bandwidth(bw), d_name(name),
- d_nconnections(nconnections), d_parent(parent)
-{
- d_main_gui = NULL;
-
- // Perform fftshift operation;
- // this is usually desired when plotting
- d_shift = true;
-
- d_fft = new gr::fft::fft_complex(d_fftsize, true);
- d_fbuf = gr::fft::malloc_float(d_fftsize);
-
- d_index = 0;
- for(int i = 0; i < d_nconnections; i++) {
- d_residbufs.push_back(gr::fft::malloc_complex(d_fftsize));
- d_magbufs.push_back(gr::fft::malloc_double(d_fftsize));
- }
-
- buildwindow();
-
- initialize();
-}
-
-qtgui_freq_sink_c::~qtgui_freq_sink_c()
-{
- for(int i = 0; i < d_nconnections; i++) {
- gr::fft::free(d_residbufs[i]);
- gr::fft::free(d_magbufs[i]);
- }
- delete d_fft;
- delete d_fbuf;
-}
-
-void
-qtgui_freq_sink_c::forecast(int noutput_items, gr_vector_int &ninput_items_required)
-{
- unsigned int ninputs = ninput_items_required.size();
- for (unsigned int i = 0; i < ninputs; i++) {
- ninput_items_required[i] = std::min(d_fftsize, 8191);
- }
-}
-
-void
-qtgui_freq_sink_c::initialize()
-{
- if(qApp != NULL) {
- d_qApplication = qApp;
- }
- else {
- int argc=0;
- char **argv = NULL;
- d_qApplication = new QApplication(argc, argv);
- }
-
- d_main_gui = new FreqDisplayForm(d_nconnections, d_parent);
- d_main_gui->SetFFTSize(d_fftsize);
- d_main_gui->SetFrequencyRange(d_center_freq,
- d_center_freq - d_bandwidth/2.0,
- d_center_freq + d_bandwidth/2.0);
-
- // initialize update time to 10 times a second
- set_update_time(0.1);
- d_last_time = 0;
-}
-
-void
-qtgui_freq_sink_c::exec_()
-{
- d_qApplication->exec();
-}
-
-QWidget*
-qtgui_freq_sink_c::qwidget()
-{
- return d_main_gui;
-}
-
-PyObject*
-qtgui_freq_sink_c::pyqwidget()
-{
- PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui);
- PyObject *retarg = Py_BuildValue("N", w);
- return retarg;
-}
-
-void
-qtgui_freq_sink_c::set_fft_size(const int fftsize)
-{
- d_fftsize = fftsize;
- d_main_gui->SetFFTSize(fftsize);
-}
-
-int
-qtgui_freq_sink_c::fft_size() const
-{
- return d_fftsize;
-}
-
-void
-qtgui_freq_sink_c::set_fft_average(const float fftavg)
-{
- d_fftavg = fftavg;
- d_main_gui->SetFFTAverage(fftavg);
-}
-
-float
-qtgui_freq_sink_c::fft_average() const
-{
- return d_fftavg;
-}
-
-void
-qtgui_freq_sink_c::set_frequency_range(const double centerfreq,
- const double bandwidth)
-{
- d_center_freq = centerfreq;
- d_bandwidth = bandwidth;
- d_main_gui->SetFrequencyRange(d_center_freq,
- -d_bandwidth/2.0,
- d_bandwidth/2.0);
-}
-
-void
-qtgui_freq_sink_c::set_fft_power_db(double min, double max)
-{
- d_main_gui->SetFrequencyAxis(min, max);
-}
-
-void
-qtgui_freq_sink_c::set_update_time(double t)
-{
- //convert update time to ticks
- gruel::high_res_timer_type tps = gruel::high_res_timer_tps();
- d_update_time = t * tps;
- d_main_gui->setUpdateTime(t);
-}
-
-void
-qtgui_freq_sink_c::set_title(int which, const std::string &title)
-{
- d_main_gui->setTitle(which, title.c_str());
-}
-
-void
-qtgui_freq_sink_c::set_color(int which, const std::string &color)
-{
- d_main_gui->setColor(which, color.c_str());
-}
-
-void
-qtgui_freq_sink_c::set_resize(int width, int height)
-{
- d_main_gui->resize(QSize(width, height));
-}
-
-void
-qtgui_freq_sink_c::fft(float *data_out, const gr_complex *data_in, int size)
-{
- if(d_window.size()) {
- volk_32fc_32f_multiply_32fc_a(d_fft->get_inbuf(), data_in, &d_window.front(), size);
- }
- else {
- memcpy(d_fft->get_inbuf(), data_in, sizeof(gr_complex)*size);
- }
-
- d_fft->execute(); // compute the fft
-
- volk_32fc_s32f_x2_power_spectral_density_32f_a(data_out, d_fft->get_outbuf(), size, 1.0, size);
-
- // Perform shift operation
- unsigned int len = (unsigned int)(floor(size/2.0));
- float *tmp = (float*)malloc(sizeof(float)*len);
- memcpy(tmp, &data_out[0], sizeof(float)*len);
- memcpy(&data_out[0], &data_out[len], sizeof(float)*(size - len));
- memcpy(&data_out[size - len], tmp, sizeof(float)*len);
- free(tmp);
-}
-
-void
-qtgui_freq_sink_c::windowreset()
-{
- //gr_firdes::win_type newwintype = (gr_firdes::win_type)d_main_gui->GetWindowType();
- //if(d_wintype != newwintype) {
- // d_wintype = newwintype;
- // buildwindow();
- //}
-}
-
-void
-qtgui_freq_sink_c::buildwindow()
-{
- d_window.clear();
- if(d_wintype != 0) {
- d_window = gr_firdes::window(d_wintype, d_fftsize, 6.76);
- }
-}
-
-void
-qtgui_freq_sink_c::fftresize()
-{
- gruel::scoped_lock lock(d_mutex);
-
- int newfftsize = d_main_gui->GetFFTSize();
- d_fftavg = d_main_gui->GetFFTAverage();
-
- if(newfftsize != d_fftsize) {
- // Resize residbuf and replace data
- for(int i = 0; i < d_nconnections; i++) {
- gr::fft::free(d_residbufs[i]);
- gr::fft::free(d_magbufs[i]);
-
- d_residbufs[i] = gr::fft::malloc_complex(newfftsize);
- d_magbufs[i] = gr::fft::malloc_double(newfftsize);
-
- memset(d_magbufs[i], 0, newfftsize*sizeof(double));
- }
-
- // Set new fft size and reset buffer index
- // (throws away any currently held data, but who cares?)
- d_fftsize = newfftsize;
- d_index = 0;
-
- // Reset window to reflect new size
- buildwindow();
-
- // Reset FFTW plan for new size
- delete d_fft;
- d_fft = new gr::fft::fft_complex(d_fftsize, true);
-
- gr::fft::free(d_fbuf);
- d_fbuf = gr::fft::malloc_float(d_fftsize);
- }
-}
-
-int
-qtgui_freq_sink_c::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- int j=0;
- const gr_complex *in = (const gr_complex*)input_items[0];
-
- // Update the FFT size from the application
- fftresize();
- windowreset();
-
- for(int i=0; i < noutput_items; i+=d_fftsize) {
- unsigned int datasize = noutput_items - i;
- unsigned int resid = d_fftsize-d_index;
-
- // If we have enough input for one full FFT, do it
- if(datasize >= resid) {
-
- for(int n = 0; n < d_nconnections; n++) {
- // Fill up residbuf with d_fftsize number of items
- in = (const gr_complex*)input_items[n];
- memcpy(d_residbufs[n]+d_index, &in[j], sizeof(gr_complex)*resid);
-
- fft(d_fbuf, d_residbufs[n], d_fftsize);
- for(int x = 0; x < d_fftsize; x++) {
- d_magbufs[n][x] = (double)((1.0-d_fftavg)*d_magbufs[n][x] + (d_fftavg)*d_fbuf[x]);
- }
-
- //volk_32f_convert_64f_a(d_magbufs[n], d_fbuf, d_fftsize);
- }
-
- if(gruel::high_res_timer_now() - d_last_time > d_update_time) {
- d_last_time = gruel::high_res_timer_now();
- d_qApplication->postEvent(d_main_gui,
- new FreqUpdateEvent(d_magbufs, d_fftsize));
- }
-
- d_index = 0;
- j += resid;
- }
- // Otherwise, copy what we received into the residbuf for next time
- else {
- for(int n = 0; n < d_nconnections; n++) {
- in = (const gr_complex*)input_items[n];
- memcpy(d_residbufs[n]+d_index, &in[j], sizeof(gr_complex)*datasize);
- }
- d_index += datasize;
- j += datasize;
- }
- }
-
- return noutput_items;
-}
diff --git a/gr-qtgui/lib/qtgui_freq_sink_f.cc b/gr-qtgui/lib/qtgui_freq_sink_f.cc
deleted file mode 100644
index c219edda6d..0000000000
--- a/gr-qtgui/lib/qtgui_freq_sink_f.cc
+++ /dev/null
@@ -1,336 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <qtgui_freq_sink_f.h>
-#include <gr_io_signature.h>
-#include <string.h>
-
-#include <QTimer>
-#include <volk/volk.h>
-
-qtgui_freq_sink_f_sptr
-qtgui_make_freq_sink_f(int fftsize, int wintype,
- double fc, double bw,
- const std::string &name,
- int nconnections,
- QWidget *parent)
-{
- return gnuradio::get_initial_sptr
- (new qtgui_freq_sink_f(fftsize, wintype,
- fc, bw, name,
- nconnections,
- parent));
-}
-
-qtgui_freq_sink_f::qtgui_freq_sink_f(int fftsize, int wintype,
- double fc, double bw,
- const std::string &name,
- int nconnections,
- QWidget *parent)
- : gr_sync_block("freq_sink_f",
- gr_make_io_signature(1, -1, sizeof(float)),
- gr_make_io_signature(0, 0, 0)),
- d_fftsize(fftsize), d_fftavg(1.0),
- d_wintype((gr_firdes::win_type)(wintype)),
- d_center_freq(fc), d_bandwidth(bw), d_name(name),
- d_nconnections(nconnections), d_parent(parent)
-{
- d_main_gui = NULL;
-
- // Perform fftshift operation;
- // this is usually desired when plotting
- d_shift = true;
-
- d_fft = new gr::fft::fft_complex(d_fftsize, true);
- d_fbuf = gr::fft::malloc_float(d_fftsize);
-
- d_index = 0;
- for(int i = 0; i < d_nconnections; i++) {
- d_residbufs.push_back(gr::fft::malloc_float(d_fftsize));
- d_magbufs.push_back(gr::fft::malloc_double(d_fftsize));
- }
-
- buildwindow();
-
- initialize();
-}
-
-qtgui_freq_sink_f::~qtgui_freq_sink_f()
-{
- for(int i = 0; i < d_nconnections; i++) {
- gr::fft::free(d_residbufs[i]);
- gr::fft::free(d_magbufs[i]);
- }
- delete d_fft;
- gr::fft::free(d_fbuf);
-}
-
-void
-qtgui_freq_sink_f::forecast(int noutput_items, gr_vector_int &ninput_items_required)
-{
- unsigned int ninputs = ninput_items_required.size();
- for (unsigned int i = 0; i < ninputs; i++) {
- ninput_items_required[i] = std::min(d_fftsize, 8191);
- }
-}
-
-void
-qtgui_freq_sink_f::initialize()
-{
- if(qApp != NULL) {
- d_qApplication = qApp;
- }
- else {
- int argc=0;
- char **argv = NULL;
- d_qApplication = new QApplication(argc, argv);
- }
-
- d_main_gui = new FreqDisplayForm(d_nconnections, d_parent);
- d_main_gui->SetFFTSize(d_fftsize);
- d_main_gui->SetFrequencyRange(d_center_freq,
- d_center_freq - d_bandwidth/2.0,
- d_center_freq + d_bandwidth/2.0);
-
- // initialize update time to 10 times a second
- set_update_time(0.1);
- d_last_time = 0;
-}
-
-void
-qtgui_freq_sink_f::exec_()
-{
- d_qApplication->exec();
-}
-
-QWidget*
-qtgui_freq_sink_f::qwidget()
-{
- return d_main_gui;
-}
-
-PyObject*
-qtgui_freq_sink_f::pyqwidget()
-{
- PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui);
- PyObject *retarg = Py_BuildValue("N", w);
- return retarg;
-}
-
-void
-qtgui_freq_sink_f::set_fft_size(const int fftsize)
-{
- d_fftsize = fftsize;
- d_main_gui->SetFFTSize(fftsize);
-}
-
-int
-qtgui_freq_sink_f::fft_size() const
-{
- return d_fftsize;
-}
-
-void
-qtgui_freq_sink_f::set_fft_average(const float fftavg)
-{
- d_fftavg = fftavg;
- d_main_gui->SetFFTAverage(fftavg);
-}
-
-float
-qtgui_freq_sink_f::fft_average() const
-{
- return d_fftavg;
-}
-
-void
-qtgui_freq_sink_f::set_frequency_range(const double centerfreq,
- const double bandwidth)
-{
- d_center_freq = centerfreq;
- d_bandwidth = bandwidth;
- d_main_gui->SetFrequencyRange(d_center_freq,
- -d_bandwidth/2.0,
- d_bandwidth/2.0);
-}
-
-void
-qtgui_freq_sink_f::set_fft_power_db(double min, double max)
-{
- d_main_gui->SetFrequencyAxis(min, max);
-}
-
-void
-qtgui_freq_sink_f::set_update_time(double t)
-{
- //convert update time to ticks
- gruel::high_res_timer_type tps = gruel::high_res_timer_tps();
- d_update_time = t * tps;
- d_main_gui->setUpdateTime(t);
-}
-
-void
-qtgui_freq_sink_f::set_title(int which, const std::string &title)
-{
- d_main_gui->setTitle(which, title.c_str());
-}
-
-void
-qtgui_freq_sink_f::set_color(int which, const std::string &color)
-{
- d_main_gui->setColor(which, color.c_str());
-}
-
-void
-qtgui_freq_sink_f::set_resize(int width, int height)
-{
- d_main_gui->resize(QSize(width, height));
-}
-
-void
-qtgui_freq_sink_f::fft(float *data_out, const float *data_in, int size)
-{
- // float to complex conversion
- gr_complex *dst = d_fft->get_inbuf();
- for (int i = 0; i < size; i++)
- dst[i] = data_in[i];
-
- if(d_window.size()) {
- volk_32fc_32f_multiply_32fc_a(d_fft->get_inbuf(), dst, &d_window.front(), size);
- }
-
- d_fft->execute(); // compute the fft
- volk_32fc_s32f_x2_power_spectral_density_32f_a(data_out, d_fft->get_outbuf(), size, 1.0, size);
-}
-
-void
-qtgui_freq_sink_f::windowreset()
-{
- //gr_firdes::win_type newwintype = (gr_firdes::win_type)d_main_gui->GetWindowType();
- //if(d_wintype != newwintype) {
- // d_wintype = newwintype;
- // buildwindow();
- //}
-}
-
-void
-qtgui_freq_sink_f::buildwindow()
-{
- d_window.clear();
- if(d_wintype != 0) {
- d_window = gr_firdes::window(d_wintype, d_fftsize, 6.76);
- }
-}
-
-void
-qtgui_freq_sink_f::fftresize()
-{
- gruel::scoped_lock lock(d_mutex);
-
- int newfftsize = d_main_gui->GetFFTSize();
- d_fftavg = d_main_gui->GetFFTAverage();
-
- if(newfftsize != d_fftsize) {
-
- // Resize residbuf and replace data
- for(int i = 0; i < d_nconnections; i++) {
- gr::fft::free(d_residbufs[i]);
- gr::fft::free(d_magbufs[i]);
-
- d_residbufs.push_back(gr::fft::malloc_float(newfftsize));
- d_magbufs.push_back(gr::fft::malloc_double(newfftsize));
- }
-
- // Set new fft size and reset buffer index
- // (throws away any currently held data, but who cares?)
- d_fftsize = newfftsize;
- d_index = 0;
-
- // Reset window to reflect new size
- buildwindow();
-
- // Reset FFTW plan for new size
- delete d_fft;
- d_fft = new gr::fft::fft_complex(d_fftsize, true);
-
- gr::fft::free(d_fbuf);
- d_fbuf = gr::fft::malloc_float(d_fftsize);
- }
-}
-
-int
-qtgui_freq_sink_f::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- int j=0;
- const float *in = (const float*)input_items[0];
-
- // Update the FFT size from the application
- fftresize();
- windowreset();
-
- for(int i=0; i < noutput_items; i+=d_fftsize) {
- unsigned int datasize = noutput_items - i;
- unsigned int resid = d_fftsize-d_index;
-
- // If we have enough input for one full FFT, do it
- if(datasize >= resid) {
-
- for(int n = 0; n < d_nconnections; n++) {
- // Fill up residbuf with d_fftsize number of items
- in = (const float*)input_items[n];
- memcpy(d_residbufs[n]+d_index, &in[j], sizeof(float)*resid);
-
- fft(d_fbuf, d_residbufs[n], d_fftsize);
- for(int x = 0; x < d_fftsize; x++) {
- d_magbufs[n][x] = (double)((1.0-d_fftavg)*d_magbufs[n][x] + (d_fftavg)*d_fbuf[x]);
- }
- //volk_32f_convert_64f_a(d_magbufs[n], d_fbuf, d_fftsize);
- }
-
- if(gruel::high_res_timer_now() - d_last_time > d_update_time) {
- d_last_time = gruel::high_res_timer_now();
- d_qApplication->postEvent(d_main_gui,
- new FreqUpdateEvent(d_magbufs, d_fftsize));
- }
-
- d_index = 0;
- j += resid;
- }
- // Otherwise, copy what we received into the residbuf for next time
- else {
- for(int n = 0; n < d_nconnections; n++) {
- in = (const float*)input_items[n];
- memcpy(d_residbufs[n]+d_index, &in[j], sizeof(float)*datasize);
- }
- d_index += datasize;
- j += datasize;
- }
- }
-
- return noutput_items;
-}
diff --git a/gr-qtgui/lib/qtgui_time_sink_c.cc b/gr-qtgui/lib/qtgui_time_sink_c.cc
deleted file mode 100644
index ef9c39afb7..0000000000
--- a/gr-qtgui/lib/qtgui_time_sink_c.cc
+++ /dev/null
@@ -1,215 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2011 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <qtgui_time_sink_c.h>
-#include <gr_io_signature.h>
-#include <string.h>
-#include <volk/volk.h>
-#include <fft/fft.h>
-
-#include <QTimer>
-
-qtgui_time_sink_c_sptr
-qtgui_make_time_sink_c(int size, double bw,
- const std::string &name,
- int nconnections,
- QWidget *parent)
-{
- return gnuradio::get_initial_sptr
- (new qtgui_time_sink_c(size, bw, name, nconnections, parent));
-}
-
-qtgui_time_sink_c::qtgui_time_sink_c(int size, double bw,
- const std::string &name,
- int nconnections,
- QWidget *parent)
- : gr_sync_block("time_sink_c",
- gr_make_io_signature(nconnections, nconnections, sizeof(gr_complex)),
- gr_make_io_signature(0, 0, 0)),
- d_size(size), d_bandwidth(bw), d_name(name),
- d_nconnections(2*nconnections), d_parent(parent)
-{
- d_main_gui = NULL;
-
- d_index = 0;
-
- for(int i = 0; i < d_nconnections; i++) {
- d_residbufs.push_back(gr::fft::malloc_double(d_size));
- }
-
- // Set alignment properties for VOLK
- const int alignment_multiple =
- volk_get_alignment() / sizeof(gr_complex);
- set_alignment(std::max(1,alignment_multiple));
-
- initialize();
-}
-
-qtgui_time_sink_c::~qtgui_time_sink_c()
-{
- // d_main_gui is a qwidget destroyed with its parent
- for(int i = 0; i < d_nconnections; i++) {
- gr::fft::free(d_residbufs[i]);
- }
-}
-
-void
-qtgui_time_sink_c::initialize()
-{
- if(qApp != NULL) {
- d_qApplication = qApp;
- }
- else {
- int argc=0;
- char **argv = NULL;
- d_qApplication = new QApplication(argc, argv);
- }
-
- d_main_gui = new TimeDisplayForm(d_nconnections, d_parent);
-
- // initialize update time to 10 times a second
- set_update_time(0.1);
- d_last_time = 0;
-}
-
-
-void
-qtgui_time_sink_c::exec_()
-{
- d_qApplication->exec();
-}
-
-QWidget*
-qtgui_time_sink_c::qwidget()
-{
- return d_main_gui;
-}
-
-PyObject*
-qtgui_time_sink_c::pyqwidget()
-{
- PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui);
- PyObject *retarg = Py_BuildValue("N", w);
- return retarg;
-}
-
-void
-qtgui_time_sink_c::set_time_domain_axis(double min, double max)
-{
- d_main_gui->setTimeDomainAxis(min, max);
-}
-
-void
-qtgui_time_sink_c::set_update_time(double t)
-{
- //convert update time to ticks
- gruel::high_res_timer_type tps = gruel::high_res_timer_tps();
- d_update_time = t * tps;
- d_main_gui->setUpdateTime(t);
-}
-
-void
-qtgui_time_sink_c::set_title(int which, const std::string &title)
-{
- d_main_gui->setTitle(which, title.c_str());
-}
-
-void
-qtgui_time_sink_c::set_color(int which, const std::string &color)
-{
- d_main_gui->setColor(which, color.c_str());
-}
-
-void
-qtgui_time_sink_c::set_resize(int width, int height)
-{
- d_main_gui->resize(QSize(width, height));
-}
-
-int
-qtgui_time_sink_c::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- int n=0, j=0, idx=0;
- const gr_complex *in = (const gr_complex*)input_items[idx];
-
- for(int i=0; i < noutput_items; i+=d_size) {
- unsigned int datasize = noutput_items - i;
- unsigned int resid = d_size-d_index;
- idx = 0;
-
- // If we have enough input for one full plot, do it
- if(datasize >= resid) {
-
- // Fill up residbufs with d_size number of items
- for(n = 0; n < d_nconnections; n+=2) {
- in = (const gr_complex*)input_items[idx++];
- if(is_unaligned()) {
- volk_32fc_deinterleave_64f_x2_u(&d_residbufs[n][d_index],
- &d_residbufs[n+1][d_index],
- &in[j], resid);
- }
- else {
- volk_32fc_deinterleave_64f_x2_a(&d_residbufs[n][d_index],
- &d_residbufs[n+1][d_index],
- &in[j], resid);
- }
- }
-
- // Update the plot if its time
- if(gruel::high_res_timer_now() - d_last_time > d_update_time) {
- d_last_time = gruel::high_res_timer_now();
- d_qApplication->postEvent(d_main_gui,
- new TimeUpdateEvent(d_residbufs, d_size));
- }
-
- d_index = 0;
- j += resid;
- }
-
- // Otherwise, copy what we received into the residbufs for next time
- else {
- for(n = 0; n < d_nconnections; n+=2) {
- in = (const gr_complex*)input_items[idx++];
- if(is_unaligned()) {
- volk_32fc_deinterleave_64f_x2_u(&d_residbufs[n][d_index],
- &d_residbufs[n+1][d_index],
- &in[j], datasize);
- }
- else {
- volk_32fc_deinterleave_64f_x2_a(&d_residbufs[n][d_index],
- &d_residbufs[n+1][d_index],
- &in[j], datasize);
- }
- }
- d_index += datasize;
- j += datasize;
- }
- }
-
- return noutput_items;
-}
diff --git a/gr-qtgui/lib/qtgui_time_sink_f.cc b/gr-qtgui/lib/qtgui_time_sink_f.cc
deleted file mode 100644
index 9ce5acd6ac..0000000000
--- a/gr-qtgui/lib/qtgui_time_sink_f.cc
+++ /dev/null
@@ -1,205 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2011 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <qtgui_time_sink_f.h>
-#include <gr_io_signature.h>
-#include <string.h>
-#include <volk/volk.h>
-#include <fft/fft.h>
-
-#include <QTimer>
-
-qtgui_time_sink_f_sptr
-qtgui_make_time_sink_f (int size, double bw,
- const std::string &name,
- int nconnections,
- QWidget *parent)
-{
- return gnuradio::get_initial_sptr(new qtgui_time_sink_f (size, bw, name,
- nconnections, parent));
-}
-
-qtgui_time_sink_f::qtgui_time_sink_f (int size, double bw,
- const std::string &name,
- int nconnections,
- QWidget *parent)
- : gr_sync_block ("time_sink_f",
- gr_make_io_signature (nconnections, nconnections, sizeof(float)),
- gr_make_io_signature (0, 0, 0)),
- d_size(size), d_bandwidth(bw), d_name(name),
- d_nconnections(nconnections), d_parent(parent)
-{
- d_main_gui = NULL;
-
- d_index = 0;
-
- for(int i = 0; i < d_nconnections; i++) {
- d_residbufs.push_back(gr::fft::malloc_double(d_size));
- }
-
- // Set alignment properties for VOLK
- const int alignment_multiple =
- volk_get_alignment() / sizeof(gr_complex);
- set_alignment(std::max(1,alignment_multiple));
-
- initialize();
-}
-
-qtgui_time_sink_f::~qtgui_time_sink_f()
-{
- // d_main_gui is a qwidget destroyed with its parent
- for(int i = 0; i < d_nconnections; i++) {
- gr::fft::free(d_residbufs[i]);
- }
-}
-
-void
-qtgui_time_sink_f::initialize()
-{
- if(qApp != NULL) {
- d_qApplication = qApp;
- }
- else {
- int argc=0;
- char **argv = NULL;
- d_qApplication = new QApplication(argc, argv);
- }
-
- d_main_gui = new TimeDisplayForm(d_nconnections, d_parent);
-
- // initialize update time to 10 times a second
- set_update_time(0.1);
- d_last_time = 0;
-}
-
-
-void
-qtgui_time_sink_f::exec_()
-{
- d_qApplication->exec();
-}
-
-QWidget*
-qtgui_time_sink_f::qwidget()
-{
- return d_main_gui;
-}
-
-PyObject*
-qtgui_time_sink_f::pyqwidget()
-{
- PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui);
- PyObject *retarg = Py_BuildValue("N", w);
- return retarg;
-}
-
-void
-qtgui_time_sink_f::set_time_domain_axis(double min, double max)
-{
- d_main_gui->setTimeDomainAxis(min, max);
-}
-
-void
-qtgui_time_sink_f::set_update_time(double t)
-{
- //convert update time to ticks
- gruel::high_res_timer_type tps = gruel::high_res_timer_tps();
- d_update_time = t * tps;
- d_main_gui->setUpdateTime(t);
-}
-
-void
-qtgui_time_sink_f::set_title(int which, const std::string &title)
-{
- d_main_gui->setTitle(which, title.c_str());
-}
-
-void
-qtgui_time_sink_f::set_color(int which, const std::string &color)
-{
- d_main_gui->setColor(which, color.c_str());
-}
-
-int
-qtgui_time_sink_f::work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- int n=0, j=0, idx=0;
- const float *in = (const float*)input_items[idx];
-
- for(int i=0; i < noutput_items; i+=d_size) {
- unsigned int datasize = noutput_items - i;
- unsigned int resid = d_size-d_index;
- idx = 0;
-
- // If we have enough input for one full plot, do it
- if(datasize >= resid) {
-
- // Fill up residbufs with d_size number of items
- for(n = 0; n < d_nconnections; n++) {
- in = (const float*)input_items[idx++];
- if(is_unaligned()) {
- volk_32f_convert_64f_u(&d_residbufs[n][d_index],
- &in[j], resid);
- }
- else {
- volk_32f_convert_64f_a(&d_residbufs[n][d_index],
- &in[j], resid);
- }
- }
-
- // Update the plot if its time
- if(gruel::high_res_timer_now() - d_last_time > d_update_time) {
- d_last_time = gruel::high_res_timer_now();
- d_qApplication->postEvent(d_main_gui,
- new TimeUpdateEvent(d_residbufs, d_size));
- }
-
- d_index = 0;
- j += resid;
- }
- // Otherwise, copy what we received into the residbufs for next time
- // because we set the output_multiple, this should never need to be called
- else {
- for(n = 0; n < d_nconnections; n++) {
- in = (const float*)input_items[idx++];
- if(is_unaligned()) {
- volk_32f_convert_64f_u(&d_residbufs[n][d_index],
- &in[j], datasize);
- }
- else {
- volk_32f_convert_64f_a(&d_residbufs[n][d_index],
- &in[j], datasize);
- }
- }
- d_index += datasize;
- j += datasize;
- }
- }
-
- return noutput_items;
-}
diff --git a/gr-qtgui/lib/qtgui_util.cc b/gr-qtgui/lib/qtgui_util.cc
index 11ad2feb90..70dcb483fb 100644
--- a/gr-qtgui/lib/qtgui_util.cc
+++ b/gr-qtgui/lib/qtgui_util.cc
@@ -20,7 +20,7 @@
* Boston, MA 02110-1301, USA.
*/
-#include <qtgui_util.h>
+#include <qtgui/utils.h>
#include <QDebug>
QwtPickerDblClickPointMachine::QwtPickerDblClickPointMachine()
diff --git a/gr-qtgui/lib/qtgui_waterfall_sink_c.cc b/gr-qtgui/lib/qtgui_waterfall_sink_c.cc
deleted file mode 100644
index 07f830d0e7..0000000000
--- a/gr-qtgui/lib/qtgui_waterfall_sink_c.cc
+++ /dev/null
@@ -1,304 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <qtgui_waterfall_sink_c.h>
-#include <gr_io_signature.h>
-#include <string.h>
-
-#include <QTimer>
-#include <volk/volk.h>
-
-qtgui_waterfall_sink_c_sptr
-qtgui_make_waterfall_sink_c(int fftsize, int wintype,
- double fc, double bw,
- const std::string &name,
- int nconnections,
- QWidget *parent)
-{
- return gnuradio::get_initial_sptr
- (new qtgui_waterfall_sink_c(fftsize, wintype,
- fc, bw, name,
- nconnections,
- parent));
-}
-
-qtgui_waterfall_sink_c::qtgui_waterfall_sink_c(int fftsize, int wintype,
- double fc, double bw,
- const std::string &name,
- int nconnections,
- QWidget *parent)
- : gr_sync_block("waterfall_sink_c",
- gr_make_io_signature(1, -1, sizeof(gr_complex)),
- gr_make_io_signature(0, 0, 0)),
- d_fftsize(fftsize),
- d_wintype((gr_firdes::win_type)(wintype)),
- d_center_freq(fc), d_bandwidth(bw), d_name(name),
- d_nconnections(nconnections), d_parent(parent)
-{
- d_main_gui = NULL;
-
- // Perform fftshift operation;
- // this is usually desired when plotting
- d_shift = true;
-
- d_fft = new gr::fft::fft_complex(d_fftsize, true);
-
- d_index = 0;
- for(int i = 0; i < d_nconnections; i++) {
- d_residbufs.push_back(gr::fft::malloc_complex(d_fftsize));
- d_magbufs.push_back(gr::fft::malloc_double(d_fftsize));
- }
-
- buildwindow();
-
- initialize();
-}
-
-qtgui_waterfall_sink_c::~qtgui_waterfall_sink_c()
-{
- for(int i = 0; i < d_nconnections; i++) {
- gr::fft::free(d_residbufs[i]);
- gr::fft::free(d_magbufs[i]);
- }
- delete d_fft;
-}
-
-void
-qtgui_waterfall_sink_c::forecast(int noutput_items, gr_vector_int &ninput_items_required)
-{
- unsigned int ninputs = ninput_items_required.size();
- for (unsigned int i = 0; i < ninputs; i++) {
- ninput_items_required[i] = std::min(d_fftsize, 8191);
- }
-}
-
-void
-qtgui_waterfall_sink_c::initialize()
-{
- if(qApp != NULL) {
- d_qApplication = qApp;
- }
- else {
- int argc=0;
- char **argv = NULL;
- d_qApplication = new QApplication(argc, argv);
- }
-
- d_main_gui = new WaterfallDisplayForm(d_nconnections, d_parent);
- d_main_gui->SetFFTSize(d_fftsize);
- d_main_gui->SetFrequencyRange(d_center_freq,
- d_center_freq - d_bandwidth/2.0,
- d_center_freq + d_bandwidth/2.0);
-
- // initialize update time to 10 times a second
- set_update_time(0.1);
- d_last_time = 0;
-}
-
-void
-qtgui_waterfall_sink_c::exec_()
-{
- d_qApplication->exec();
-}
-
-QWidget*
-qtgui_waterfall_sink_c::qwidget()
-{
- return d_main_gui;
-}
-
-PyObject*
-qtgui_waterfall_sink_c::pyqwidget()
-{
- PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui);
- PyObject *retarg = Py_BuildValue("N", w);
- return retarg;
-}
-
-void
-qtgui_waterfall_sink_c::set_frequency_range(const double centerfreq,
- const double bandwidth)
-{
- d_center_freq = centerfreq;
- d_bandwidth = bandwidth;
- d_main_gui->SetFrequencyRange(d_center_freq,
- -d_bandwidth/2.0,
- d_bandwidth/2.0);
-}
-
-void
-qtgui_waterfall_sink_c::set_update_time(double t)
-{
- //convert update time to ticks
- gruel::high_res_timer_type tps = gruel::high_res_timer_tps();
- d_update_time = t * tps;
- d_main_gui->setUpdateTime(t);
-}
-
-void
-qtgui_waterfall_sink_c::set_title(int which, const std::string &title)
-{
- d_main_gui->setTitle(which, title.c_str());
-}
-
-void
-qtgui_waterfall_sink_c::set_color(int which, const std::string &color)
-{
- d_main_gui->setColor(which, color.c_str());
-}
-
-void
-qtgui_waterfall_sink_c::set_resize(int width, int height)
-{
- d_main_gui->resize(QSize(width, height));
-}
-
-void
-qtgui_waterfall_sink_c::fft(float *data_out, const gr_complex *data_in, int size)
-{
- if(d_window.size()) {
- volk_32fc_32f_multiply_32fc_a(d_fft->get_inbuf(), data_in, &d_window.front(), size);
- }
- else {
- memcpy(d_fft->get_inbuf(), data_in, sizeof(gr_complex)*size);
- }
-
- d_fft->execute(); // compute the fft
-
- volk_32fc_s32f_x2_power_spectral_density_32f_a(data_out, d_fft->get_outbuf(), size, 1.0, size);
-
- // Perform shift operation
- unsigned int len = (unsigned int)(floor(size/2.0));
- float *tmp = (float*)malloc(sizeof(float)*len);
- memcpy(tmp, &data_out[0], sizeof(float)*len);
- memcpy(&data_out[0], &data_out[len], sizeof(float)*(size - len));
- memcpy(&data_out[size - len], tmp, sizeof(float)*len);
- free(tmp);
-}
-
-void
-qtgui_waterfall_sink_c::windowreset()
-{
- //gr_firdes::win_type newwintype = (gr_firdes::win_type)d_main_gui->GetWindowType();
- //if(d_wintype != newwintype) {
- // d_wintype = newwintype;
- // buildwindow();
- //}
-}
-
-void
-qtgui_waterfall_sink_c::buildwindow()
-{
- d_window.clear();
- if(d_wintype != 0) {
- d_window = gr_firdes::window(d_wintype, d_fftsize, 6.76);
- }
-}
-
-void
-qtgui_waterfall_sink_c::fftresize()
-{
- int newfftsize = d_main_gui->GetFFTSize();
-
- if(newfftsize != d_fftsize) {
-
- // Resize residbuf and replace data
- for(int i = 0; i < d_nconnections; i++) {
- gr::fft::free(d_residbufs[i]);
- gr::fft::free(d_magbufs[i]);
-
- d_residbufs[i] = gr::fft::malloc_complex(newfftsize);
- d_magbufs[i] = gr::fft::malloc_double(newfftsize);
- }
-
- // Set new fft size and reset buffer index
- // (throws away any currently held data, but who cares?)
- d_fftsize = newfftsize;
- d_index = 0;
-
- // Reset window to reflect new size
- buildwindow();
-
- // Reset FFTW plan for new size
- delete d_fft;
- d_fft = new gr::fft::fft_complex(d_fftsize, true);
- }
-}
-
-int
-qtgui_waterfall_sink_c::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- int j=0;
- const gr_complex *in = (const gr_complex*)input_items[0];
-
- // Update the FFT size from the application
- fftresize();
- windowreset();
-
- for(int i=0; i < noutput_items; i+=d_fftsize) {
- unsigned int datasize = noutput_items - i;
- unsigned int resid = d_fftsize-d_index;
-
- // If we have enough input for one full FFT, do it
- if(datasize >= resid) {
-
- float *fbuf = gr::fft::malloc_float(d_fftsize);
- for(int n = 0; n < d_nconnections; n++) {
- // Fill up residbuf with d_fftsize number of items
- in = (const gr_complex*)input_items[n];
- memcpy(d_residbufs[n]+d_index, &in[j], sizeof(gr_complex)*resid);
-
- fft(fbuf, d_residbufs[n], d_fftsize);
- volk_32f_convert_64f_a(d_magbufs[n], fbuf, d_fftsize);
- }
- gr::fft::free(fbuf);
-
- if(gruel::high_res_timer_now() - d_last_time > d_update_time) {
- d_last_time = gruel::high_res_timer_now();
- d_qApplication->postEvent(d_main_gui,
- new WaterfallUpdateEvent(d_magbufs,
- d_fftsize,
- d_last_time));
- }
-
- d_index = 0;
- j += resid;
- }
- // Otherwise, copy what we received into the residbuf for next time
- else {
- for(int n = 0; n < d_nconnections; n++) {
- in = (const gr_complex*)input_items[n];
- memcpy(d_residbufs[n]+d_index, &in[j], sizeof(gr_complex)*datasize);
- }
- d_index += datasize;
- j += datasize;
- }
- }
-
- return noutput_items;
-}
diff --git a/gr-qtgui/lib/qtgui_waterfall_sink_f.cc b/gr-qtgui/lib/qtgui_waterfall_sink_f.cc
deleted file mode 100644
index 7f7ebb3ede..0000000000
--- a/gr-qtgui/lib/qtgui_waterfall_sink_f.cc
+++ /dev/null
@@ -1,298 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <qtgui_waterfall_sink_f.h>
-#include <gr_io_signature.h>
-#include <string.h>
-
-#include <QTimer>
-#include <volk/volk.h>
-
-qtgui_waterfall_sink_f_sptr
-qtgui_make_waterfall_sink_f(int fftsize, int wintype,
- double fc, double bw,
- const std::string &name,
- int nconnections,
- QWidget *parent)
-{
- return gnuradio::get_initial_sptr
- (new qtgui_waterfall_sink_f(fftsize, wintype,
- fc, bw, name,
- nconnections,
- parent));
-}
-
-qtgui_waterfall_sink_f::qtgui_waterfall_sink_f(int fftsize, int wintype,
- double fc, double bw,
- const std::string &name,
- int nconnections,
- QWidget *parent)
- : gr_sync_block("waterfall_sink_f",
- gr_make_io_signature(1, -1, sizeof(float)),
- gr_make_io_signature(0, 0, 0)),
- d_fftsize(fftsize),
- d_wintype((gr_firdes::win_type)(wintype)),
- d_center_freq(fc), d_bandwidth(bw), d_name(name),
- d_nconnections(nconnections), d_parent(parent)
-{
- d_main_gui = NULL;
-
- // Perform fftshift operation;
- // this is usually desired when plotting
- d_shift = true;
-
- d_fft = new gr::fft::fft_complex(d_fftsize, true);
-
- d_index = 0;
- for(int i = 0; i < d_nconnections; i++) {
- d_residbufs.push_back(gr::fft::malloc_float(d_fftsize));
- d_magbufs.push_back(gr::fft::malloc_double(d_fftsize));
- }
-
- buildwindow();
-
- initialize();
-}
-
-qtgui_waterfall_sink_f::~qtgui_waterfall_sink_f()
-{
- for(int i = 0; i < d_nconnections; i++) {
- gr::fft::free(d_residbufs[i]);
- gr::fft::free(d_magbufs[i]);
- }
- delete d_fft;
-}
-
-void
-qtgui_waterfall_sink_f::forecast(int noutput_items, gr_vector_int &ninput_items_required)
-{
- unsigned int ninputs = ninput_items_required.size();
- for (unsigned int i = 0; i < ninputs; i++) {
- ninput_items_required[i] = std::min(d_fftsize, 8191);
- }
-}
-
-void
-qtgui_waterfall_sink_f::initialize()
-{
- if(qApp != NULL) {
- d_qApplication = qApp;
- }
- else {
- int argc=0;
- char **argv = NULL;
- d_qApplication = new QApplication(argc, argv);
- }
-
- d_main_gui = new WaterfallDisplayForm(d_nconnections, d_parent);
- d_main_gui->SetFFTSize(d_fftsize);
- d_main_gui->SetFrequencyRange(d_center_freq,
- d_center_freq - d_bandwidth/2.0,
- d_center_freq + d_bandwidth/2.0);
-
- // initialize update time to 10 times a second
- set_update_time(0.1);
- d_last_time = 0;
-}
-
-void
-qtgui_waterfall_sink_f::exec_()
-{
- d_qApplication->exec();
-}
-
-QWidget*
-qtgui_waterfall_sink_f::qwidget()
-{
- return d_main_gui;
-}
-
-PyObject*
-qtgui_waterfall_sink_f::pyqwidget()
-{
- PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui);
- PyObject *retarg = Py_BuildValue("N", w);
- return retarg;
-}
-
-void
-qtgui_waterfall_sink_f::set_frequency_range(const double centerfreq,
- const double bandwidth)
-{
- d_center_freq = centerfreq;
- d_bandwidth = bandwidth;
- d_main_gui->SetFrequencyRange(d_center_freq,
- -d_bandwidth/2.0,
- d_bandwidth/2.0);
-}
-
-void
-qtgui_waterfall_sink_f::set_update_time(double t)
-{
- //convert update time to ticks
- gruel::high_res_timer_type tps = gruel::high_res_timer_tps();
- d_update_time = t * tps;
- d_main_gui->setUpdateTime(t);
-}
-
-void
-qtgui_waterfall_sink_f::set_title(int which, const std::string &title)
-{
- d_main_gui->setTitle(which, title.c_str());
-}
-
-void
-qtgui_waterfall_sink_f::set_color(int which, const std::string &color)
-{
- d_main_gui->setColor(which, color.c_str());
-}
-
-void
-qtgui_waterfall_sink_f::set_resize(int width, int height)
-{
- d_main_gui->resize(QSize(width, height));
-}
-
-void
-qtgui_waterfall_sink_f::fft(float *data_out, const float *data_in, int size)
-{
- // float to complex conversion
- gr_complex *dst = d_fft->get_inbuf();
- for (int i = 0; i < size; i++)
- dst[i] = data_in[i];
-
- if(d_window.size()) {
- volk_32fc_32f_multiply_32fc_a(d_fft->get_inbuf(), dst, &d_window.front(), size);
- }
-
- d_fft->execute(); // compute the fft
-
- volk_32fc_s32f_x2_power_spectral_density_32f_a(data_out, d_fft->get_outbuf(), size, 1.0, size);
-}
-
-void
-qtgui_waterfall_sink_f::windowreset()
-{
- //gr_firdes::win_type newwintype = (gr_firdes::win_type)d_main_gui->GetWindowType();
- //if(d_wintype != newwintype) {
- // d_wintype = newwintype;
- // buildwindow();
- //}
-}
-
-void
-qtgui_waterfall_sink_f::buildwindow()
-{
- d_window.clear();
- if(d_wintype != 0) {
- d_window = gr_firdes::window(d_wintype, d_fftsize, 6.76);
- }
-}
-
-void
-qtgui_waterfall_sink_f::fftresize()
-{
- int newfftsize = d_fftsize;
-
- if(newfftsize != d_fftsize) {
-
- // Resize residbuf and replace data
- for(int i = 0; i < d_nconnections; i++) {
- gr::fft::free(d_residbufs[i]);
- gr::fft::free(d_magbufs[i]);
-
- d_residbufs.push_back(gr::fft::malloc_float(newfftsize));
- d_magbufs.push_back(gr::fft::malloc_double(newfftsize));
- }
-
- // Set new fft size and reset buffer index
- // (throws away any currently held data, but who cares?)
- d_fftsize = newfftsize;
- d_index = 0;
-
- // Reset window to reflect new size
- buildwindow();
-
- // Reset FFTW plan for new size
- delete d_fft;
- d_fft = new gr::fft::fft_complex(d_fftsize, true);
- }
-}
-
-int
-qtgui_waterfall_sink_f::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- int j=0;
- const float *in = (const float*)input_items[0];
-
- // Update the FFT size from the application
- fftresize();
- windowreset();
-
- for(int i=0; i < noutput_items; i+=d_fftsize) {
- unsigned int datasize = noutput_items - i;
- unsigned int resid = d_fftsize-d_index;
-
- // If we have enough input for one full FFT, do it
- if(datasize >= resid) {
-
- float *fbuf = gr::fft::malloc_float(d_fftsize);
- for(int n = 0; n < d_nconnections; n++) {
- // Fill up residbuf with d_fftsize number of items
- in = (const float*)input_items[n];
- memcpy(d_residbufs[n]+d_index, &in[j], sizeof(float)*resid);
-
- fft(fbuf, d_residbufs[n], d_fftsize);
- volk_32f_convert_64f_a(d_magbufs[n], fbuf, d_fftsize);
- }
- gr::fft::free(fbuf);
-
- if(gruel::high_res_timer_now() - d_last_time > d_update_time) {
- d_last_time = gruel::high_res_timer_now();
- d_qApplication->postEvent(d_main_gui,
- new WaterfallUpdateEvent(d_magbufs,
- d_fftsize,
- d_last_time));
- }
-
- d_index = 0;
- j += resid;
- }
- // Otherwise, copy what we received into the residbuf for next time
- else {
- for(int n = 0; n < d_nconnections; n++) {
- in = (const float*)input_items[n];
- memcpy(d_residbufs[n]+d_index, &in[j], sizeof(float)*datasize);
- }
- d_index += datasize;
- j += datasize;
- }
- }
-
- return noutput_items;
-}
diff --git a/gr-qtgui/lib/time_sink_c_impl.cc b/gr-qtgui/lib/time_sink_c_impl.cc
new file mode 100644
index 0000000000..fc090501d2
--- /dev/null
+++ b/gr-qtgui/lib/time_sink_c_impl.cc
@@ -0,0 +1,235 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2011,2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "time_sink_c_impl.h"
+#include <gr_io_signature.h>
+#include <string.h>
+#include <volk/volk.h>
+#include <fft/fft.h>
+
+namespace gr {
+ namespace qtgui {
+
+ time_sink_c::sptr time_sink_c::make(int size, double bw,
+ const std::string &name,
+ int nconnections,
+ QWidget *parent)
+ {
+ return gnuradio::get_initial_sptr
+ (new time_sink_c_impl(size, bw, name, nconnections, parent));
+ }
+
+ time_sink_c_impl::time_sink_c_impl(int size, double bw,
+ const std::string &name,
+ int nconnections,
+ QWidget *parent)
+ : gr_sync_block("time_sink_c",
+ gr_make_io_signature(nconnections, nconnections, sizeof(gr_complex)),
+ gr_make_io_signature(0, 0, 0)),
+ d_size(size), d_bandwidth(bw), d_name(name),
+ d_nconnections(2*nconnections), d_parent(parent)
+ {
+ d_main_gui = NULL;
+
+ d_index = 0;
+
+ for(int i = 0; i < d_nconnections; i++) {
+ d_residbufs.push_back(gr::fft::malloc_double(d_size));
+ }
+
+ // Set alignment properties for VOLK
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(gr_complex);
+ set_alignment(std::max(1,alignment_multiple));
+
+ initialize();
+ }
+
+ time_sink_c_impl::~time_sink_c_impl()
+ {
+ // d_main_gui is a qwidget destroyed with its parent
+ for(int i = 0; i < d_nconnections; i++) {
+ gr::fft::free(d_residbufs[i]);
+ }
+ }
+
+ void
+ time_sink_c_impl::initialize()
+ {
+ if(qApp != NULL) {
+ d_qApplication = qApp;
+ }
+ else {
+ int argc=0;
+ char **argv = NULL;
+ d_qApplication = new QApplication(argc, argv);
+ }
+
+ d_main_gui = new TimeDisplayForm(d_nconnections, d_parent);
+
+ // initialize update time to 10 times a second
+ set_update_time(0.1);
+ d_last_time = 0;
+ }
+
+ void
+ time_sink_c_impl::exec_()
+ {
+ d_qApplication->exec();
+ }
+
+ QWidget*
+ time_sink_c_impl::qwidget()
+ {
+ return d_main_gui;
+ }
+
+ PyObject*
+ time_sink_c_impl::pyqwidget()
+ {
+ PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui);
+ PyObject *retarg = Py_BuildValue("N", w);
+ return retarg;
+ }
+
+ void
+ time_sink_c_impl::set_time_domain_axis(double min, double max)
+ {
+ d_main_gui->setTimeDomainAxis(min, max);
+ }
+
+ void
+ time_sink_c_impl::set_update_time(double t)
+ {
+ //convert update time to ticks
+ gruel::high_res_timer_type tps = gruel::high_res_timer_tps();
+ d_update_time = t * tps;
+ d_main_gui->setUpdateTime(t);
+ }
+
+ void
+ time_sink_c_impl::set_title(int which, const std::string &title)
+ {
+ d_main_gui->setTitle(which, title.c_str());
+ }
+
+ void
+ time_sink_c_impl::set_color(int which, const std::string &color)
+ {
+ d_main_gui->setColor(which, color.c_str());
+ }
+
+ void
+ time_sink_c_impl::set_line_width(int which, int width)
+ {
+ d_main_gui->setLineWidth(which, width);
+ }
+
+ void
+ time_sink_c_impl::set_line_style(int which, Qt::PenStyle style)
+ {
+ d_main_gui->setLineStyle(which, style);
+ }
+
+ void
+ time_sink_c_impl::set_line_marker(int which, QwtSymbol::Style marker)
+ {
+ d_main_gui->setLineMarker(which, marker);
+ }
+
+ void
+ time_sink_c_impl::set_size(int width, int height)
+ {
+ d_main_gui->resize(QSize(width, height));
+ }
+
+ int
+ time_sink_c_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ int n=0, j=0, idx=0;
+ const gr_complex *in = (const gr_complex*)input_items[idx];
+
+ for(int i=0; i < noutput_items; i+=d_size) {
+ unsigned int datasize = noutput_items - i;
+ unsigned int resid = d_size-d_index;
+ idx = 0;
+
+ // If we have enough input for one full plot, do it
+ if(datasize >= resid) {
+
+ // Fill up residbufs with d_size number of items
+ for(n = 0; n < d_nconnections; n+=2) {
+ in = (const gr_complex*)input_items[idx++];
+ if(is_unaligned()) {
+ volk_32fc_deinterleave_64f_x2_u(&d_residbufs[n][d_index],
+ &d_residbufs[n+1][d_index],
+ &in[j], resid);
+ }
+ else {
+ volk_32fc_deinterleave_64f_x2_a(&d_residbufs[n][d_index],
+ &d_residbufs[n+1][d_index],
+ &in[j], resid);
+ }
+ }
+
+ // Update the plot if its time
+ if(gruel::high_res_timer_now() - d_last_time > d_update_time) {
+ d_last_time = gruel::high_res_timer_now();
+ d_qApplication->postEvent(d_main_gui,
+ new TimeUpdateEvent(d_residbufs, d_size));
+ }
+
+ d_index = 0;
+ j += resid;
+ }
+
+ // Otherwise, copy what we received into the residbufs for next time
+ else {
+ for(n = 0; n < d_nconnections; n+=2) {
+ in = (const gr_complex*)input_items[idx++];
+ if(is_unaligned()) {
+ volk_32fc_deinterleave_64f_x2_u(&d_residbufs[n][d_index],
+ &d_residbufs[n+1][d_index],
+ &in[j], datasize);
+ }
+ else {
+ volk_32fc_deinterleave_64f_x2_a(&d_residbufs[n][d_index],
+ &d_residbufs[n+1][d_index],
+ &in[j], datasize);
+ }
+ }
+ d_index += datasize;
+ j += datasize;
+ }
+ }
+
+ return noutput_items;
+ }
+
+ } /* namespace qtgui */
+} /* namespace gr */
diff --git a/gr-qtgui/lib/time_sink_c_impl.h b/gr-qtgui/lib/time_sink_c_impl.h
new file mode 100644
index 0000000000..8509f73973
--- /dev/null
+++ b/gr-qtgui/lib/time_sink_c_impl.h
@@ -0,0 +1,82 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2011,2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_QTGUI_TIME_SINK_C_IMPL_H
+#define INCLUDED_QTGUI_TIME_SINK_C_IMPL_H
+
+#include <qtgui/time_sink_c.h>
+#include <fft/fft.h>
+#include <timedisplayform.h>
+#include <gruel/high_res_timer.h>
+
+namespace gr {
+ namespace qtgui {
+
+ class QTGUI_API time_sink_c_impl : public time_sink_c
+ {
+ private:
+ void initialize();
+
+ int d_size;
+ double d_bandwidth;
+ std::string d_name;
+ int d_nconnections;
+
+ int d_index;
+ std::vector<double*> d_residbufs;
+
+ QWidget *d_parent;
+ TimeDisplayForm *d_main_gui;
+
+ gruel::high_res_timer_type d_update_time;
+ gruel::high_res_timer_type d_last_time;
+
+ public:
+ time_sink_c_impl(int size, double bw,
+ const std::string &name,
+ int nconnections,
+ QWidget *parent=NULL);
+ ~time_sink_c_impl();
+
+ void exec_();
+ QWidget* qwidget();
+ PyObject* pyqwidget();
+
+ void set_time_domain_axis(double min, double max);
+ void set_update_time(double t);
+ void set_title(int which, const std::string &title);
+ void set_color(int which, const std::string &color);
+ void set_line_width(int which, int width);
+ void set_line_style(int which, Qt::PenStyle style);
+ void set_line_marker(int which, QwtSymbol::Style marker);
+
+ void set_size(int width, int height);
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace qtgui */
+} /* namespace gr */
+
+#endif /* INCLUDED_QTGUI_TIME_SINK_C_IMPL_H */
diff --git a/gr-qtgui/lib/time_sink_f_impl.cc b/gr-qtgui/lib/time_sink_f_impl.cc
new file mode 100644
index 0000000000..d93d267924
--- /dev/null
+++ b/gr-qtgui/lib/time_sink_f_impl.cc
@@ -0,0 +1,233 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2011,2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "time_sink_f_impl.h"
+#include <gr_io_signature.h>
+#include <string.h>
+#include <volk/volk.h>
+#include <fft/fft.h>
+
+#include <QTimer>
+
+namespace gr {
+ namespace qtgui {
+
+ time_sink_f::sptr time_sink_f::make(int size, double bw,
+ const std::string &name,
+ int nconnections,
+ QWidget *parent)
+ {
+ return gnuradio::get_initial_sptr
+ (new time_sink_f_impl(size, bw, name, nconnections, parent));
+ }
+
+ time_sink_f_impl::time_sink_f_impl(int size, double bw,
+ const std::string &name,
+ int nconnections,
+ QWidget *parent)
+ : gr_sync_block("time_sink_f",
+ gr_make_io_signature(nconnections, nconnections, sizeof(float)),
+ gr_make_io_signature(0, 0, 0)),
+ d_size(size), d_bandwidth(bw), d_name(name),
+ d_nconnections(nconnections), d_parent(parent)
+ {
+ d_main_gui = NULL;
+
+ d_index = 0;
+
+ for(int i = 0; i < d_nconnections; i++) {
+ d_residbufs.push_back(gr::fft::malloc_double(d_size));
+ }
+
+ // Set alignment properties for VOLK
+ const int alignment_multiple =
+ volk_get_alignment() / sizeof(gr_complex);
+ set_alignment(std::max(1,alignment_multiple));
+
+ initialize();
+ }
+
+ time_sink_f_impl::~time_sink_f_impl()
+ {
+ // d_main_gui is a qwidget destroyed with its parent
+ for(int i = 0; i < d_nconnections; i++) {
+ gr::fft::free(d_residbufs[i]);
+ }
+ }
+
+ void
+ time_sink_f_impl::initialize()
+ {
+ if(qApp != NULL) {
+ d_qApplication = qApp;
+ }
+ else {
+ int argc=0;
+ char **argv = NULL;
+ d_qApplication = new QApplication(argc, argv);
+ }
+
+ d_main_gui = new TimeDisplayForm(d_nconnections, d_parent);
+
+ // initialize update time to 10 times a second
+ set_update_time(0.1);
+ d_last_time = 0;
+ }
+
+ void
+ time_sink_f_impl::exec_()
+ {
+ d_qApplication->exec();
+ }
+
+ QWidget*
+ time_sink_f_impl::qwidget()
+ {
+ return d_main_gui;
+ }
+
+ PyObject*
+ time_sink_f_impl::pyqwidget()
+ {
+ PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui);
+ PyObject *retarg = Py_BuildValue("N", w);
+ return retarg;
+ }
+
+ void
+ time_sink_f_impl::set_time_domain_axis(double min, double max)
+ {
+ d_main_gui->setTimeDomainAxis(min, max);
+ }
+
+ void
+ time_sink_f_impl::set_update_time(double t)
+ {
+ //convert update time to ticks
+ gruel::high_res_timer_type tps = gruel::high_res_timer_tps();
+ d_update_time = t * tps;
+ d_main_gui->setUpdateTime(t);
+ }
+
+ void
+ time_sink_f_impl::set_title(int which, const std::string &title)
+ {
+ d_main_gui->setTitle(which, title.c_str());
+ }
+
+ void
+ time_sink_f_impl::set_color(int which, const std::string &color)
+ {
+ d_main_gui->setColor(which, color.c_str());
+ }
+
+ void
+ time_sink_f_impl::set_line_width(int which, int width)
+ {
+ d_main_gui->setLineWidth(which, width);
+ }
+
+ void
+ time_sink_f_impl::set_line_style(int which, Qt::PenStyle style)
+ {
+ d_main_gui->setLineStyle(which, style);
+ }
+
+ void
+ time_sink_f_impl::set_line_marker(int which, QwtSymbol::Style marker)
+ {
+ d_main_gui->setLineMarker(which, marker);
+ }
+
+ void
+ time_sink_f_impl::set_size(int width, int height)
+ {
+ d_main_gui->resize(QSize(width, height));
+ }
+
+ int
+ time_sink_f_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ int n=0, j=0, idx=0;
+ const float *in = (const float*)input_items[idx];
+
+ for(int i=0; i < noutput_items; i+=d_size) {
+ unsigned int datasize = noutput_items - i;
+ unsigned int resid = d_size-d_index;
+ idx = 0;
+
+ // If we have enough input for one full plot, do it
+ if(datasize >= resid) {
+
+ // Fill up residbufs with d_size number of items
+ for(n = 0; n < d_nconnections; n++) {
+ in = (const float*)input_items[idx++];
+ if(is_unaligned()) {
+ volk_32f_convert_64f_u(&d_residbufs[n][d_index],
+ &in[j], resid);
+ }
+ else {
+ volk_32f_convert_64f_a(&d_residbufs[n][d_index],
+ &in[j], resid);
+ }
+ }
+
+ // Update the plot if its time
+ if(gruel::high_res_timer_now() - d_last_time > d_update_time) {
+ d_last_time = gruel::high_res_timer_now();
+ d_qApplication->postEvent(d_main_gui,
+ new TimeUpdateEvent(d_residbufs, d_size));
+ }
+
+ d_index = 0;
+ j += resid;
+ }
+ // Otherwise, copy what we received into the residbufs for next time
+ // because we set the output_multiple, this should never need to be called
+ else {
+ for(n = 0; n < d_nconnections; n++) {
+ in = (const float*)input_items[idx++];
+ if(is_unaligned()) {
+ volk_32f_convert_64f_u(&d_residbufs[n][d_index],
+ &in[j], datasize);
+ }
+ else {
+ volk_32f_convert_64f_a(&d_residbufs[n][d_index],
+ &in[j], datasize);
+ }
+ }
+ d_index += datasize;
+ j += datasize;
+ }
+ }
+
+ return noutput_items;
+ }
+
+ } /* namespace qtgui */
+} /* namespace gr */
diff --git a/gr-qtgui/lib/time_sink_f_impl.h b/gr-qtgui/lib/time_sink_f_impl.h
new file mode 100644
index 0000000000..65dd3645db
--- /dev/null
+++ b/gr-qtgui/lib/time_sink_f_impl.h
@@ -0,0 +1,82 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2011,2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_QTGUI_TIME_SINK_F_IMPL_H
+#define INCLUDED_QTGUI_TIME_SINK_F_IMPL_H
+
+#include <qtgui/time_sink_f.h>
+#include <fft/fft.h>
+#include <timedisplayform.h>
+#include <gruel/high_res_timer.h>
+
+namespace gr {
+ namespace qtgui {
+
+ class QTGUI_API time_sink_f_impl : public time_sink_f
+ {
+ private:
+ void initialize();
+
+ int d_size;
+ double d_bandwidth;
+ std::string d_name;
+ int d_nconnections;
+
+ int d_index;
+ std::vector<double*> d_residbufs;
+
+ QWidget *d_parent;
+ TimeDisplayForm *d_main_gui;
+
+ gruel::high_res_timer_type d_update_time;
+ gruel::high_res_timer_type d_last_time;
+
+ public:
+ time_sink_f_impl(int size, double bw,
+ const std::string &name,
+ int nconnections,
+ QWidget *parent=NULL);
+ ~time_sink_f_impl();
+
+ void exec_();
+ QWidget* qwidget();
+ PyObject* pyqwidget();
+
+ void set_time_domain_axis(double min, double max);
+ void set_update_time(double t);
+ void set_title(int which, const std::string &title);
+ void set_color(int which, const std::string &color);
+ void set_line_width(int which, int width);
+ void set_line_style(int which, Qt::PenStyle style);
+ void set_line_marker(int which, QwtSymbol::Style marker);
+
+ void set_size(int width, int height);
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace qtgui */
+} /* namespace gr */
+
+#endif /* INCLUDED_QTGUI_TIME_SINK_F_IMPL_H */
diff --git a/gr-qtgui/lib/waterfall_sink_c_impl.cc b/gr-qtgui/lib/waterfall_sink_c_impl.cc
new file mode 100644
index 0000000000..fa2e028783
--- /dev/null
+++ b/gr-qtgui/lib/waterfall_sink_c_impl.cc
@@ -0,0 +1,354 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "waterfall_sink_c_impl.h"
+#include <gr_io_signature.h>
+#include <string.h>
+#include <volk/volk.h>
+
+namespace gr {
+ namespace qtgui {
+
+ waterfall_sink_c::sptr
+ waterfall_sink_c::make(int fftsize, int wintype,
+ double fc, double bw,
+ const std::string &name,
+ int nconnections,
+ QWidget *parent)
+ {
+ return gnuradio::get_initial_sptr
+ (new waterfall_sink_c_impl(fftsize, wintype,
+ fc, bw, name,
+ nconnections,
+ parent));
+ }
+
+ waterfall_sink_c_impl::waterfall_sink_c_impl(int fftsize, int wintype,
+ double fc, double bw,
+ const std::string &name,
+ int nconnections,
+ QWidget *parent)
+ : gr_sync_block("waterfall_sink_c",
+ gr_make_io_signature(1, -1, sizeof(gr_complex)),
+ gr_make_io_signature(0, 0, 0)),
+ d_fftsize(fftsize), d_fftavg(1.0),
+ d_wintype((filter::firdes::win_type)(wintype)),
+ d_center_freq(fc), d_bandwidth(bw), d_name(name),
+ d_nconnections(nconnections), d_parent(parent)
+ {
+ d_main_gui = NULL;
+
+ // Perform fftshift operation;
+ // this is usually desired when plotting
+ d_shift = true;
+
+ d_fft = new gr::fft::fft_complex(d_fftsize, true);
+
+ d_index = 0;
+ for(int i = 0; i < d_nconnections; i++) {
+ d_residbufs.push_back(gr::fft::malloc_complex(d_fftsize));
+ d_magbufs.push_back(gr::fft::malloc_double(d_fftsize));
+ }
+
+ buildwindow();
+
+ initialize();
+ }
+
+ waterfall_sink_c_impl::~waterfall_sink_c_impl()
+ {
+ for(int i = 0; i < d_nconnections; i++) {
+ gr::fft::free(d_residbufs[i]);
+ gr::fft::free(d_magbufs[i]);
+ }
+ delete d_fft;
+ }
+
+ void
+ waterfall_sink_c_impl::forecast(int noutput_items, gr_vector_int &ninput_items_required)
+ {
+ unsigned int ninputs = ninput_items_required.size();
+ for (unsigned int i = 0; i < ninputs; i++) {
+ ninput_items_required[i] = std::min(d_fftsize, 8191);
+ }
+ }
+
+ void
+ waterfall_sink_c_impl::initialize()
+ {
+ if(qApp != NULL) {
+ d_qApplication = qApp;
+ }
+ else {
+ int argc=0;
+ char **argv = NULL;
+ d_qApplication = new QApplication(argc, argv);
+ }
+
+ d_main_gui = new WaterfallDisplayForm(d_nconnections, d_parent);
+ d_main_gui->SetFFTSize(d_fftsize);
+ d_main_gui->SetFFTWindowType(d_wintype);
+ d_main_gui->SetFrequencyRange(d_center_freq,
+ d_center_freq - d_bandwidth/2.0,
+ d_center_freq + d_bandwidth/2.0);
+
+ // initialize update time to 10 times a second
+ set_update_time(0.1);
+ d_last_time = 0;
+ }
+
+ void
+ waterfall_sink_c_impl::exec_()
+ {
+ d_qApplication->exec();
+ }
+
+ QWidget*
+ waterfall_sink_c_impl::qwidget()
+ {
+ return d_main_gui;
+ }
+
+ PyObject*
+ waterfall_sink_c_impl::pyqwidget()
+ {
+ PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui);
+ PyObject *retarg = Py_BuildValue("N", w);
+ return retarg;
+ }
+
+ void
+ waterfall_sink_c_impl::set_fft_size(const int fftsize)
+ {
+ d_fftsize = fftsize;
+ d_main_gui->SetFFTSize(fftsize);
+ }
+
+ int
+ waterfall_sink_c_impl::fft_size() const
+ {
+ return d_fftsize;
+ }
+
+ void
+ waterfall_sink_c_impl::set_fft_average(const float fftavg)
+ {
+ d_fftavg = fftavg;
+ d_main_gui->SetFFTAverage(fftavg);
+ }
+
+ float
+ waterfall_sink_c_impl::fft_average() const
+ {
+ return d_fftavg;
+ }
+
+ void
+ waterfall_sink_c_impl::set_frequency_range(const double centerfreq,
+ const double bandwidth)
+ {
+ d_center_freq = centerfreq;
+ d_bandwidth = bandwidth;
+ d_main_gui->SetFrequencyRange(d_center_freq,
+ -d_bandwidth/2.0,
+ d_bandwidth/2.0);
+ }
+
+ void
+ waterfall_sink_c_impl::set_update_time(double t)
+ {
+ //convert update time to ticks
+ gruel::high_res_timer_type tps = gruel::high_res_timer_tps();
+ d_update_time = t * tps;
+ d_main_gui->setUpdateTime(t);
+ }
+
+ void
+ waterfall_sink_c_impl::set_title(int which, const std::string &title)
+ {
+ d_main_gui->setTitle(which, title.c_str());
+ }
+
+ void
+ waterfall_sink_c_impl::set_color(int which, const std::string &color)
+ {
+ d_main_gui->setColor(which, color.c_str());
+ }
+
+ void
+ waterfall_sink_c_impl::set_line_width(int which, int width)
+ {
+ d_main_gui->setLineWidth(which, width);
+ }
+
+ void
+ waterfall_sink_c_impl::set_line_style(int which, Qt::PenStyle style)
+ {
+ d_main_gui->setLineStyle(which, style);
+ }
+
+ void
+ waterfall_sink_c_impl::set_line_marker(int which, QwtSymbol::Style marker)
+ {
+ d_main_gui->setLineMarker(which, marker);
+ }
+
+ void
+ waterfall_sink_c_impl::set_size(int width, int height)
+ {
+ d_main_gui->resize(QSize(width, height));
+ }
+
+ void
+ waterfall_sink_c_impl::fft(float *data_out, const gr_complex *data_in, int size)
+ {
+ if(d_window.size()) {
+ volk_32fc_32f_multiply_32fc_a(d_fft->get_inbuf(), data_in, &d_window.front(), size);
+ }
+ else {
+ memcpy(d_fft->get_inbuf(), data_in, sizeof(gr_complex)*size);
+ }
+
+ d_fft->execute(); // compute the fft
+
+ volk_32fc_s32f_x2_power_spectral_density_32f_a(data_out, d_fft->get_outbuf(), size, 1.0, size);
+
+ // Perform shift operation
+ unsigned int len = (unsigned int)(floor(size/2.0));
+ float *tmp = (float*)malloc(sizeof(float)*len);
+ memcpy(tmp, &data_out[0], sizeof(float)*len);
+ memcpy(&data_out[0], &data_out[len], sizeof(float)*(size - len));
+ memcpy(&data_out[size - len], tmp, sizeof(float)*len);
+ free(tmp);
+ }
+
+ void
+ waterfall_sink_c_impl::windowreset()
+ {
+ filter::firdes::win_type newwintype;
+ newwintype = d_main_gui->GetFFTWindowType();
+ if(d_wintype != newwintype) {
+ d_wintype = newwintype;
+ buildwindow();
+ }
+ }
+
+ void
+ waterfall_sink_c_impl::buildwindow()
+ {
+ d_window.clear();
+ if(d_wintype != 0) {
+ d_window = filter::firdes::window(d_wintype, d_fftsize, 6.76);
+ }
+ }
+
+ void
+ waterfall_sink_c_impl::fftresize()
+ {
+ int newfftsize = d_main_gui->GetFFTSize();
+
+ if(newfftsize != d_fftsize) {
+
+ // Resize residbuf and replace data
+ for(int i = 0; i < d_nconnections; i++) {
+ gr::fft::free(d_residbufs[i]);
+ gr::fft::free(d_magbufs[i]);
+
+ d_residbufs[i] = gr::fft::malloc_complex(newfftsize);
+ d_magbufs[i] = gr::fft::malloc_double(newfftsize);
+ }
+
+ // Set new fft size and reset buffer index
+ // (throws away any currently held data, but who cares?)
+ d_fftsize = newfftsize;
+ d_index = 0;
+
+ // Reset window to reflect new size
+ buildwindow();
+
+ // Reset FFTW plan for new size
+ delete d_fft;
+ d_fft = new gr::fft::fft_complex(d_fftsize, true);
+ }
+ }
+
+ int
+ waterfall_sink_c_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ int j=0;
+ const gr_complex *in = (const gr_complex*)input_items[0];
+
+ // Update the FFT size from the application
+ fftresize();
+ windowreset();
+
+ for(int i=0; i < noutput_items; i+=d_fftsize) {
+ unsigned int datasize = noutput_items - i;
+ unsigned int resid = d_fftsize-d_index;
+
+ // If we have enough input for one full FFT, do it
+ if(datasize >= resid) {
+
+ float *fbuf = gr::fft::malloc_float(d_fftsize);
+ for(int n = 0; n < d_nconnections; n++) {
+ // Fill up residbuf with d_fftsize number of items
+ in = (const gr_complex*)input_items[n];
+ memcpy(d_residbufs[n]+d_index, &in[j], sizeof(gr_complex)*resid);
+
+ fft(fbuf, d_residbufs[n], d_fftsize);
+ volk_32f_convert_64f_a(d_magbufs[n], fbuf, d_fftsize);
+ }
+ gr::fft::free(fbuf);
+
+ if(gruel::high_res_timer_now() - d_last_time > d_update_time) {
+ d_last_time = gruel::high_res_timer_now();
+ d_qApplication->postEvent(d_main_gui,
+ new WaterfallUpdateEvent(d_magbufs,
+ d_fftsize,
+ d_last_time));
+ }
+
+ d_index = 0;
+ j += resid;
+ }
+ // Otherwise, copy what we received into the residbuf for next time
+ else {
+ for(int n = 0; n < d_nconnections; n++) {
+ in = (const gr_complex*)input_items[n];
+ memcpy(d_residbufs[n]+d_index, &in[j], sizeof(gr_complex)*datasize);
+ }
+ d_index += datasize;
+ j += datasize;
+ }
+ }
+
+ return noutput_items;
+ }
+
+ } /* namespace qtgui */
+} /* namespace gr */
diff --git a/gr-qtgui/lib/waterfall_sink_c_impl.h b/gr-qtgui/lib/waterfall_sink_c_impl.h
new file mode 100644
index 0000000000..9b7a3bcd6a
--- /dev/null
+++ b/gr-qtgui/lib/waterfall_sink_c_impl.h
@@ -0,0 +1,106 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_QTGUI_WATERFALL_SINK_C_IMPL_H
+#define INCLUDED_QTGUI_WATERFALL_SINK_C_IMPL_H
+
+#include <qtgui/waterfall_sink_c.h>
+#include <filter/firdes.h>
+#include <fft/fft.h>
+#include <gruel/high_res_timer.h>
+#include <gruel/thread.h>
+#include <waterfalldisplayform.h>
+
+namespace gr {
+ namespace qtgui {
+
+ class QTGUI_API waterfall_sink_c_impl : public waterfall_sink_c
+ {
+ private:
+ void forecast(int noutput_items, gr_vector_int &ninput_items_required);
+
+ void initialize();
+
+ int d_fftsize;
+ float d_fftavg;
+ filter::firdes::win_type d_wintype;
+ std::vector<float> d_window;
+ double d_center_freq;
+ double d_bandwidth;
+ std::string d_name;
+ int d_nconnections;
+
+ bool d_shift;
+ gr::fft::fft_complex *d_fft;
+
+ int d_index;
+ std::vector<gr_complex*> d_residbufs;
+ std::vector<double*> d_magbufs;
+
+ QWidget *d_parent;
+ WaterfallDisplayForm *d_main_gui;
+
+ gruel::high_res_timer_type d_update_time;
+ gruel::high_res_timer_type d_last_time;
+
+ void windowreset();
+ void buildwindow();
+ void fftresize();
+ void fft(float *data_out, const gr_complex *data_in, int size);
+
+ public:
+ waterfall_sink_c_impl(int size, int wintype,
+ double fc, double bw,
+ const std::string &name,
+ int nconnections,
+ QWidget *parent=NULL);
+ ~waterfall_sink_c_impl();
+
+ void exec_();
+ QWidget* qwidget();
+ PyObject* pyqwidget();
+
+ void set_fft_size(const int fftsize);
+ int fft_size() const;
+ void set_fft_average(const float fftavg);
+ float fft_average() const;
+
+ void set_frequency_range(const double centerfreq, const double bandwidth);
+
+ void set_update_time(double t);
+ void set_title(int which, const std::string &title);
+ void set_color(int which, const std::string &color);
+ void set_line_width(int which, int width);
+ void set_line_style(int which, Qt::PenStyle style);
+ void set_line_marker(int which, QwtSymbol::Style marker);
+
+ void set_size(int width, int height);
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace qtgui */
+} /* namespace gr */
+
+#endif /* INCLUDED_QTGUI_WATERFALL_SINK_C_IMPL_H */
diff --git a/gr-qtgui/lib/waterfall_sink_f_impl.cc b/gr-qtgui/lib/waterfall_sink_f_impl.cc
new file mode 100644
index 0000000000..8cf4d0615f
--- /dev/null
+++ b/gr-qtgui/lib/waterfall_sink_f_impl.cc
@@ -0,0 +1,350 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "waterfall_sink_f_impl.h"
+#include <gr_io_signature.h>
+#include <string.h>
+#include <volk/volk.h>
+
+namespace gr {
+ namespace qtgui {
+
+ waterfall_sink_f::sptr
+ waterfall_sink_f::make(int fftsize, int wintype,
+ double fc, double bw,
+ const std::string &name,
+ int nconnections,
+ QWidget *parent)
+ {
+ return gnuradio::get_initial_sptr
+ (new waterfall_sink_f_impl(fftsize, wintype,
+ fc, bw, name,
+ nconnections,
+ parent));
+ }
+
+ waterfall_sink_f_impl::waterfall_sink_f_impl(int fftsize, int wintype,
+ double fc, double bw,
+ const std::string &name,
+ int nconnections,
+ QWidget *parent)
+ : gr_sync_block("waterfall_sink_f",
+ gr_make_io_signature(1, -1, sizeof(float)),
+ gr_make_io_signature(0, 0, 0)),
+ d_fftsize(fftsize), d_fftavg(1.0),
+ d_wintype((filter::firdes::win_type)(wintype)),
+ d_center_freq(fc), d_bandwidth(bw), d_name(name),
+ d_nconnections(nconnections), d_parent(parent)
+ {
+ d_main_gui = NULL;
+
+ // Perform fftshift operation;
+ // this is usually desired when plotting
+ d_shift = true;
+
+ d_fft = new gr::fft::fft_complex(d_fftsize, true);
+
+ d_index = 0;
+ for(int i = 0; i < d_nconnections; i++) {
+ d_residbufs.push_back(gr::fft::malloc_float(d_fftsize));
+ d_magbufs.push_back(gr::fft::malloc_double(d_fftsize));
+ }
+
+ buildwindow();
+
+ initialize();
+ }
+
+ waterfall_sink_f_impl::~waterfall_sink_f_impl()
+ {
+ for(int i = 0; i < d_nconnections; i++) {
+ gr::fft::free(d_residbufs[i]);
+ gr::fft::free(d_magbufs[i]);
+ }
+ delete d_fft;
+ }
+
+ void
+ waterfall_sink_f_impl::forecast(int noutput_items, gr_vector_int &ninput_items_required)
+ {
+ unsigned int ninputs = ninput_items_required.size();
+ for (unsigned int i = 0; i < ninputs; i++) {
+ ninput_items_required[i] = std::min(d_fftsize, 8191);
+ }
+ }
+
+ void
+ waterfall_sink_f_impl::initialize()
+ {
+ if(qApp != NULL) {
+ d_qApplication = qApp;
+ }
+ else {
+ int argc=0;
+ char **argv = NULL;
+ d_qApplication = new QApplication(argc, argv);
+ }
+
+ d_main_gui = new WaterfallDisplayForm(d_nconnections, d_parent);
+ d_main_gui->SetFFTSize(d_fftsize);
+ d_main_gui->SetFFTWindowType(d_wintype);
+ d_main_gui->SetFrequencyRange(d_center_freq,
+ d_center_freq - d_bandwidth/2.0,
+ d_center_freq + d_bandwidth/2.0);
+
+ // initialize update time to 10 times a second
+ set_update_time(0.1);
+ d_last_time = 0;
+ }
+
+ void
+ waterfall_sink_f_impl::exec_()
+ {
+ d_qApplication->exec();
+ }
+
+ QWidget*
+ waterfall_sink_f_impl::qwidget()
+ {
+ return d_main_gui;
+ }
+
+ PyObject*
+ waterfall_sink_f_impl::pyqwidget()
+ {
+ PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui);
+ PyObject *retarg = Py_BuildValue("N", w);
+ return retarg;
+ }
+
+ void
+ waterfall_sink_f_impl::set_fft_size(const int fftsize)
+ {
+ d_fftsize = fftsize;
+ d_main_gui->SetFFTSize(fftsize);
+ }
+
+ int
+ waterfall_sink_f_impl::fft_size() const
+ {
+ return d_fftsize;
+ }
+
+ void
+ waterfall_sink_f_impl::set_fft_average(const float fftavg)
+ {
+ d_fftavg = fftavg;
+ d_main_gui->SetFFTAverage(fftavg);
+ }
+
+ float
+ waterfall_sink_f_impl::fft_average() const
+ {
+ return d_fftavg;
+ }
+
+ void
+ waterfall_sink_f_impl::set_frequency_range(const double centerfreq,
+ const double bandwidth)
+ {
+ d_center_freq = centerfreq;
+ d_bandwidth = bandwidth;
+ d_main_gui->SetFrequencyRange(d_center_freq,
+ -d_bandwidth/2.0,
+ d_bandwidth/2.0);
+ }
+
+ void
+ waterfall_sink_f_impl::set_update_time(double t)
+ {
+ //convert update time to ticks
+ gruel::high_res_timer_type tps = gruel::high_res_timer_tps();
+ d_update_time = t * tps;
+ d_main_gui->setUpdateTime(t);
+ }
+
+ void
+ waterfall_sink_f_impl::set_title(int which, const std::string &title)
+ {
+ d_main_gui->setTitle(which, title.c_str());
+ }
+
+ void
+ waterfall_sink_f_impl::set_color(int which, const std::string &color)
+ {
+ d_main_gui->setColor(which, color.c_str());
+ }
+
+ void
+ waterfall_sink_f_impl::set_line_width(int which, int width)
+ {
+ d_main_gui->setLineWidth(which, width);
+ }
+
+ void
+ waterfall_sink_f_impl::set_line_style(int which, Qt::PenStyle style)
+ {
+ d_main_gui->setLineStyle(which, style);
+ }
+
+ void
+ waterfall_sink_f_impl::set_line_marker(int which, QwtSymbol::Style marker)
+ {
+ d_main_gui->setLineMarker(which, marker);
+ }
+
+ void
+ waterfall_sink_f_impl::set_size(int width, int height)
+ {
+ d_main_gui->resize(QSize(width, height));
+ }
+
+ void
+ waterfall_sink_f_impl::fft(float *data_out, const float *data_in, int size)
+ {
+ // float to complex conversion
+ gr_complex *dst = d_fft->get_inbuf();
+ for (int i = 0; i < size; i++)
+ dst[i] = data_in[i];
+
+ if(d_window.size()) {
+ volk_32fc_32f_multiply_32fc_a(d_fft->get_inbuf(), dst,
+ &d_window.front(), size);
+ }
+
+ d_fft->execute(); // compute the fft
+
+ volk_32fc_s32f_x2_power_spectral_density_32f_a(data_out, d_fft->get_outbuf(),
+ size, 1.0, size);
+ }
+
+ void
+ waterfall_sink_f_impl::windowreset()
+ {
+ filter::firdes::win_type newwintype;
+ newwintype = d_main_gui->GetFFTWindowType();
+ if(d_wintype != newwintype) {
+ d_wintype = newwintype;
+ buildwindow();
+ }
+ }
+
+ void
+ waterfall_sink_f_impl::buildwindow()
+ {
+ d_window.clear();
+ if(d_wintype != 0) {
+ d_window = filter::firdes::window(d_wintype, d_fftsize, 6.76);
+ }
+ }
+
+ void
+ waterfall_sink_f_impl::fftresize()
+ {
+ int newfftsize = d_fftsize;
+
+ if(newfftsize != d_fftsize) {
+
+ // Resize residbuf and replace data
+ for(int i = 0; i < d_nconnections; i++) {
+ gr::fft::free(d_residbufs[i]);
+ gr::fft::free(d_magbufs[i]);
+
+ d_residbufs[i] = gr::fft::malloc_float(newfftsize);
+ d_magbufs[i] = gr::fft::malloc_double(newfftsize);
+ }
+
+ // Set new fft size and reset buffer index
+ // (throws away any currently held data, but who cares?)
+ d_fftsize = newfftsize;
+ d_index = 0;
+
+ // Reset window to reflect new size
+ buildwindow();
+
+ // Reset FFTW plan for new size
+ delete d_fft;
+ d_fft = new gr::fft::fft_complex(d_fftsize, true);
+ }
+ }
+
+ int
+ waterfall_sink_f_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ int j=0;
+ const float *in = (const float*)input_items[0];
+
+ // Update the FFT size from the application
+ fftresize();
+ windowreset();
+
+ for(int i=0; i < noutput_items; i+=d_fftsize) {
+ unsigned int datasize = noutput_items - i;
+ unsigned int resid = d_fftsize-d_index;
+
+ // If we have enough input for one full FFT, do it
+ if(datasize >= resid) {
+
+ float *fbuf = gr::fft::malloc_float(d_fftsize);
+ for(int n = 0; n < d_nconnections; n++) {
+ // Fill up residbuf with d_fftsize number of items
+ in = (const float*)input_items[n];
+ memcpy(d_residbufs[n]+d_index, &in[j], sizeof(float)*resid);
+
+ fft(fbuf, d_residbufs[n], d_fftsize);
+ volk_32f_convert_64f_a(d_magbufs[n], fbuf, d_fftsize);
+ }
+ gr::fft::free(fbuf);
+
+ if(gruel::high_res_timer_now() - d_last_time > d_update_time) {
+ d_last_time = gruel::high_res_timer_now();
+ d_qApplication->postEvent(d_main_gui,
+ new WaterfallUpdateEvent(d_magbufs,
+ d_fftsize,
+ d_last_time));
+ }
+
+ d_index = 0;
+ j += resid;
+ }
+ // Otherwise, copy what we received into the residbuf for next time
+ else {
+ for(int n = 0; n < d_nconnections; n++) {
+ in = (const float*)input_items[n];
+ memcpy(d_residbufs[n]+d_index, &in[j], sizeof(float)*datasize);
+ }
+ d_index += datasize;
+ j += datasize;
+ }
+ }
+
+ return noutput_items;
+ }
+
+ } /* namespace qtgui */
+} /* namespace gr */
diff --git a/gr-qtgui/lib/waterfall_sink_f_impl.h b/gr-qtgui/lib/waterfall_sink_f_impl.h
new file mode 100644
index 0000000000..789a5a8ca3
--- /dev/null
+++ b/gr-qtgui/lib/waterfall_sink_f_impl.h
@@ -0,0 +1,107 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_QTGUI_WATERFALL_SINK_F_IMPL_H
+#define INCLUDED_QTGUI_WATERFALL_SINK_F_IMPL_H
+
+
+#include <qtgui/waterfall_sink_f.h>
+#include <filter/firdes.h>
+#include <fft/fft.h>
+#include <gruel/high_res_timer.h>
+#include <gruel/thread.h>
+#include <waterfalldisplayform.h>
+
+namespace gr {
+ namespace qtgui {
+
+ class QTGUI_API waterfall_sink_f_impl : public waterfall_sink_f
+ {
+ private:
+ void forecast(int noutput_items, gr_vector_int &ninput_items_required);
+
+ void initialize();
+
+ int d_fftsize;
+ float d_fftavg;
+ filter::firdes::win_type d_wintype;
+ std::vector<float> d_window;
+ double d_center_freq;
+ double d_bandwidth;
+ std::string d_name;
+ int d_nconnections;
+
+ bool d_shift;
+ gr::fft::fft_complex *d_fft;
+
+ int d_index;
+ std::vector<float*> d_residbufs;
+ std::vector<double*> d_magbufs;
+
+ QWidget *d_parent;
+ WaterfallDisplayForm *d_main_gui;
+
+ gruel::high_res_timer_type d_update_time;
+ gruel::high_res_timer_type d_last_time;
+
+ void windowreset();
+ void buildwindow();
+ void fftresize();
+ void fft(float *data_out, const float *data_in, int size);
+
+ public:
+ waterfall_sink_f_impl(int size, int wintype,
+ double fc, double bw,
+ const std::string &name,
+ int nconnections,
+ QWidget *parent=NULL);
+ ~waterfall_sink_f_impl();
+
+ void exec_();
+ QWidget* qwidget();
+ PyObject* pyqwidget();
+
+ void set_fft_size(const int fftsize);
+ int fft_size() const;
+ void set_fft_average(const float fftavg);
+ float fft_average() const;
+
+ void set_frequency_range(const double centerfreq, const double bandwidth);
+
+ void set_update_time(double t);
+ void set_title(int which, const std::string &title);
+ void set_color(int which, const std::string &color);
+ void set_line_width(int which, int width);
+ void set_line_style(int which, Qt::PenStyle style);
+ void set_line_marker(int which, QwtSymbol::Style marker);
+
+ void set_size(int width, int height);
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace qtgui */
+} /* namespace gr */
+
+#endif /* INCLUDED_QTGUI_WATERFALL_SINK_F_IMPL_H */
diff --git a/gr-qtgui/lib/waterfalldisplayform.cc b/gr-qtgui/lib/waterfalldisplayform.cc
index a436ed7db4..c2721a9fa1 100644
--- a/gr-qtgui/lib/waterfalldisplayform.cc
+++ b/gr-qtgui/lib/waterfalldisplayform.cc
@@ -101,6 +101,12 @@ WaterfallDisplayForm::GetFFTAverage() const
return _fftavg;
}
+gr::filter::firdes::win_type
+WaterfallDisplayForm::GetFFTWindowType() const
+{
+ return _fftwintype;
+}
+
void
WaterfallDisplayForm::SetFFTSize(const int newsize)
{
@@ -114,6 +120,12 @@ WaterfallDisplayForm::SetFFTAverage(const float newavg)
}
void
+WaterfallDisplayForm::SetFFTWindowType(const gr::filter::firdes::win_type newwin)
+{
+ _fftwintype = newwin;
+}
+
+void
WaterfallDisplayForm::SetFrequencyRange(const double newCenterFrequency,
const double newStartFrequency,
const double newStopFrequency)
diff --git a/gr-qtgui/lib/waterfalldisplayform.h b/gr-qtgui/lib/waterfalldisplayform.h
index 04c9a8088c..0235ddeeeb 100644
--- a/gr-qtgui/lib/waterfalldisplayform.h
+++ b/gr-qtgui/lib/waterfalldisplayform.h
@@ -27,6 +27,7 @@
#include <WaterfallDisplayPlot.h>
#include <QtGui/QtGui>
#include <vector>
+#include <filter/firdes.h>
#include "displayform.h"
@@ -42,12 +43,14 @@ class WaterfallDisplayForm : public DisplayForm
int GetFFTSize() const;
float GetFFTAverage() const;
+ gr::filter::firdes::win_type GetFFTWindowType() const;
public slots:
void customEvent(QEvent *e);
void SetFFTSize(const int);
void SetFFTAverage(const float);
+ void SetFFTWindowType(const gr::filter::firdes::win_type);
void SetFrequencyRange(const double newCenterFrequency,
const double newStartFrequency,
@@ -68,6 +71,7 @@ private:
int _fftsize;
float _fftavg;
+ gr::filter::firdes::win_type _fftwintype;
};
#endif /* WATERFALL_DISPLAY_FORM_H */