summaryrefslogtreecommitdiff
path: root/gr-fft
diff options
context:
space:
mode:
authorMarcus Müller <marcus@hostalia.de>2018-08-31 23:02:22 +0200
committerMarcus Müller <marcus@hostalia.de>2018-08-31 23:02:22 +0200
commit254fe5e89403d4de1fa6663d09efdf946996aff3 (patch)
tree62877d7ac7fdedf6c397c51e22ac6f97eba97ddf /gr-fft
parent896d1c9da31963ecf5b0d90942c2af51ca998a69 (diff)
parent5ad935c3a3dd46ce2860b13e2b774e4841784616 (diff)
Merge remote-tracking branch 'origin/next' into merge_next
Diffstat (limited to 'gr-fft')
-rw-r--r--gr-fft/CMakeLists.txt35
-rw-r--r--gr-fft/grc/CMakeLists.txt11
-rw-r--r--gr-fft/grc/fft.tree.yml7
-rw-r--r--gr-fft/grc/fft_block_tree.xml41
-rw-r--r--gr-fft/grc/fft_ctrlport_probe_psd.block.yml31
-rw-r--r--gr-fft/grc/fft_ctrlport_probe_psd.xml63
-rw-r--r--gr-fft/grc/fft_fft_vxx.block.yml60
-rw-r--r--gr-fft/grc/fft_fft_vxx.xml88
-rw-r--r--gr-fft/grc/fft_goertzel_fc.block.yml30
-rw-r--r--gr-fft/grc/fft_goertzel_fc.xml37
-rw-r--r--gr-fft/grc/fft_logpwrfft_x.block.yml64
-rw-r--r--gr-fft/grc/fft_logpwrfft_x.xml90
-rw-r--r--gr-fft/include/gnuradio/fft/CMakeLists.txt3
-rw-r--r--gr-fft/lib/CMakeLists.txt4
-rw-r--r--gr-fft/lib/fft_vfc_fftw.cc2
-rw-r--r--gr-fft/lib/goertzel.cc7
-rw-r--r--gr-fft/lib/window.cc19
-rw-r--r--gr-fft/python/fft/CMakeLists.txt3
-rw-r--r--gr-fft/python/fft/__init__.py8
-rw-r--r--gr-fft/python/fft/logpwrfft.py13
-rw-r--r--[-rwxr-xr-x]gr-fft/python/fft/qa_fft.py2
-rw-r--r--[-rwxr-xr-x]gr-fft/python/fft/qa_goertzel.py40
-rw-r--r--gr-fft/swig/CMakeLists.txt2
23 files changed, 251 insertions, 409 deletions
diff --git a/gr-fft/CMakeLists.txt b/gr-fft/CMakeLists.txt
index 1eaff37672..992ca5ca86 100644
--- a/gr-fft/CMakeLists.txt
+++ b/gr-fft/CMakeLists.txt
@@ -48,40 +48,6 @@ GR_SET_GLOBAL(GR_FFT_INCLUDE_DIRS
if(ENABLE_GR_FFT)
########################################################################
-# Setup CPack components
-########################################################################
-include(GrPackage)
-CPACK_SET(CPACK_COMPONENT_GROUP_FFT_DESCRIPTION "GNU Radio FFT Blocks")
-
-CPACK_COMPONENT("fft_runtime"
- GROUP "FFT"
- DISPLAY_NAME "Runtime"
- DESCRIPTION "Runtime"
- DEPENDS "runtime_runtime"
-)
-
-CPACK_COMPONENT("fft_devel"
- GROUP "FFT"
- DISPLAY_NAME "Development"
- DESCRIPTION "C++ headers, package config, import libraries"
- DEPENDS "runtime_devel"
-)
-
-CPACK_COMPONENT("fft_python"
- GROUP "FFT"
- DISPLAY_NAME "Python"
- DESCRIPTION "Python modules for runtime; GRC xml files"
- DEPENDS "runtime_python;fft_runtime"
-)
-
-CPACK_COMPONENT("fft_swig"
- GROUP "FFT"
- DISPLAY_NAME "SWIG"
- DESCRIPTION "SWIG development .i files"
- DEPENDS "runtime_swig;fft_python;fft_devel"
-)
-
-########################################################################
# Add subdirectories
########################################################################
add_subdirectory(include/gnuradio/fft)
@@ -104,7 +70,6 @@ configure_file(
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-fft.pc
DESTINATION ${GR_LIBRARY_DIR}/pkgconfig
- COMPONENT "fft_devel"
)
endif(ENABLE_GR_FFT)
diff --git a/gr-fft/grc/CMakeLists.txt b/gr-fft/grc/CMakeLists.txt
index cc972dfa7e..d0432c4281 100644
--- a/gr-fft/grc/CMakeLists.txt
+++ b/gr-fft/grc/CMakeLists.txt
@@ -18,11 +18,10 @@
# Boston, MA 02110-1301, USA.
install(FILES
- fft_block_tree.xml
- fft_fft_vxx.xml
- fft_goertzel_fc.xml
- fft_logpwrfft_x.xml
- fft_ctrlport_probe_psd.xml
+ fft.tree.yml
+ fft_fft_vxx.block.yml
+ fft_goertzel_fc.block.yml
+ fft_logpwrfft_x.block.yml
+ fft_ctrlport_probe_psd.block.yml
DESTINATION ${GRC_BLOCKS_DIR}
- COMPONENT "fft_python"
)
diff --git a/gr-fft/grc/fft.tree.yml b/gr-fft/grc/fft.tree.yml
new file mode 100644
index 0000000000..c198bc4573
--- /dev/null
+++ b/gr-fft/grc/fft.tree.yml
@@ -0,0 +1,7 @@
+'[Core]':
+- Fourier Analysis:
+ - fft_vxx
+ - goertzel_fc
+ - logpwrfft_x
+- Control Port:
+ - fft_ctrlport_probe_psd
diff --git a/gr-fft/grc/fft_block_tree.xml b/gr-fft/grc/fft_block_tree.xml
deleted file mode 100644
index e844d837b4..0000000000
--- a/gr-fft/grc/fft_block_tree.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0"?>
-
-<!--
- 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.
--->
-
-<!--
-###################################################
-##Block Tree for GR FFT blocks.
-###################################################
- -->
-<cat>
- <name>[Core]</name> <!-- Blank for Root Name -->
- <cat>
- <name>Fourier Analysis</name>
- <block>fft_vxx</block>
- <block>goertzel_fc</block>
- <block>logpwrfft_x</block>
- </cat>
- <cat>
- <name>Control Port</name>
- <block>fft_ctrlport_probe_psd</block>
- </cat>
-</cat>
diff --git a/gr-fft/grc/fft_ctrlport_probe_psd.block.yml b/gr-fft/grc/fft_ctrlport_probe_psd.block.yml
new file mode 100644
index 0000000000..3349f42639
--- /dev/null
+++ b/gr-fft/grc/fft_ctrlport_probe_psd.block.yml
@@ -0,0 +1,31 @@
+id: fft_ctrlport_probe_psd
+label: Ctrlport Probe PSD
+
+parameters:
+- id: name
+ label: Name
+ dtype: string
+ default: psd
+- id: desc
+ label: Description
+ dtype: string
+ default: PSD Plot
+- id: len
+ label: Length
+ dtype: int
+ default: '1024'
+
+inputs:
+- domain: stream
+ dtype: complex
+
+templates:
+ imports: from gnuradio import fft
+ make: fft.ctrlport_probe_psd(${name}, ${desc}, ${len})
+ callbacks:
+ - set_length(${len})
+
+documentation: |-
+ Place this in a graph to export PSD values to a GRCP port probe.
+
+file_format: 1
diff --git a/gr-fft/grc/fft_ctrlport_probe_psd.xml b/gr-fft/grc/fft_ctrlport_probe_psd.xml
deleted file mode 100644
index f50144ba92..0000000000
--- a/gr-fft/grc/fft_ctrlport_probe_psd.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-<?xml version="1.0"?>
-
-<!--
- 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.
--->
-
-<block>
- <name>Ctrlport Probe PSD</name>
- <key>fft_ctrlport_probe_psd</key>
- <import>from gnuradio import fft</import>
- <make>fft.ctrlport_probe_psd($name, $desc, $len)</make>
- <callback>set_length($len)</callback>
-
- <param>
- <name>Name</name>
- <key>name</key>
- <value>psd</value>
- <type>string</type>
- </param>
-
- <param>
- <name>Description</name>
- <key>desc</key>
- <value>PSD Plot</value>
- <type>string</type>
- </param>
-
- <param>
- <name>Length</name>
- <key>len</key>
- <value>1024</value>
- <type>int</type>
- </param>
-
-
- <sink>
- <name>in</name>
- <type>complex</type>
- </sink>
-
- <doc>
- Place this in a graph to export PSD values to a GRCP port probe.
- </doc>
-
-</block>
-
diff --git a/gr-fft/grc/fft_fft_vxx.block.yml b/gr-fft/grc/fft_fft_vxx.block.yml
new file mode 100644
index 0000000000..33143f688a
--- /dev/null
+++ b/gr-fft/grc/fft_fft_vxx.block.yml
@@ -0,0 +1,60 @@
+id: fft_vxx
+label: FFT
+
+parameters:
+- id: type
+ label: Input Type
+ dtype: enum
+ options: [complex, float]
+ option_attributes:
+ hide_shift: ['', all]
+ hide: part
+- id: fft_size
+ label: FFT Size
+ dtype: int
+ default: '1024'
+ hide: ${ 'part' if vlen == 1 else 'none' }
+- id: forward
+ label: Forward/Reverse
+ dtype: enum
+ options: ['True', 'False']
+ option_labels: [Forward, Reverse]
+- id: window
+ label: Window
+ dtype: real_vector
+ default: window.blackmanharris(1024)
+- id: shift
+ label: Shift
+ dtype: enum
+ options: ['True', 'False']
+ option_labels: ['Yes', 'No']
+ hide: ${ type.hide_shift }
+- id: nthreads
+ label: Num. Threads
+ dtype: int
+ default: '1'
+
+inputs:
+- domain: stream
+ dtype: ${ type }
+ vlen: ${ fft_size }
+
+outputs:
+- domain: stream
+ dtype: complex
+ vlen: ${ fft_size }
+
+templates:
+ imports: |-
+ from gnuradio import fft
+ from gnuradio.fft import window
+ make: |-
+ % if type == "complex":
+ fft.fft_vcc(${fft_size}, ${forward}, ${window}, ${shift}, ${nthreads})
+ % else:
+ fft.fft_vfc(${fft_size}, ${forward}, ${window}, ${nthreads})
+ % endif
+ callbacks:
+ - set_nthreads(${nthreads})
+
+file_format: 1
diff --git a/gr-fft/grc/fft_fft_vxx.xml b/gr-fft/grc/fft_fft_vxx.xml
deleted file mode 100644
index 028721fe25..0000000000
--- a/gr-fft/grc/fft_fft_vxx.xml
+++ /dev/null
@@ -1,88 +0,0 @@
-<?xml version="1.0"?>
-<!--
-###################################################
-##FFT
-###################################################
- -->
-<block>
- <name>FFT</name>
- <key>fft_vxx</key>
- <import>from gnuradio import fft</import>
- <import>from gnuradio.fft import window</import>
- <make>#if $type() == "complex"
-fft.fft_vcc($fft_size, $forward, $window, $shift, $nthreads)
-#else
-fft.fft_vfc($fft_size, $forward, $window, $nthreads)
-#end if</make>
- <callback>set_nthreads($nthreads)</callback>
- <param>
- <name>Input Type</name>
- <key>type</key>
- <type>enum</type>
- <option>
- <name>Complex</name>
- <key>complex</key>
- <opt>hide_shift:</opt>
- </option>
- <option>
- <name>Float</name>
- <key>float</key>
- <opt>hide_shift:all</opt>
- </option>
- </param>
- <param>
- <name>FFT Size</name>
- <key>fft_size</key>
- <value>1024</value>
- <type>int</type>
- </param>
- <param>
- <name>Forward/Reverse</name>
- <key>forward</key>
- <type>enum</type>
- <option>
- <name>Forward</name>
- <key>True</key>
- </option>
- <option>
- <name>Reverse</name>
- <key>False</key>
- </option>
- </param>
- <param>
- <name>Window</name>
- <key>window</key>
- <value>window.blackmanharris(1024)</value>
- <type>real_vector</type>
- </param>
- <param>
- <name>Shift</name>
- <key>shift</key>
- <type>enum</type>
- <hide>$type.hide_shift</hide>
- <option>
- <name>Yes</name>
- <key>True</key>
- </option>
- <option>
- <name>No</name>
- <key>False</key>
- </option>
- </param>
- <param>
- <name>Num. Threads</name>
- <key>nthreads</key>
- <value>1</value>
- <type>int</type>
- </param>
- <sink>
- <name>in</name>
- <type>$type</type>
- <vlen>$fft_size</vlen>
- </sink>
- <source>
- <name>out</name>
- <type>complex</type>
- <vlen>$fft_size</vlen>
- </source>
-</block>
diff --git a/gr-fft/grc/fft_goertzel_fc.block.yml b/gr-fft/grc/fft_goertzel_fc.block.yml
new file mode 100644
index 0000000000..6ea74e7f53
--- /dev/null
+++ b/gr-fft/grc/fft_goertzel_fc.block.yml
@@ -0,0 +1,30 @@
+id: goertzel_fc
+label: Goertzel
+
+parameters:
+- id: rate
+ label: Rate
+ dtype: int
+- id: len
+ label: Length
+ dtype: int
+- id: freq
+ label: Frequency
+ dtype: real
+
+inputs:
+- domain: stream
+ dtype: float
+
+outputs:
+- domain: stream
+ dtype: complex
+
+templates:
+ imports: from gnuradio import fft
+ make: fft.goertzel_fc(${rate}, ${len}, ${freq})
+ callbacks:
+ - set_freq(${freq})
+ - set_rate(${rate})
+
+file_format: 1
diff --git a/gr-fft/grc/fft_goertzel_fc.xml b/gr-fft/grc/fft_goertzel_fc.xml
deleted file mode 100644
index 3712843586..0000000000
--- a/gr-fft/grc/fft_goertzel_fc.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0"?>
-<!--
-###################################################
-##Goertzel
-###################################################
- -->
-<block>
- <name>Goertzel</name>
- <key>goertzel_fc</key>
- <import>from gnuradio import fft</import>
- <make>fft.goertzel_fc($rate, $len, $freq)</make>
- <callback>set_freq($freq)</callback>
- <callback>set_rate($rate)</callback>
- <param>
- <name>Rate</name>
- <key>rate</key>
- <type>int</type>
- </param>
- <param>
- <name>Length</name>
- <key>len</key>
- <type>int</type>
- </param>
- <param>
- <name>Frequency</name>
- <key>freq</key>
- <type>real</type>
- </param>
- <sink>
- <name>in</name>
- <type>float</type>
- </sink>
- <source>
- <name>out</name>
- <type>complex</type>
- </source>
-</block>
diff --git a/gr-fft/grc/fft_logpwrfft_x.block.yml b/gr-fft/grc/fft_logpwrfft_x.block.yml
new file mode 100644
index 0000000000..3090699a50
--- /dev/null
+++ b/gr-fft/grc/fft_logpwrfft_x.block.yml
@@ -0,0 +1,64 @@
+id: logpwrfft_x
+label: Log Power FFT
+
+parameters:
+- id: type
+ label: Input Type
+ dtype: enum
+ options: [complex, float]
+ option_attributes:
+ fcn: [c, f]
+ hide: part
+- id: sample_rate
+ label: Sample Rate
+ dtype: real
+ default: samp_rate
+- id: fft_size
+ label: FFT Size
+ dtype: int
+ default: '1024'
+ hide: ${ 'part' if vlen == 1 else 'none' }
+- id: ref_scale
+ label: Reference Scale
+ dtype: real
+ default: '2'
+- id: frame_rate
+ label: Frame Rate
+ dtype: real
+ default: '30'
+- id: average
+ label: Average
+ dtype: bool
+ default: 'False'
+ options: ['True', 'False']
+ option_labels: ['On', 'Off']
+- id: avg_alpha
+ label: Average Alpha
+ dtype: real
+ default: '1.0'
+
+inputs:
+- domain: stream
+ dtype: ${ type }
+
+outputs:
+- domain: stream
+ dtype: float
+ vlen: ${ fft_size }
+
+templates:
+ imports: from gnuradio.fft import logpwrfft
+ make: |-
+ logpwrfft.logpwrfft_${type.fcn}(
+ sample_rate=${sample_rate},
+ fft_size=${fft_size},
+ ref_scale=${ref_scale},
+ frame_rate=${frame_rate},
+ avg_alpha=${avg_alpha},
+ average=${average})
+ callbacks:
+ - set_sample_rate(${sample_rate})
+ - set_avg_alpha(${avg_alpha})
+ - set_average(${average})
+
+file_format: 1
diff --git a/gr-fft/grc/fft_logpwrfft_x.xml b/gr-fft/grc/fft_logpwrfft_x.xml
deleted file mode 100644
index ee45b577d8..0000000000
--- a/gr-fft/grc/fft_logpwrfft_x.xml
+++ /dev/null
@@ -1,90 +0,0 @@
-<?xml version="1.0"?>
-<!--
-###################################################
-##Log Power FFT
-###################################################
- -->
-<block>
- <name>Log Power FFT</name>
- <key>logpwrfft_x</key>
- <import>from gnuradio.fft import logpwrfft</import>
- <make>logpwrfft.logpwrfft_$(type.fcn)(
- sample_rate=$sample_rate,
- fft_size=$fft_size,
- ref_scale=$ref_scale,
- frame_rate=$frame_rate,
- avg_alpha=$avg_alpha,
- average=$average,
-)</make>
- <callback>set_sample_rate($sample_rate)</callback>
- <callback>set_avg_alpha($avg_alpha)</callback>
- <callback>set_average($average)</callback>
- <param>
- <name>Input Type</name>
- <key>type</key>
- <type>enum</type>
- <option>
- <name>Complex</name>
- <key>complex</key>
- <opt>fcn:c</opt>
- </option>
- <option>
- <name>Float</name>
- <key>float</key>
- <opt>fcn:f</opt>
- </option>
- </param>
- <param>
- <name>Sample Rate</name>
- <key>sample_rate</key>
- <value>samp_rate</value>
- <type>real</type>
- </param>
- <param>
- <name>FFT Size</name>
- <key>fft_size</key>
- <value>1024</value>
- <type>int</type>
- </param>
- <param>
- <name>Reference Scale</name>
- <key>ref_scale</key>
- <value>2</value>
- <type>real</type>
- </param>
- <param>
- <name>Frame Rate</name>
- <key>frame_rate</key>
- <value>30</value>
- <type>real</type>
- </param>
- <param>
- <name>Average</name>
- <key>average</key>
- <value>False</value>
- <type>bool</type>
- <option>
- <name>On</name>
- <key>True</key>
- </option>
- <option>
- <name>Off</name>
- <key>False</key>
- </option>
- </param>
- <param>
- <name>Average Alpha</name>
- <key>avg_alpha</key>
- <value>1.0</value>
- <type>real</type>
- </param>
- <sink>
- <name>in</name>
- <type>$type</type>
- </sink>
- <source>
- <name>out</name>
- <type>float</type>
- <vlen>$fft_size</vlen>
- </source>
-</block>
diff --git a/gr-fft/include/gnuradio/fft/CMakeLists.txt b/gr-fft/include/gnuradio/fft/CMakeLists.txt
index 55705ee660..0f52b0aa96 100644
--- a/gr-fft/include/gnuradio/fft/CMakeLists.txt
+++ b/gr-fft/include/gnuradio/fft/CMakeLists.txt
@@ -29,14 +29,11 @@ install(FILES
goertzel_fc.h
window.h
DESTINATION ${GR_INCLUDE_DIR}/gnuradio/fft
- COMPONENT "fft_devel"
)
if(ENABLE_GR_CTRLPORT)
install(FILES
ctrlport_probe_psd.h
DESTINATION ${GR_INCLUDE_DIR}/gnuradio/fft
- COMPONENT "fft_devel"
)
endif(ENABLE_GR_CTRLPORT)
-
diff --git a/gr-fft/lib/CMakeLists.txt b/gr-fft/lib/CMakeLists.txt
index 77476e58b4..9777d243df 100644
--- a/gr-fft/lib/CMakeLists.txt
+++ b/gr-fft/lib/CMakeLists.txt
@@ -83,7 +83,7 @@ endif()
add_library(gnuradio-fft SHARED ${fft_sources})
target_link_libraries(gnuradio-fft ${fft_libs})
-GR_LIBRARY_FOO(gnuradio-fft RUNTIME_COMPONENT "fft_runtime" DEVEL_COMPONENT "fft_devel")
+GR_LIBRARY_FOO(gnuradio-fft)
if(ENABLE_STATIC_LIBS)
if(ENABLE_GR_CTRLPORT)
@@ -105,6 +105,6 @@ if(ENABLE_STATIC_LIBS)
endif(NOT WIN32)
install(TARGETS gnuradio-fft_static
- ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "fft_devel" # .lib file
+ ARCHIVE DESTINATION lib${LIB_SUFFIX} # .lib file
)
endif(ENABLE_STATIC_LIBS)
diff --git a/gr-fft/lib/fft_vfc_fftw.cc b/gr-fft/lib/fft_vfc_fftw.cc
index 7e327ea916..b635c3b9bd 100644
--- a/gr-fft/lib/fft_vfc_fftw.cc
+++ b/gr-fft/lib/fft_vfc_fftw.cc
@@ -49,7 +49,7 @@ namespace gr {
io_signature::make(1, 1, fft_size * sizeof(gr_complex))),
d_fft_size(fft_size), d_forward(forward)
{
- d_fft = new fft_complex(d_fft_size, forward, nthreads);
+ d_fft = new fft_complex(d_fft_size, d_forward, nthreads);
if(!set_window(window))
throw std::runtime_error("fft_vfc: window not the same length as fft_size\n");
}
diff --git a/gr-fft/lib/goertzel.cc b/gr-fft/lib/goertzel.cc
index 14098180b5..324d2a76a2 100644
--- a/gr-fft/lib/goertzel.cc
+++ b/gr-fft/lib/goertzel.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2002,2011,2012 Free Software Foundation, Inc.
+ * Copyright 2002,2011,2012,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -24,8 +24,9 @@
#include <config.h>
#endif
-#include <cmath>
#include <gnuradio/fft/goertzel.h>
+#include <gnuradio/math.h>
+#include <cmath>
namespace gr {
namespace fft {
@@ -41,7 +42,7 @@ namespace gr {
d_d1 = 0.0;
d_d2 = 0.0;
- float w = 2.0*M_PI*freq/rate;
+ float w = 2.0*GR_M_PI*freq/rate;
d_wr = 2.0*std::cos(w);
d_wi = std::sin(w);
d_len = len;
diff --git a/gr-fft/lib/window.cc b/gr-fft/lib/window.cc
index cfbdb93dbd..0c1e27f66a 100644
--- a/gr-fft/lib/window.cc
+++ b/gr-fft/lib/window.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2002,2007,2008,2012,2013 Free Software Foundation, Inc.
+ * Copyright 2002,2007,2008,2012,2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -25,6 +25,7 @@
#endif
#include <gnuradio/fft/window.h>
+#include <gnuradio/math.h>
#include <stdexcept>
namespace gr {
@@ -66,7 +67,7 @@ namespace gr {
double freq(int ntaps)
{
- return 2.0*M_PI/ntaps;
+ return 2.0*GR_M_PI/ntaps;
}
double rate(int ntaps)
@@ -98,7 +99,7 @@ namespace gr {
float M = static_cast<float>(ntaps - 1);
for(int n = 0; n < ntaps; n++)
- taps[n] = c0 - c1*cosf((2.0f*M_PI*n)/M) + c2*cosf((4.0f*M_PI*n)/M);
+ taps[n] = c0 - c1*cosf((2.0f*GR_M_PI*n)/M) + c2*cosf((4.0f*GR_M_PI*n)/M);
return taps;
}
@@ -109,8 +110,8 @@ namespace gr {
float M = static_cast<float>(ntaps - 1);
for(int n = 0; n < ntaps; n++)
- taps[n] = c0 - c1*cosf((2.0f*M_PI*n)/M) + c2*cosf((4.0f*M_PI*n)/M) \
- - c3*cosf((6.0f*M_PI*n)/M);
+ taps[n] = c0 - c1*cosf((2.0f*GR_M_PI*n)/M) + c2*cosf((4.0f*GR_M_PI*n)/M) \
+ - c3*cosf((6.0f*GR_M_PI*n)/M);
return taps;
}
@@ -121,8 +122,8 @@ namespace gr {
float M = static_cast<float>(ntaps - 1);
for(int n = 0; n < ntaps; n++)
- taps[n] = c0 - c1*cosf((2.0f*M_PI*n)/M) + c2*cosf((4.0f*M_PI*n)/M) \
- - c3*cosf((6.0f*M_PI*n)/M) + c4*cosf((8.0f*M_PI*n)/M);
+ taps[n] = c0 - c1*cosf((2.0f*GR_M_PI*n)/M) + c2*cosf((4.0f*GR_M_PI*n)/M) \
+ - c3*cosf((6.0f*GR_M_PI*n)/M) + c4*cosf((8.0f*GR_M_PI*n)/M);
return taps;
}
@@ -142,7 +143,7 @@ namespace gr {
float M = static_cast<float>(ntaps - 1);
for(int n = 0; n < ntaps; n++)
- taps[n] = 0.54 - 0.46 * cos((2 * M_PI * n) / M);
+ taps[n] = 0.54 - 0.46 * cos((2 * GR_M_PI * n) / M);
return taps;
}
@@ -153,7 +154,7 @@ namespace gr {
float M = static_cast<float>(ntaps - 1);
for(int n = 0; n < ntaps; n++)
- taps[n] = 0.5 - 0.5 * cos((2 * M_PI * n) / M);
+ taps[n] = 0.5 - 0.5 * cos((2 * GR_M_PI * n) / M);
return taps;
}
diff --git a/gr-fft/python/fft/CMakeLists.txt b/gr-fft/python/fft/CMakeLists.txt
index b3ada6b707..acf81ca050 100644
--- a/gr-fft/python/fft/CMakeLists.txt
+++ b/gr-fft/python/fft/CMakeLists.txt
@@ -25,7 +25,6 @@ GR_PYTHON_INSTALL(
__init__.py
logpwrfft.py
DESTINATION ${GR_PYTHON_DIR}/gnuradio/fft
- COMPONENT "fft_python"
)
########################################################################
@@ -44,6 +43,6 @@ if(ENABLE_TESTING)
file(GLOB py_qa_test_files "qa_*.py")
foreach(py_qa_test_file ${py_qa_test_files})
get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE)
- GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} ${PYTHON_DASH_B} ${py_qa_test_file})
+ GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} -B ${py_qa_test_file})
endforeach(py_qa_test_file)
endif(ENABLE_TESTING)
diff --git a/gr-fft/python/fft/__init__.py b/gr-fft/python/fft/__init__.py
index 1864353ed1..2e110f5371 100644
--- a/gr-fft/python/fft/__init__.py
+++ b/gr-fft/python/fft/__init__.py
@@ -22,11 +22,15 @@
'''
Fourier-transform blocks and related functions.
'''
+
+from __future__ import absolute_import
+from __future__ import unicode_literals
+
import os
try:
- from fft_swig import *
+ from .fft_swig import *
except ImportError:
dirname, filename = os.path.split(os.path.abspath(__file__))
__path__.append(os.path.join(dirname, "..", "..", "swig"))
- from fft_swig import *
+ from .fft_swig import *
diff --git a/gr-fft/python/fft/logpwrfft.py b/gr-fft/python/fft/logpwrfft.py
index 1ed9d6cacb..3c568b67e4 100644
--- a/gr-fft/python/fft/logpwrfft.py
+++ b/gr-fft/python/fft/logpwrfft.py
@@ -1,3 +1,5 @@
+from __future__ import division
+from __future__ import unicode_literals
#
# Copyright 2008 Free Software Foundation, Inc.
#
@@ -23,8 +25,8 @@ from gnuradio import gr
from gnuradio import blocks
import sys, math
-import fft_swig as fft
-from fft_swig import window
+from . import fft_swig as fft
+from .fft_swig import window
try:
from gnuradio import filter
@@ -63,14 +65,14 @@ class _logpwrfft_base(gr.hier_block2):
if win is None: win = window.blackmanharris
fft_window = win(fft_size)
fft = self._fft_block[0](fft_size, True, fft_window)
- window_power = sum(map(lambda x: x*x, fft_window))
+ window_power = sum([x*x for x in fft_window])
c2magsq = blocks.complex_to_mag_squared(fft_size)
self._avg = filter.single_pole_iir_filter_ff(1.0, fft_size)
self._log = blocks.nlog10_ff(10, fft_size,
-20*math.log10(fft_size) # Adjust for number of bins
- -10*math.log10(float(window_power)/fft_size) # Adjust for windowing loss
- -20*math.log10(float(ref_scale)/2)) # Adjust for reference scale
+ -10*math.log10(float(window_power) / fft_size) # Adjust for windowing loss
+ -20*math.log10(float(ref_scale) / 2)) # Adjust for reference scale
self.connect(self, self._sd, fft, c2magsq, self._avg, self._log, self)
self._average = average
@@ -173,4 +175,3 @@ class logpwrfft_c(_logpwrfft_base):
_name = "logpwrfft_c"
_item_size = gr.sizeof_gr_complex
_fft_block = (fft.fft_vcc, )
-
diff --git a/gr-fft/python/fft/qa_fft.py b/gr-fft/python/fft/qa_fft.py
index db3ca7778d..b1c44f2809 100755..100644
--- a/gr-fft/python/fft/qa_fft.py
+++ b/gr-fft/python/fft/qa_fft.py
@@ -19,6 +19,8 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
+from __future__ import division
+
from gnuradio import gr, gr_unittest, fft, blocks
# Note: Octave code to verify these results:
diff --git a/gr-fft/python/fft/qa_goertzel.py b/gr-fft/python/fft/qa_goertzel.py
index c2c5c565e7..ebd272cb22 100755..100644
--- a/gr-fft/python/fft/qa_goertzel.py
+++ b/gr-fft/python/fft/qa_goertzel.py
@@ -20,6 +20,8 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import division
+
from math import pi, cos
from gnuradio import gr, gr_unittest, fft, blocks
@@ -36,30 +38,30 @@ class test_goertzel(gr_unittest.TestCase):
return [cos(2*pi*x*freq/rate) for x in range(rate)]
def transform(self, src_data, rate, freq):
- src = blocks.vector_source_f(src_data, False)
+ src = blocks.vector_source_f(src_data, False)
dft = fft.goertzel_fc(rate, rate, freq)
- dst = blocks.vector_sink_c()
- self.tb.connect(src, dft, dst)
- self.tb.run()
- return dst.data()
+ dst = blocks.vector_sink_c()
+ self.tb.connect(src, dft, dst)
+ self.tb.run()
+ return dst.data()
def test_001(self): # Measure single tone magnitude
- rate = 8000
- freq = 100
- bin = freq
- src_data = self.make_tone_data(rate, freq)
- expected_result = 0.5
- actual_result = abs(self.transform(src_data, rate, bin)[0])
- self.assertAlmostEqual(expected_result, actual_result, places=4)
+ rate = 8000
+ freq = 100
+ bin = freq
+ src_data = self.make_tone_data(rate, freq)
+ expected_result = 0.5
+ actual_result = abs(self.transform(src_data, rate, bin)[0])
+ self.assertAlmostEqual(expected_result, actual_result, places=4)
def test_002(self): # Measure off frequency magnitude
- rate = 8000
- freq = 100
- bin = freq/2
- src_data = self.make_tone_data(rate, freq)
- expected_result = 0.0
- actual_result = abs(self.transform(src_data, rate, bin)[0])
- self.assertAlmostEqual(expected_result, actual_result, places=4)
+ rate = 8000
+ freq = 100
+ bin = freq / 2
+ src_data = self.make_tone_data(rate, freq)
+ expected_result = 0.0
+ actual_result = abs(self.transform(src_data, rate, bin)[0])
+ self.assertAlmostEqual(expected_result, actual_result, places=4)
if __name__ == '__main__':
gr_unittest.run(test_goertzel, "test_goertzel.xml")
diff --git a/gr-fft/swig/CMakeLists.txt b/gr-fft/swig/CMakeLists.txt
index 74a4a25b10..67e34bbba8 100644
--- a/gr-fft/swig/CMakeLists.txt
+++ b/gr-fft/swig/CMakeLists.txt
@@ -44,7 +44,6 @@ GR_SWIG_MAKE(fft_swig fft_swig.i)
GR_SWIG_INSTALL(
TARGETS fft_swig
DESTINATION ${GR_PYTHON_DIR}/gnuradio/fft
- COMPONENT "fft_python"
)
install(
@@ -52,5 +51,4 @@ install(
fft_swig.i
${CMAKE_CURRENT_BINARY_DIR}/fft_swig_doc.i
DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig
- COMPONENT "fft_swig"
)