summaryrefslogtreecommitdiff
path: root/gr-audio/python/audio
diff options
context:
space:
mode:
Diffstat (limited to 'gr-audio/python/audio')
-rw-r--r--gr-audio/python/audio/CMakeLists.txt3
-rw-r--r--gr-audio/python/audio/__init__.py8
-rw-r--r--gr-audio/python/audio/bindings/CMakeLists.txt18
-rw-r--r--gr-audio/python/audio/bindings/docstrings/sink_pydoc_template.h24
-rw-r--r--gr-audio/python/audio/bindings/docstrings/source_pydoc_template.h24
-rw-r--r--gr-audio/python/audio/bindings/python_bindings.cc44
-rw-r--r--gr-audio/python/audio/bindings/sink_python.cc47
-rw-r--r--gr-audio/python/audio/bindings/source_python.cc50
8 files changed, 213 insertions, 5 deletions
diff --git a/gr-audio/python/audio/CMakeLists.txt b/gr-audio/python/audio/CMakeLists.txt
index bf1204ab8b..cc195dd062 100644
--- a/gr-audio/python/audio/CMakeLists.txt
+++ b/gr-audio/python/audio/CMakeLists.txt
@@ -23,7 +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
)
include(GrTest)
@@ -33,3 +32,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-audio/python/audio/__init__.py b/gr-audio/python/audio/__init__.py
index 435d7c591e..831311e9e4 100644
--- a/gr-audio/python/audio/__init__.py
+++ b/gr-audio/python/audio/__init__.py
@@ -18,8 +18,8 @@ from __future__ import unicode_literals
import os
try:
- from .audio_swig import *
+ from .audio_python import *
except ImportError:
- dirname, filename = os.path.split(os.path.abspath(__file__))
- __path__.append(os.path.join(dirname, "..", "..", "swig"))
- from .audio_swig import *
+ dirname, filename = os.path.split(os.path.abspath(__file__))
+ __path__.append(os.path.join(dirname, "bindings"))
+ from .audio_python import *
diff --git a/gr-audio/python/audio/bindings/CMakeLists.txt b/gr-audio/python/audio/bindings/CMakeLists.txt
new file mode 100644
index 0000000000..24ad0551f3
--- /dev/null
+++ b/gr-audio/python/audio/bindings/CMakeLists.txt
@@ -0,0 +1,18 @@
+include(GrPybind)
+
+########################################################################
+# Python Bindings
+########################################################################
+
+list(APPEND audio_python_files
+ # osx_impl_python.cc
+ sink_python.cc
+ source_python.cc
+ python_bindings.cc)
+
+GR_PYBIND_MAKE_CHECK_HASH(audio
+ ../../..
+ gr::audio
+ "${audio_python_files}")
+
+install(TARGETS audio_python DESTINATION ${GR_PYTHON_DIR}/gnuradio/audio COMPONENT pythonapi)
diff --git a/gr-audio/python/audio/bindings/docstrings/sink_pydoc_template.h b/gr-audio/python/audio/bindings/docstrings/sink_pydoc_template.h
new file mode 100644
index 0000000000..3abdde8e8f
--- /dev/null
+++ b/gr-audio/python/audio/bindings/docstrings/sink_pydoc_template.h
@@ -0,0 +1,24 @@
+/*
+ * 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, audio, __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_audio_sink = R"doc()doc";
+
+
+static const char* __doc_gr_audio_sink_sink = R"doc()doc";
+
+
+static const char* __doc_gr_audio_sink_make = R"doc()doc";
diff --git a/gr-audio/python/audio/bindings/docstrings/source_pydoc_template.h b/gr-audio/python/audio/bindings/docstrings/source_pydoc_template.h
new file mode 100644
index 0000000000..9e721fbeaf
--- /dev/null
+++ b/gr-audio/python/audio/bindings/docstrings/source_pydoc_template.h
@@ -0,0 +1,24 @@
+/*
+ * 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, audio, __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_audio_source = R"doc()doc";
+
+
+static const char* __doc_gr_audio_source_source = R"doc()doc";
+
+
+static const char* __doc_gr_audio_source_make = R"doc()doc";
diff --git a/gr-audio/python/audio/bindings/python_bindings.cc b/gr-audio/python/audio/bindings/python_bindings.cc
new file mode 100644
index 0000000000..d9b302fe3f
--- /dev/null
+++ b/gr-audio/python/audio/bindings/python_bindings.cc
@@ -0,0 +1,44 @@
+
+/*
+ * 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_osx_impl(py::module&);
+void bind_sink(py::module&);
+void bind_source(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(audio_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_osx_impl(m);
+ bind_sink(m);
+ bind_source(m);
+}
diff --git a/gr-audio/python/audio/bindings/sink_python.cc b/gr-audio/python/audio/bindings/sink_python.cc
new file mode 100644
index 0000000000..da062a56b3
--- /dev/null
+++ b/gr-audio/python/audio/bindings/sink_python.cc
@@ -0,0 +1,47 @@
+/*
+ * 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 and can be manually edited */
+/* The following lines can be configured to regenerate this file during cmake */
+/* If manual edits are made, the following tags should be modified accordingly. */
+/* BINDTOOL_GEN_AUTOMATIC(0) */
+/* BINDTOOL_USE_PYGCCXML(0) */
+/* BINDTOOL_HEADER_FILE(sink.h) */
+/* BINDTOOL_HEADER_FILE_HASH(656d21133902e8ba6177998cb10c59a3) */
+/***********************************************************************************/
+
+#include <pybind11/complex.h>
+#include <pybind11/pybind11.h>
+#include <pybind11/stl.h>
+
+namespace py = pybind11;
+
+#include <gnuradio/audio/sink.h>
+// pydoc.h is automatically generated in the build directory
+#include <sink_pydoc.h>
+
+void bind_sink(py::module& m)
+{
+
+ using sink = ::gr::audio::sink;
+
+
+ py::class_<sink, gr::sync_block, gr::block, gr::basic_block, std::shared_ptr<sink>>(
+ m, "sink", D(sink))
+
+ .def(py::init(&sink::make),
+ py::arg("sampling_rate"),
+ py::arg("device_name") = "",
+ py::arg("ok_to_block") = true,
+ D(sink, make))
+
+
+ ;
+}
diff --git a/gr-audio/python/audio/bindings/source_python.cc b/gr-audio/python/audio/bindings/source_python.cc
new file mode 100644
index 0000000000..e6672e0b35
--- /dev/null
+++ b/gr-audio/python/audio/bindings/source_python.cc
@@ -0,0 +1,50 @@
+/*
+ * 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 and can be manually edited */
+/* The following lines can be configured to regenerate this file during cmake */
+/* If manual edits are made, the following tags should be modified accordingly. */
+/* BINDTOOL_GEN_AUTOMATIC(0) */
+/* BINDTOOL_USE_PYGCCXML(0) */
+/* BINDTOOL_HEADER_FILE(source.h) */
+/* BINDTOOL_HEADER_FILE_HASH(25caec545d837656eb133c4bdccb7521) */
+/***********************************************************************************/
+
+#include <pybind11/complex.h>
+#include <pybind11/pybind11.h>
+#include <pybind11/stl.h>
+
+namespace py = pybind11;
+
+#include <gnuradio/audio/source.h>
+// pydoc.h is automatically generated in the build directory
+#include <source_pydoc.h>
+
+void bind_source(py::module& m)
+{
+
+ using source = ::gr::audio::source;
+
+
+ py::class_<source,
+ gr::sync_block,
+ gr::block,
+ gr::basic_block,
+ std::shared_ptr<source>>(m, "source", D(source))
+
+ .def(py::init(&source::make),
+ py::arg("sampling_rate"),
+ py::arg("device_name") = "",
+ py::arg("ok_to_block") = true,
+ D(source, make))
+
+
+ ;
+}