diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0dbc5f5..51f03d2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -120,7 +120,7 @@ endif (QT_FOUND)
########################################################################
# Find gnuradio build dependencies
########################################################################
-set(GR_REQUIRED_COMPONENTS RUNTIME)
+set(GR_REQUIRED_COMPONENTS RUNTIME FFT)
find_package(Gnuradio 3.7 REQUIRED)
find_package(CppUnit)
diff --git a/grc/fosphor_glfw_sink_c.xml b/grc/fosphor_glfw_sink_c.xml
index e428f1e..037d59d 100644
--- a/grc/fosphor_glfw_sink_c.xml
+++ b/grc/fosphor_glfw_sink_c.xml
@@ -4,10 +4,44 @@
fosphor_glfw_sink_c
Instrumentation
from gnuradio import fosphor
+ from gnuradio.fft import window
fosphor.glfw_sink_c()
+self.$(id).set_fft_window($wintype)
self.$(id).set_frequency_range($freq_center, $freq_span)
+ set_fft_window($wintype)
set_frequency_range($freq_center, $freq_span)
+
+ Window Type
+ wintype
+ window.WIN_BLACKMAN_hARRIS
+ int
+ part
+
+
+
+
+
+
+
Center Frequency (Hz)
freq_center
diff --git a/grc/fosphor_qt_sink_c.xml b/grc/fosphor_qt_sink_c.xml
index 854bc48..39c15ad 100644
--- a/grc/fosphor_qt_sink_c.xml
+++ b/grc/fosphor_qt_sink_c.xml
@@ -6,12 +6,46 @@
from PyQt4 import Qt
import sip
from gnuradio import fosphor
+ from gnuradio.fft import window
#set $win = 'self._%s_win'%$id
fosphor.qt_sink_c()
+self.$(id).set_fft_window($wintype)
self.$(id).set_frequency_range($freq_center, $freq_span)
self._$(id)_win = sip.wrapinstance(self.$(id).pyqwidget(), Qt.QWidget)
$(gui_hint()($win))
+ set_fft_window($wintype)
set_frequency_range($freq_center, $freq_span)
+
+ Window Type
+ wintype
+ window.WIN_BLACKMAN_hARRIS
+ int
+ part
+
+
+
+
+
+
+
Center Frequency (Hz)
freq_center
diff --git a/grc/fosphor_wx_sink_c.xml b/grc/fosphor_wx_sink_c.xml
index 3b90fda..a752726 100644
--- a/grc/fosphor_wx_sink_c.xml
+++ b/grc/fosphor_wx_sink_c.xml
@@ -4,6 +4,7 @@
fosphor_wx_sink_c
Instrumentation/WX
from gnuradio import fosphor
+ from gnuradio.fft import window
#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self'
fosphor.wx_sink_c(
$(parent).GetWin()
@@ -11,13 +12,46 @@ fosphor.wx_sink_c(
size=$win_size,
#end if
)
+self.$(id).set_fft_window($wintype)
self.$(id).set_frequency_range($freq_center, $freq_span)
#if not $grid_pos()
$(parent).Add(self.$(id).win)
#else
$(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos()))))
#end if
+ set_fft_window($wintype)
set_frequency_range($freq_center, $freq_span)
+
+ Window Type
+ wintype
+ window.WIN_BLACKMAN_hARRIS
+ int
+ part
+
+
+
+
+
+
+
Center Frequency (Hz)
freq_center
diff --git a/include/gnuradio/fosphor/base_sink_c.h b/include/gnuradio/fosphor/base_sink_c.h
index 31e62f0..89a15b1 100644
--- a/include/gnuradio/fosphor/base_sink_c.h
+++ b/include/gnuradio/fosphor/base_sink_c.h
@@ -25,6 +25,7 @@
#include
#include
+#include
namespace gr {
namespace fosphor {
@@ -53,6 +54,8 @@ namespace gr {
const double span) = 0;
virtual void set_frequency_center(const double center) = 0;
virtual void set_frequency_span(const double span) = 0;
+
+ virtual void set_fft_window(const gr::fft::window::win_type win) = 0;
};
} // namespace fosphor
diff --git a/lib/base_sink_c_impl.cc b/lib/base_sink_c_impl.cc
index 786e249..238823a 100644
--- a/lib/base_sink_c_impl.cc
+++ b/lib/base_sink_c_impl.cc
@@ -54,7 +54,7 @@ const int base_sink_c_impl::k_db_per_div[] = {1, 2, 5, 10, 20};
base_sink_c_impl::base_sink_c_impl()
: d_db_ref(0), d_db_per_div_idx(3), d_active(false),
- d_frequency()
+ d_frequency(), d_fft_window(gr::fft::window::WIN_BLACKMAN_hARRIS)
{
/* Init FIFO */
this->d_fifo = new fifo(2 * 1024 * 1024);
@@ -198,6 +198,12 @@ base_sink_c_impl::settings_apply(uint32_t settings)
this->d_frequency.span
);
}
+
+ if (settings & SETTING_FFT_WINDOW) {
+ std::vector window =
+ gr::fft::window::build(this->d_fft_window, 1024, 6.76);
+ fosphor_set_fft_window(this->d_fosphor, window.data());
+ }
}
@@ -258,6 +264,16 @@ base_sink_c_impl::set_frequency_span(const double span)
this->settings_mark_changed(SETTING_FREQUENCY_RANGE);
}
+void
+base_sink_c_impl::set_fft_window(const gr::fft::window::win_type win)
+{
+ if (win == this->d_fft_window) /* Reloading FFT window takes time */
+ return; /* avoid doing it if possible */
+
+ this->d_fft_window = win;
+ this->settings_mark_changed(SETTING_FFT_WINDOW);
+}
+
int
base_sink_c_impl::work(
diff --git a/lib/base_sink_c_impl.h b/lib/base_sink_c_impl.h
index ae9583b..45efa65 100644
--- a/lib/base_sink_c_impl.h
+++ b/lib/base_sink_c_impl.h
@@ -61,6 +61,7 @@ namespace gr {
SETTING_DIMENSIONS = (1 << 0),
SETTING_POWER_RANGE = (1 << 1),
SETTING_FREQUENCY_RANGE = (1 << 2),
+ SETTING_FFT_WINDOW = (1 << 3),
};
uint32_t d_settings_changed;
@@ -83,6 +84,8 @@ namespace gr {
double span;
} d_frequency;
+ gr::fft::window::win_type d_fft_window;
+
protected:
base_sink_c_impl();
@@ -106,6 +109,8 @@ namespace gr {
void set_frequency_center(const double center);
void set_frequency_span(const double span);
+ void set_fft_window(const gr::fft::window::win_type win);
+
/* gr::sync_block implementation */
int work (int noutput_items,
gr_vector_const_void_star &input_items,
diff --git a/swig/fosphor_swig.i b/swig/fosphor_swig.i
index f908756..064ab9b 100644
--- a/swig/fosphor_swig.i
+++ b/swig/fosphor_swig.i
@@ -13,6 +13,9 @@
#include "gnuradio/fosphor/wx_core_sink_c.h"
%}
+%typemap(in) gr::fft::window::win_type {
+ $1 = (gr::fft::window::win_type)(PyInt_AsLong($input));
+}
%include "gnuradio/fosphor/base_sink_c.h"