diff options
author | Sylvain Munaut <tnt@246tNt.com> | 2013-11-10 15:11:49 +0100 |
---|---|---|
committer | Sylvain Munaut <tnt@246tNt.com> | 2013-11-10 22:24:07 +0100 |
commit | fd3d6cf77d6b99538d012e4a53d47ebbf7822039 (patch) | |
tree | 6ff0a67f0aa6d875ead58fcd75319a8aaea3300e /lib | |
parent | ce907419c7e595a442bae5fe572c2697c905b1b0 (diff) |
gr-fosphor: Allow to select custom FFT window from the gr::fft:window list
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/base_sink_c_impl.cc | 18 | ||||
-rw-r--r-- | lib/base_sink_c_impl.h | 5 |
2 files changed, 22 insertions, 1 deletions
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<float> 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, |