aboutsummaryrefslogtreecommitdiffstats
path: root/gr-fft
diff options
context:
space:
mode:
authorJosh Morman <mormjb@gmail.com>2020-04-23 10:35:45 -0400
committerJosh Morman <mormjb@gmail.com>2020-06-04 10:05:47 -0400
commita958015fcd19f8374dc2016df471641fcdf7c158 (patch)
treec0593f2bce3b36cff64964d1b07d67773b9fe02d /gr-fft
parentruntime: replace py gateway with pybind11 support, remove feval (diff)
downloadgnuradio-a958015fcd19f8374dc2016df471641fcdf7c158.tar.xz
gnuradio-a958015fcd19f8374dc2016df471641fcdf7c158.zip
fft: add pybind11 bindings
Diffstat (limited to 'gr-fft')
-rw-r--r--gr-fft/python/fft/CMakeLists.txt5
-rw-r--r--gr-fft/python/fft/__init__.py6
-rw-r--r--gr-fft/python/fft/bindings/CMakeLists.txt23
-rw-r--r--gr-fft/python/fft/bindings/ctrlport_probe_psd_python.cc46
-rw-r--r--gr-fft/python/fft/bindings/docstrings/ctrlport_probe_psd_pydoc_template.h33
-rw-r--r--gr-fft/python/fft/bindings/docstrings/fft_pydoc_template.h114
-rw-r--r--gr-fft/python/fft/bindings/docstrings/fft_shift_pydoc_template.h15
-rw-r--r--gr-fft/python/fft/bindings/docstrings/fft_vcc_pydoc_template.h36
-rw-r--r--gr-fft/python/fft/bindings/docstrings/fft_vfc_pydoc_template.h36
-rw-r--r--gr-fft/python/fft/bindings/docstrings/goertzel_fc_pydoc_template.h39
-rw-r--r--gr-fft/python/fft/bindings/docstrings/goertzel_pydoc_template.h39
-rw-r--r--gr-fft/python/fft/bindings/docstrings/window_pydoc_template.h108
-rw-r--r--gr-fft/python/fft/bindings/fft_python.cc155
-rw-r--r--gr-fft/python/fft/bindings/fft_shift_python.cc45
-rw-r--r--gr-fft/python/fft/bindings/fft_vcc_python.cc56
-rw-r--r--gr-fft/python/fft/bindings/fft_vfc_python.cc54
-rw-r--r--gr-fft/python/fft/bindings/goertzel_fc_python.cc53
-rw-r--r--gr-fft/python/fft/bindings/goertzel_python.cc55
-rw-r--r--gr-fft/python/fft/bindings/python_bindings.cc54
-rw-r--r--gr-fft/python/fft/bindings/window_python.cc187
-rw-r--r--gr-fft/python/fft/logpwrfft.py4
-rw-r--r--gr-fft/python/fft/qa_fft.py4
22 files changed, 1157 insertions, 10 deletions
diff --git a/gr-fft/python/fft/CMakeLists.txt b/gr-fft/python/fft/CMakeLists.txt
index 2d9f46d99..e94f20635 100644
--- a/gr-fft/python/fft/CMakeLists.txt
+++ b/gr-fft/python/fft/CMakeLists.txt
@@ -23,9 +23,6 @@ if(ENABLE_TESTING)
set(GR_TEST_LIBRARY_DIRS "")
set(GR_TEST_PYTHON_DIRS
${CMAKE_BINARY_DIR}/gnuradio-runtime/python
- ${CMAKE_BINARY_DIR}/gnuradio-runtime/swig
- ${CMAKE_BINARY_DIR}/gr-blocks/swig
- ${CMAKE_BINARY_DIR}/gr-fft/swig
)
include(GrTest)
file(GLOB py_qa_test_files "qa_*.py")
@@ -34,3 +31,5 @@ if(ENABLE_TESTING)
GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} -B ${py_qa_test_file})
endforeach(py_qa_test_file)
endif(ENABLE_TESTING)
+
+add_subdirectory(bindings)
diff --git a/gr-fft/python/fft/__init__.py b/gr-fft/python/fft/__init__.py
index ac01ea2cc..09b157cf6 100644
--- a/gr-fft/python/fft/__init__.py
+++ b/gr-fft/python/fft/__init__.py
@@ -17,8 +17,8 @@ from __future__ import unicode_literals
import os
try:
- from .fft_swig import *
+ from .fft_python import *
except ImportError:
dirname, filename = os.path.split(os.path.abspath(__file__))
- __path__.append(os.path.join(dirname, "..", "..", "swig"))
- from .fft_swig import *
+ __path__.append(os.path.join(dirname, "bindings"))
+ from .fft_python import *
diff --git a/gr-fft/python/fft/bindings/CMakeLists.txt b/gr-fft/python/fft/bindings/CMakeLists.txt
new file mode 100644
index 000000000..ab1e903bf
--- /dev/null
+++ b/gr-fft/python/fft/bindings/CMakeLists.txt
@@ -0,0 +1,23 @@
+include(GrPybind)
+
+########################################################################
+# Python Bindings
+########################################################################
+
+list(APPEND fft_python_files
+ #ctrlport_probe_psd_python.cc
+ fft_python.cc
+ fft_shift_python.cc
+ fft_vcc_python.cc
+ fft_vfc_python.cc
+ goertzel_python.cc
+ goertzel_fc_python.cc
+ window_python.cc
+ python_bindings.cc)
+
+GR_PYBIND_MAKE(fft
+ ../../..
+ gr::fft
+ "${fft_python_files}")
+
+install(TARGETS fft_python DESTINATION ${GR_PYTHON_DIR}/gnuradio/fft COMPONENT pythonapi)
diff --git a/gr-fft/python/fft/bindings/ctrlport_probe_psd_python.cc b/gr-fft/python/fft/bindings/ctrlport_probe_psd_python.cc
new file mode 100644
index 000000000..2b9ba14c2
--- /dev/null
+++ b/gr-fft/python/fft/bindings/ctrlport_probe_psd_python.cc
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2020 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+/* This file is automatically generated using bindtool */
+
+#include <pybind11/complex.h>
+#include <pybind11/pybind11.h>
+#include <pybind11/stl.h>
+
+namespace py = pybind11;
+
+#include <gnuradio/fft/ctrlport_probe_psd.h>
+// pydoc.h is automatically generated in the build directory
+#include <ctrlport_probe_psd_pydoc.h>
+
+void bind_ctrlport_probe_psd(py::module& m)
+{
+ using ctrlport_probe_psd = gr::fft::ctrlport_probe_psd;
+
+ py::class_<ctrlport_probe_psd,
+ gr::sync_block,
+ gr::block,
+ gr::basic_block,
+ std::shared_ptr<ctrlport_probe_psd>>(
+ m, "ctrlport_probe_psd", D(ctrlport_probe_psd))
+
+ .def(py::init(&ctrlport_probe_psd::make),
+ py::arg("id"),
+ py::arg("desc"),
+ py::arg("len"),
+ D(ctrlport_probe_psd, make))
+
+
+ .def("get", &ctrlport_probe_psd::get, D(ctrlport_probe_psd, get))
+
+ .def("set_length",
+ &ctrlport_probe_psd::set_length,
+ py::arg("len"),
+ D(ctrlport_probe_psd, set_length));
+}
diff --git a/gr-fft/python/fft/bindings/docstrings/ctrlport_probe_psd_pydoc_template.h b/gr-fft/python/fft/bindings/docstrings/ctrlport_probe_psd_pydoc_template.h
new file mode 100644
index 000000000..28584573c
--- /dev/null
+++ b/gr-fft/python/fft/bindings/docstrings/ctrlport_probe_psd_pydoc_template.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2020 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+#include "pydoc_macros.h"
+#define D(...) DOC(gr, fft, __VA_ARGS__)
+/*
+ This file contains placeholders for docstrings for the Python bindings.
+ Do not edit! These were automatically extracted during the binding process
+ and will be overwritten during the build process
+ */
+
+
+static const char* __doc_gr_fft_ctrlport_probe_psd = R"doc()doc";
+
+
+static const char* __doc_gr_fft_ctrlport_probe_psd_ctrlport_probe_psd_0 = R"doc()doc";
+
+
+static const char* __doc_gr_fft_ctrlport_probe_psd_ctrlport_probe_psd_1 = R"doc()doc";
+
+
+static const char* __doc_gr_fft_ctrlport_probe_psd_make = R"doc()doc";
+
+
+static const char* __doc_gr_fft_ctrlport_probe_psd_get = R"doc()doc";
+
+
+static const char* __doc_gr_fft_ctrlport_probe_psd_set_length = R"doc()doc";
diff --git a/gr-fft/python/fft/bindings/docstrings/fft_pydoc_template.h b/gr-fft/python/fft/bindings/docstrings/fft_pydoc_template.h
new file mode 100644
index 000000000..fabe5afd4
--- /dev/null
+++ b/gr-fft/python/fft/bindings/docstrings/fft_pydoc_template.h
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2020 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+#include "pydoc_macros.h"
+#define D(...) DOC(gr, fft, __VA_ARGS__)
+/*
+ This file contains placeholders for docstrings for the Python bindings.
+ Do not edit! These were automatically extracted during the binding process
+ and will be overwritten during the build process
+ */
+
+
+static const char* __doc_gr_fft_planner = R"doc()doc";
+
+
+static const char* __doc_gr_fft_planner_planner_0 = R"doc()doc";
+
+
+static const char* __doc_gr_fft_planner_planner_1 = R"doc()doc";
+
+
+static const char* __doc_gr_fft_planner_mutex = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_complex = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_complex_fft_complex = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_complex_get_inbuf = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_complex_get_outbuf = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_complex_inbuf_length = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_complex_outbuf_length = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_complex_set_nthreads = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_complex_nthreads = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_complex_execute = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_real_fwd = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_real_fwd_fft_real_fwd = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_real_fwd_get_inbuf = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_real_fwd_get_outbuf = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_real_fwd_inbuf_length = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_real_fwd_outbuf_length = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_real_fwd_set_nthreads = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_real_fwd_nthreads = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_real_fwd_execute = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_real_rev = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_real_rev_fft_real_rev = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_real_rev_get_inbuf = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_real_rev_get_outbuf = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_real_rev_inbuf_length = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_real_rev_outbuf_length = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_real_rev_set_nthreads = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_real_rev_nthreads = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_real_rev_execute = R"doc()doc";
+
+
+static const char* __doc_gr_fft_malloc_complex = R"doc()doc";
+
+
+static const char* __doc_gr_fft_free = R"doc()doc";
diff --git a/gr-fft/python/fft/bindings/docstrings/fft_shift_pydoc_template.h b/gr-fft/python/fft/bindings/docstrings/fft_shift_pydoc_template.h
new file mode 100644
index 000000000..4a1b3ede3
--- /dev/null
+++ b/gr-fft/python/fft/bindings/docstrings/fft_shift_pydoc_template.h
@@ -0,0 +1,15 @@
+/*
+ * Copyright 2020 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+#include "pydoc_macros.h"
+#define D(...) DOC(gr, fft, __VA_ARGS__)
+/*
+ This file contains placeholders for docstrings for the Python bindings.
+ Do not edit! These were automatically extracted during the binding process
+ and will be overwritten during the build process
+ */
diff --git a/gr-fft/python/fft/bindings/docstrings/fft_vcc_pydoc_template.h b/gr-fft/python/fft/bindings/docstrings/fft_vcc_pydoc_template.h
new file mode 100644
index 000000000..ecf12fc7f
--- /dev/null
+++ b/gr-fft/python/fft/bindings/docstrings/fft_vcc_pydoc_template.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2020 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+#include "pydoc_macros.h"
+#define D(...) DOC(gr, fft, __VA_ARGS__)
+/*
+ This file contains placeholders for docstrings for the Python bindings.
+ Do not edit! These were automatically extracted during the binding process
+ and will be overwritten during the build process
+ */
+
+
+static const char* __doc_gr_fft_fft_vcc = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_vcc_fft_vcc_0 = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_vcc_fft_vcc_1 = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_vcc_make = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_vcc_set_nthreads = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_vcc_nthreads = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_vcc_set_window = R"doc()doc";
diff --git a/gr-fft/python/fft/bindings/docstrings/fft_vfc_pydoc_template.h b/gr-fft/python/fft/bindings/docstrings/fft_vfc_pydoc_template.h
new file mode 100644
index 000000000..6c8a4b15b
--- /dev/null
+++ b/gr-fft/python/fft/bindings/docstrings/fft_vfc_pydoc_template.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2020 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+#include "pydoc_macros.h"
+#define D(...) DOC(gr, fft, __VA_ARGS__)
+/*
+ This file contains placeholders for docstrings for the Python bindings.
+ Do not edit! These were automatically extracted during the binding process
+ and will be overwritten during the build process
+ */
+
+
+static const char* __doc_gr_fft_fft_vfc = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_vfc_fft_vfc_0 = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_vfc_fft_vfc_1 = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_vfc_make = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_vfc_set_nthreads = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_vfc_nthreads = R"doc()doc";
+
+
+static const char* __doc_gr_fft_fft_vfc_set_window = R"doc()doc";
diff --git a/gr-fft/python/fft/bindings/docstrings/goertzel_fc_pydoc_template.h b/gr-fft/python/fft/bindings/docstrings/goertzel_fc_pydoc_template.h
new file mode 100644
index 000000000..76ebd24a8
--- /dev/null
+++ b/gr-fft/python/fft/bindings/docstrings/goertzel_fc_pydoc_template.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2020 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+#include "pydoc_macros.h"
+#define D(...) DOC(gr, fft, __VA_ARGS__)
+/*
+ This file contains placeholders for docstrings for the Python bindings.
+ Do not edit! These were automatically extracted during the binding process
+ and will be overwritten during the build process
+ */
+
+
+static const char* __doc_gr_fft_goertzel_fc = R"doc()doc";
+
+
+static const char* __doc_gr_fft_goertzel_fc_goertzel_fc_0 = R"doc()doc";
+
+
+static const char* __doc_gr_fft_goertzel_fc_goertzel_fc_1 = R"doc()doc";
+
+
+static const char* __doc_gr_fft_goertzel_fc_make = R"doc()doc";
+
+
+static const char* __doc_gr_fft_goertzel_fc_set_freq = R"doc()doc";
+
+
+static const char* __doc_gr_fft_goertzel_fc_set_rate = R"doc()doc";
+
+
+static const char* __doc_gr_fft_goertzel_fc_freq = R"doc()doc";
+
+
+static const char* __doc_gr_fft_goertzel_fc_rate = R"doc()doc";
diff --git a/gr-fft/python/fft/bindings/docstrings/goertzel_pydoc_template.h b/gr-fft/python/fft/bindings/docstrings/goertzel_pydoc_template.h
new file mode 100644
index 000000000..a0963f2f4
--- /dev/null
+++ b/gr-fft/python/fft/bindings/docstrings/goertzel_pydoc_template.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2020 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+#include "pydoc_macros.h"
+#define D(...) DOC(gr, fft, __VA_ARGS__)
+/*
+ This file contains placeholders for docstrings for the Python bindings.
+ Do not edit! These were automatically extracted during the binding process
+ and will be overwritten during the build process
+ */
+
+
+static const char* __doc_gr_fft_goertzel = R"doc()doc";
+
+
+static const char* __doc_gr_fft_goertzel_goertzel_0 = R"doc()doc";
+
+
+static const char* __doc_gr_fft_goertzel_goertzel_1 = R"doc()doc";
+
+
+static const char* __doc_gr_fft_goertzel_set_params = R"doc()doc";
+
+
+static const char* __doc_gr_fft_goertzel_batch = R"doc()doc";
+
+
+static const char* __doc_gr_fft_goertzel_input = R"doc()doc";
+
+
+static const char* __doc_gr_fft_goertzel_output = R"doc()doc";
+
+
+static const char* __doc_gr_fft_goertzel_ready = R"doc()doc";
diff --git a/gr-fft/python/fft/bindings/docstrings/window_pydoc_template.h b/gr-fft/python/fft/bindings/docstrings/window_pydoc_template.h
new file mode 100644
index 000000000..cc089b8c4
--- /dev/null
+++ b/gr-fft/python/fft/bindings/docstrings/window_pydoc_template.h
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2020 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+#include "pydoc_macros.h"
+#define D(...) DOC(gr, fft, __VA_ARGS__)
+/*
+ This file contains placeholders for docstrings for the Python bindings.
+ Do not edit! These were automatically extracted during the binding process
+ and will be overwritten during the build process
+ */
+
+
+static const char* __doc_gr_fft_window = R"doc()doc";
+
+
+static const char* __doc_gr_fft_window_window_0 = R"doc()doc";
+
+
+static const char* __doc_gr_fft_window_window_1 = R"doc()doc";
+
+
+static const char* __doc_gr_fft_window_max_attenuation = R"doc()doc";
+
+
+static const char* __doc_gr_fft_window_coswindow_0 = R"doc()doc";
+
+
+static const char* __doc_gr_fft_window_coswindow_1 = R"doc()doc";
+
+
+static const char* __doc_gr_fft_window_coswindow_2 = R"doc()doc";
+
+
+static const char* __doc_gr_fft_window_rectangular = R"doc()doc";
+
+
+static const char* __doc_gr_fft_window_hamming = R"doc()doc";
+
+
+static const char* __doc_gr_fft_window_hann = R"doc()doc";
+
+
+static const char* __doc_gr_fft_window_hanning = R"doc()doc";
+
+
+static const char* __doc_gr_fft_window_blackman = R"doc()doc";
+
+
+static const char* __doc_gr_fft_window_blackman2 = R"doc()doc";
+
+
+static const char* __doc_gr_fft_window_blackman3 = R"doc()doc";
+
+
+static const char* __doc_gr_fft_window_blackman4 = R"doc()doc";
+
+
+static const char* __doc_gr_fft_window_blackman_harris = R"doc()doc";
+
+
+static const char* __doc_gr_fft_window_blackmanharris = R"doc()doc";
+
+
+static const char* __doc_gr_fft_window_nuttall = R"doc()doc";
+
+
+static const char* __doc_gr_fft_window_nuttal = R"doc()doc";
+
+
+static const char* __doc_gr_fft_window_blackman_nuttall = R"doc()doc";
+
+
+static const char* __doc_gr_fft_window_blackman_nuttal = R"doc()doc";
+
+
+static const char* __doc_gr_fft_window_nuttall_cfd = R"doc()doc";
+
+
+static const char* __doc_gr_fft_window_nuttal_cfd = R"doc()doc";
+
+
+static const char* __doc_gr_fft_window_flattop = R"doc()doc";
+
+
+static const char* __doc_gr_fft_window_kaiser = R"doc()doc";
+
+
+static const char* __doc_gr_fft_window_bartlett = R"doc()doc";
+
+
+static const char* __doc_gr_fft_window_welch = R"doc()doc";
+
+
+static const char* __doc_gr_fft_window_parzen = R"doc()doc";
+
+
+static const char* __doc_gr_fft_window_exponential = R"doc()doc";
+
+
+static const char* __doc_gr_fft_window_riemann = R"doc()doc";
+
+
+static const char* __doc_gr_fft_window_build = R"doc()doc";
diff --git a/gr-fft/python/fft/bindings/fft_python.cc b/gr-fft/python/fft/bindings/fft_python.cc
new file mode 100644
index 000000000..054863255
--- /dev/null
+++ b/gr-fft/python/fft/bindings/fft_python.cc
@@ -0,0 +1,155 @@
+/*
+ * Copyright 2020 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+/* This file is automatically generated using bindtool */
+
+#include <pybind11/complex.h>
+#include <pybind11/pybind11.h>
+#include <pybind11/stl.h>
+
+namespace py = pybind11;
+
+#include <gnuradio/fft/fft.h>
+// pydoc.h is automatically generated in the build directory
+#include <fft_pydoc.h>
+
+void bind_fft(py::module& m)
+{
+
+ using planner = ::gr::fft::planner;
+ using fft_complex = ::gr::fft::fft_complex;
+ using fft_real_fwd = ::gr::fft::fft_real_fwd;
+ using fft_real_rev = ::gr::fft::fft_real_rev;
+
+
+ py::class_<planner, std::shared_ptr<planner>>(m, "planner", D(planner))
+
+ .def(py::init<>(), D(planner, planner, 0))
+ .def(py::init<gr::fft::planner const&>(), py::arg("arg0"), D(planner, planner, 1))
+
+
+ .def_static("mutex", &planner::mutex, D(planner, mutex))
+
+ ;
+
+
+ py::class_<fft_complex, std::shared_ptr<fft_complex>>(
+ m, "fft_complex", D(fft_complex))
+
+ .def(py::init<int, bool, int>(),
+ py::arg("fft_size"),
+ py::arg("forward") = true,
+ py::arg("nthreads") = 1,
+ D(fft_complex, fft_complex))
+
+
+ .def("get_inbuf", &fft_complex::get_inbuf, D(fft_complex, get_inbuf))
+
+
+ .def("get_outbuf", &fft_complex::get_outbuf, D(fft_complex, get_outbuf))
+
+
+ .def("inbuf_length", &fft_complex::inbuf_length, D(fft_complex, inbuf_length))
+
+
+ .def("outbuf_length", &fft_complex::outbuf_length, D(fft_complex, outbuf_length))
+
+
+ .def("set_nthreads",
+ &fft_complex::set_nthreads,
+ py::arg("n"),
+ D(fft_complex, set_nthreads))
+
+
+ .def("nthreads", &fft_complex::nthreads, D(fft_complex, nthreads))
+
+
+ .def("execute", &fft_complex::execute, D(fft_complex, execute))
+
+ ;
+
+
+ py::class_<fft_real_fwd, std::shared_ptr<fft_real_fwd>>(
+ m, "fft_real_fwd", D(fft_real_fwd))
+
+ .def(py::init<int, int>(),
+ py::arg("fft_size"),
+ py::arg("nthreads") = 1,
+ D(fft_real_fwd, fft_real_fwd))
+
+
+ .def("get_inbuf", &fft_real_fwd::get_inbuf, D(fft_real_fwd, get_inbuf))
+
+
+ .def("get_outbuf", &fft_real_fwd::get_outbuf, D(fft_real_fwd, get_outbuf))
+
+
+ .def("inbuf_length", &fft_real_fwd::inbuf_length, D(fft_real_fwd, inbuf_length))
+
+
+ .def(
+ "outbuf_length", &fft_real_fwd::outbuf_length, D(fft_real_fwd, outbuf_length))
+
+
+ .def("set_nthreads",
+ &fft_real_fwd::set_nthreads,
+ py::arg("n"),
+ D(fft_real_fwd, set_nthreads))
+
+
+ .def("nthreads", &fft_real_fwd::nthreads, D(fft_real_fwd, nthreads))
+
+
+ .def("execute", &fft_real_fwd::execute, D(fft_real_fwd, execute))
+
+ ;
+
+
+ py::class_<fft_real_rev, std::shared_ptr<fft_real_rev>>(
+ m, "fft_real_rev", D(fft_real_rev))
+
+ .def(py::init<int, int>(),
+ py::arg("fft_size"),
+ py::arg("nthreads") = 1,
+ D(fft_real_rev, fft_real_rev))
+
+
+ .def("get_inbuf", &fft_real_rev::get_inbuf, D(fft_real_rev, get_inbuf))
+
+
+ .def("get_outbuf", &fft_real_rev::get_outbuf, D(fft_real_rev, get_outbuf))
+
+
+ .def("inbuf_length", &fft_real_rev::inbuf_length, D(fft_real_rev, inbuf_length))
+
+
+ .def(
+ "outbuf_length", &fft_real_rev::outbuf_length, D(fft_real_rev, outbuf_length))
+
+
+ .def("set_nthreads",
+ &fft_real_rev::set_nthreads,
+ py::arg("n"),
+ D(fft_real_rev, set_nthreads))
+
+
+ .def("nthreads", &fft_real_rev::nthreads, D(fft_real_rev, nthreads))
+
+
+ .def("execute", &fft_real_rev::execute, D(fft_real_rev, execute))
+
+ ;
+
+
+ m.def(
+ "malloc_complex", &::gr::fft::malloc_complex, py::arg("size"), D(malloc_complex));
+
+
+ m.def("free", &::gr::fft::free, py::arg("b"), D(free));
+}
diff --git a/gr-fft/python/fft/bindings/fft_shift_python.cc b/gr-fft/python/fft/bindings/fft_shift_python.cc
new file mode 100644
index 000000000..7795f2bc1
--- /dev/null
+++ b/gr-fft/python/fft/bindings/fft_shift_python.cc
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2020 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+/* This file is automatically generated using bindtool */
+
+#include <pybind11/complex.h>
+#include <pybind11/pybind11.h>
+#include <pybind11/stl.h>
+
+namespace py = pybind11;
+
+#include <gnuradio/fft/fft_shift.h>
+// pydoc.h is automatically generated in the build directory
+#include <fft_shift_pydoc.h>
+
+template <typename T>
+void bind_fft_shift_template(py::module& m, const char* classname)
+{
+ // TODO: Finish the template binding code and determine what classes should be exposed
+
+ // using fft_shift = gr::blocks::fft_shift<T>;
+
+ // py::class_<fft_shift, gr::sync_block, gr::block, gr::basic_block,
+ // std::shared_ptr<fft_shift>>(m, classname)
+ // .def(py::init<size_t>,
+ // py::arg("vlen") = 1
+ // )
+ // .def("shift",&fft_shift
+ // )
+ // ;
+}
+
+void bind_fft_shift(py::module& m)
+{
+ // bind_fft_shift_template<std::int16_t>(m,"fft_shift_ss");
+ // bind_fft_shift_template<std::int32_t>(m,"fft_shift_ii");
+ // bind_fft_shift_template<float>(m,"fft_shift_ff");
+ // bind_fft_shift_template<gr_complex>(m,"fft_shift_cc");
+}
diff --git a/gr-fft/python/fft/bindings/fft_vcc_python.cc b/gr-fft/python/fft/bindings/fft_vcc_python.cc
new file mode 100644
index 000000000..958a70a2f
--- /dev/null
+++ b/gr-fft/python/fft/bindings/fft_vcc_python.cc
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2020 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+/* This file is automatically generated using bindtool */
+
+#include <pybind11/complex.h>
+#include <pybind11/pybind11.h>
+#include <pybind11/stl.h>
+
+namespace py = pybind11;
+
+#include <gnuradio/fft/fft_vcc.h>
+// pydoc.h is automatically generated in the build directory
+#include <fft_vcc_pydoc.h>
+
+void bind_fft_vcc(py::module& m)
+{
+
+ using fft_vcc = ::gr::fft::fft_vcc;
+
+
+ py::class_<fft_vcc,
+ gr::sync_block,
+ gr::block,
+ gr::basic_block,
+ std::shared_ptr<fft_vcc>>(m, "fft_vcc", D(fft_vcc))
+
+ .def(py::init(&fft_vcc::make),
+ py::arg("fft_size"),
+ py::arg("forward"),
+ py::arg("window"),
+ py::arg("shift") = false,
+ py::arg("nthreads") = 1,
+ D(fft_vcc, make))
+
+
+ .def("set_nthreads",
+ &fft_vcc::set_nthreads,
+ py::arg("n"),
+ D(fft_vcc, set_nthreads))
+
+
+ .def("nthreads", &fft_vcc::nthreads, D(fft_vcc, nthreads))
+
+
+ .def("set_window",
+ &fft_vcc::set_window,
+ py::arg("window"),
+ D(fft_vcc, set_window));
+}
diff --git a/gr-fft/python/fft/bindings/fft_vfc_python.cc b/gr-fft/python/fft/bindings/fft_vfc_python.cc
new file mode 100644
index 000000000..a80f2176c
--- /dev/null
+++ b/gr-fft/python/fft/bindings/fft_vfc_python.cc
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2020 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+/* This file is automatically generated using bindtool */
+
+#include <pybind11/complex.h>
+#include <pybind11/pybind11.h>
+#include <pybind11/stl.h>
+
+namespace py = pybind11;
+
+#include <gnuradio/fft/fft_vfc.h>
+// pydoc.h is automatically generated in the build directory
+#include <fft_vfc_pydoc.h>
+
+void bind_fft_vfc(py::module& m)
+{
+ using fft_vfc = gr::fft::fft_vfc;
+
+
+ py::class_<fft_vfc,
+ gr::sync_block,
+ gr::block,
+ gr::basic_block,
+ std::shared_ptr<fft_vfc>>(m, "fft_vfc", D(fft_vfc))
+
+ .def(py::init(&fft_vfc::make),
+ py::arg("fft_size"),
+ py::arg("forward"),
+ py::arg("window"),
+ py::arg("nthreads") = 1,
+ D(fft_vfc, make))
+
+
+ .def("set_nthreads",
+ &fft_vfc::set_nthreads,
+ py::arg("n"),
+ D(fft_vfc, set_nthreads))
+
+
+ .def("nthreads", &fft_vfc::nthreads, D(fft_vfc, nthreads))
+
+
+ .def("set_window",
+ &fft_vfc::set_window,
+ py::arg("window"),
+ D(fft_vfc, set_window));
+}
diff --git a/gr-fft/python/fft/bindings/goertzel_fc_python.cc b/gr-fft/python/fft/bindings/goertzel_fc_python.cc
new file mode 100644
index 000000000..936b98aaa
--- /dev/null
+++ b/gr-fft/python/fft/bindings/goertzel_fc_python.cc
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2020 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+/* This file is automatically generated using bindtool */
+
+#include <pybind11/complex.h>
+#include <pybind11/pybind11.h>
+#include <pybind11/stl.h>
+
+namespace py = pybind11;
+
+#include <gnuradio/fft/goertzel_fc.h>
+// pydoc.h is automatically generated in the build directory
+#include <goertzel_fc_pydoc.h>
+
+void bind_goertzel_fc(py::module& m)
+{
+ using goertzel_fc = gr::fft::goertzel_fc;
+
+
+ py::class_<goertzel_fc,
+ gr::sync_decimator,
+ gr::sync_block,
+ gr::block,
+ gr::basic_block,
+ std::shared_ptr<goertzel_fc>>(m, "goertzel_fc", D(goertzel_fc))
+
+ .def(py::init(&goertzel_fc::make),
+ py::arg("rate"),
+ py::arg("len"),
+ py::arg("freq"),
+ D(goertzel_fc, make))
+
+
+ .def(
+ "set_freq", &goertzel_fc::set_freq, py::arg("freq"), D(goertzel_fc, set_freq))
+ .def(
+ "set_rate", &goertzel_fc::set_rate, py::arg("rate"), D(goertzel_fc, set_rate))
+
+
+ .def("freq", &goertzel_fc::freq, D(goertzel_fc, freq))
+
+
+ .def("rate", &goertzel_fc::rate, D(goertzel_fc, rate))
+
+ ;
+}
diff --git a/gr-fft/python/fft/bindings/goertzel_python.cc b/gr-fft/python/fft/bindings/goertzel_python.cc
new file mode 100644
index 000000000..79bc72563
--- /dev/null
+++ b/gr-fft/python/fft/bindings/goertzel_python.cc
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2020 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+/* This file is automatically generated using bindtool */
+
+#include <pybind11/complex.h>
+#include <pybind11/pybind11.h>
+#include <pybind11/stl.h>
+
+namespace py = pybind11;
+
+#include <gnuradio/fft/goertzel.h>
+// pydoc.h is automatically generated in the build directory
+#include <goertzel_pydoc.h>
+
+void bind_goertzel(py::module& m)
+{
+
+ using goertzel = ::gr::fft::goertzel;
+
+
+ py::class_<goertzel, std::shared_ptr<goertzel>>(m, "goertzel", D(goertzel))
+
+ .def(py::init<int, int, float>(),
+ py::arg("rate"),
+ py::arg("len"),
+ py::arg("freq"),
+ D(goertzel, goertzel, 0))
+ .def(py::init<gr::fft::goertzel const&>(),
+ py::arg("arg0"),
+ D(goertzel, goertzel, 1))
+
+ .def("set_params",
+ &goertzel::set_params,
+ py::arg("rate"),
+ py::arg("len"),
+ py::arg("freq"),
+ D(goertzel, set_params))
+ .def("batch", &goertzel::batch, py::arg("in"), D(goertzel, batch))
+ .def("input", &goertzel::input, py::arg("in"), D(goertzel, input))
+
+
+ .def("output", &goertzel::output, D(goertzel, output))
+
+
+ .def("ready", &goertzel::ready, D(goertzel, ready))
+
+ ;
+}
diff --git a/gr-fft/python/fft/bindings/python_bindings.cc b/gr-fft/python/fft/bindings/python_bindings.cc
new file mode 100644
index 000000000..a1c191ed3
--- /dev/null
+++ b/gr-fft/python/fft/bindings/python_bindings.cc
@@ -0,0 +1,54 @@
+
+/*
+ * Copyright 2020 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+#include <pybind11/pybind11.h>
+
+#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
+#include <numpy/arrayobject.h>
+
+namespace py = pybind11;
+
+// void bind_ctrlport_probe_psd(py::module&);
+void bind_fft(py::module&);
+void bind_fft_shift(py::module&);
+void bind_fft_vcc(py::module&);
+void bind_fft_vfc(py::module&);
+void bind_goertzel(py::module&);
+void bind_goertzel_fc(py::module&);
+void bind_window(py::module&);
+
+// We need this hack because import_array() returns NULL
+// for newer Python versions.
+// This function is also necessary because it ensures access to the C API
+// and removes a warning.
+void* init_numpy()
+{
+ import_array();
+ return NULL;
+}
+
+PYBIND11_MODULE(fft_python, m)
+{
+ // Initialize the numpy C API
+ // (otherwise we will see segmentation faults)
+ init_numpy();
+
+ // Allow access to base block methods
+ py::module::import("gnuradio.gr");
+
+ // bind_ctrlport_probe_psd(m);
+ bind_fft(m);
+ bind_fft_shift(m);
+ bind_fft_vcc(m);
+ bind_fft_vfc(m);
+ bind_goertzel(m);
+ bind_goertzel_fc(m);
+ bind_window(m);
+}
diff --git a/gr-fft/python/fft/bindings/window_python.cc b/gr-fft/python/fft/bindings/window_python.cc
new file mode 100644
index 000000000..f331ac339
--- /dev/null
+++ b/gr-fft/python/fft/bindings/window_python.cc
@@ -0,0 +1,187 @@
+/*
+ * Copyright 2020 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+/* This file is automatically generated using bindtool */
+
+#include <pybind11/complex.h>
+#include <pybind11/pybind11.h>
+#include <pybind11/stl.h>
+
+namespace py = pybind11;
+
+#include <gnuradio/fft/window.h>
+// pydoc.h is automatically generated in the build directory
+#include <window_pydoc.h>
+
+void bind_window(py::module& m)
+{
+ using window = gr::fft::window;
+
+
+ py::class_<window, std::shared_ptr<window>>(m, "window", D(window))
+
+
+ .def_static("max_attenuation",
+ &window::max_attenuation,
+ py::arg("type"),
+ py::arg("beta") = 6.7599999999999998,
+ D(window, max_attenuation))
+
+
+ .def_static("coswindow",
+ (std::vector<float>(*)(int, float, float, float)) & window::coswindow,
+ py::arg("ntaps"),
+ py::arg("c0"),
+ py::arg("c1"),
+ py::arg("c2"),
+ D(window, coswindow, 0))
+
+
+ .def_static("coswindow",
+ (std::vector<float>(*)(int, float, float, float, float)) &
+ window::coswindow,
+ py::arg("ntaps"),
+ py::arg("c0"),
+ py::arg("c1"),
+ py::arg("c2"),
+ py::arg("c3"),
+ D(window, coswindow, 1))
+
+
+ .def_static("coswindow",
+ (std::vector<float>(*)(int, float, float, float, float, float)) &
+ window::coswindow,
+ py::arg("ntaps"),
+ py::arg("c0"),
+ py::arg("c1"),
+ py::arg("c2"),
+ py::arg("c3"),
+ py::arg("c4"),
+ D(window, coswindow, 2))
+
+
+ .def_static(
+ "rectangular", &window::rectangular, py::arg("ntaps"), D(window, rectangular))
+
+
+ .def_static("hamming", &window::hamming, py::arg("ntaps"), D(window, hamming))
+
+
+ .def_static("hann", &window::hann, py::arg("ntaps"), D(window, hann))
+
+
+ .def_static("hanning", &window::hanning, py::arg("ntaps"), D(window, hanning))
+
+
+ .def_static("blackman", &window::blackman, py::arg("ntaps"), D(window, blackman))
+
+
+ .def_static(
+ "blackman2", &window::blackman2, py::arg("ntaps"), D(window, blackman2))
+
+
+ .def_static(
+ "blackman3", &window::blackman3, py::arg("ntaps"), D(window, blackman3))
+
+
+ .def_static(
+ "blackman4", &window::blackman4, py::arg("ntaps"), D(window, blackman4))
+
+
+ .def_static("blackman_harris",
+ &window::blackman_harris,
+ py::arg("ntaps"),
+ py::arg("atten") = 92,
+ D(window, blackman_harris))
+
+
+ .def_static("blackmanharris",
+ &window::blackmanharris,
+ py::arg("ntaps"),
+ py::arg("atten") = 92,
+ D(window, blackmanharris))
+
+
+ .def_static("nuttall", &window::nuttall, py::arg("ntaps"), D(window, nuttall))
+
+
+ .def_static("nuttal", &window::nuttal, py::arg("ntaps"), D(window, nuttal))
+
+
+ .def_static("blackman_nuttall",
+ &window::blackman_nuttall,
+ py::arg("ntaps"),
+ D(window, blackman_nuttall))
+
+
+ .def_static("blackman_nuttal",
+ &window::blackman_nuttal,
+ py::arg("ntaps"),
+ D(window, blackman_nuttal))
+
+
+ .def_static(
+ "nuttall_cfd", &window::nuttall_cfd, py::arg("ntaps"), D(window, nuttall_cfd))
+
+
+ .def_static(
+ "nuttal_cfd", &window::nuttal_cfd, py::arg("ntaps"), D(window, nuttal_cfd))
+
+
+ .def_static("flattop", &window::flattop, py::arg("ntaps"), D(window, flattop))
+
+
+ .def_static("kaiser",
+ &window::kaiser,
+ py::arg("ntaps"),
+ py::arg("beta"),
+ D(window, kaiser))
+
+
+ .def_static("bartlett", &window::bartlett, py::arg("ntaps"), D(window, bartlett))
+
+
+ .def_static("welch", &window::welch, py::arg("ntaps"), D(window, welch))
+
+
+ .def_static("parzen", &window::parzen, py::arg("ntaps"), D(window, parzen))
+
+
+ .def_static("exponential",
+ &window::exponential,
+ py::arg("ntaps"),
+ py::arg("d"),
+ D(window, exponential))
+
+
+ .def_static("riemann", &window::riemann, py::arg("ntaps"), D(window, riemann))
+
+
+ .def_static("build",
+ &window::build,
+ py::arg("type"),
+ py::arg("ntaps"),
+ py::arg("beta"),
+ D(window, build))
+
+ ;
+
+
+ py::enum_<gr::fft::window::win_type>(m, "win_type")
+ .value("WIN_HAMMING", gr::fft::window::WIN_HAMMING) // 0
+ .value("WIN_HANN", gr::fft::window::WIN_HANN) // 1
+ .value("WIN_BLACKMAN", gr::fft::window::WIN_BLACKMAN) // 2
+ .value("WIN_RECTANGULAR", gr::fft::window::WIN_RECTANGULAR) // 3
+ .value("WIN_KAISER", gr::fft::window::WIN_KAISER) // 4
+ .value("WIN_BLACKMAN_hARRIS", gr::fft::window::WIN_BLACKMAN_hARRIS) // 5
+ .value("WIN_BLACKMAN_HARRIS", gr::fft::window::WIN_BLACKMAN_HARRIS) // 5
+ .value("WIN_BARTLETT", gr::fft::window::WIN_BARTLETT) // 6
+ .value("WIN_FLATTOP", gr::fft::window::WIN_FLATTOP) // 7
+ .export_values();
+}
diff --git a/gr-fft/python/fft/logpwrfft.py b/gr-fft/python/fft/logpwrfft.py
index f823cfd6c..8ae76489d 100644
--- a/gr-fft/python/fft/logpwrfft.py
+++ b/gr-fft/python/fft/logpwrfft.py
@@ -13,8 +13,8 @@ from gnuradio import gr
from gnuradio import blocks
import sys, math
-from . import fft_swig as fft
-from .fft_swig import window
+from . import fft_python as fft
+from .fft_python import window
try:
from gnuradio import filter
diff --git a/gr-fft/python/fft/qa_fft.py b/gr-fft/python/fft/qa_fft.py
index 34cc302e1..b7d4b1e6d 100644
--- a/gr-fft/python/fft/qa_fft.py
+++ b/gr-fft/python/fft/qa_fft.py
@@ -151,7 +151,7 @@ class test_fft(gr_unittest.TestCase):
(14.7145 - 14.4113j),
(-60.0053 + 114.7418j),
(-440.1561 - 1632.9807j))
- window = fft.window_hamming(ntaps=self.fft_size)
+ window = fft.window.hamming(ntaps=self.fft_size)
src = blocks.vector_source_c(src_data)
s2v = blocks.stream_to_vector(gr.sizeof_gr_complex, self.fft_size)
@@ -197,7 +197,7 @@ class test_fft(gr_unittest.TestCase):
(-22.2144 - 20.0343j),
(17.0359 + 17.6910j),
(-91.8955 - 103.1093j))
- window = fft.window_hamming(ntaps=self.fft_size)
+ window = fft.window.hamming(ntaps=self.fft_size)
src = blocks.vector_source_c(src_data)
s2v = blocks.stream_to_vector(gr.sizeof_gr_complex, self.fft_size)