python/ext/py-musicutils.{c,h}: first .c and test
authorPaul Brossier <piem@piem.org>
Thu, 9 Jul 2015 22:10:57 +0000 (00:10 +0200)
committerPaul Brossier <piem@piem.org>
Thu, 9 Jul 2015 22:10:57 +0000 (00:10 +0200)
python/ext/aubiomodule.c
python/ext/py-musicutils.c [new file with mode: 0644]
python/ext/py-musicutils.h [new file with mode: 0644]
python/setup.py
python/tests/test_musicutils.py [new file with mode: 0755]

index 1db715a..a54a0cb 100644 (file)
@@ -1,6 +1,7 @@
 #define PY_AUBIO_MODULE_MAIN
 #include "aubio-types.h"
 #include "aubio-generated.h"
+#include "py-musicutils.h"
 
 static char aubio_module_doc[] = "Python module for the aubio library";
 
@@ -239,6 +240,7 @@ static PyMethodDef aubio_methods[] = {
   {"alpha_norm", Py_alpha_norm, METH_VARARGS, Py_alpha_norm_doc},
   {"zero_crossing_rate", Py_zero_crossing_rate, METH_VARARGS, Py_zero_crossing_rate_doc},
   {"min_removal", Py_min_removal, METH_VARARGS, Py_min_removal_doc},
+  {"window", Py_aubio_window, METH_VARARGS, Py_aubio_window_doc},
   {NULL, NULL} /* Sentinel */
 };
 
diff --git a/python/ext/py-musicutils.c b/python/ext/py-musicutils.c
new file mode 100644 (file)
index 0000000..e50939d
--- /dev/null
@@ -0,0 +1,19 @@
+#include "aubio-types.h"
+
+PyObject *
+Py_aubio_window(PyObject *self, PyObject *args)
+{
+  PyObject *output = NULL;
+  char_t *wintype = NULL;
+  uint_t winlen = 0;
+  fvec_t *window;
+
+  if (!PyArg_ParseTuple (args, "|sd", &wintype, &winlen)) {
+    PyErr_SetString (PyExc_ValueError,
+        "failed parsing arguments");
+    return NULL;
+  }
+
+  //return (PyObject *) PyAubio_CFvecToArray(vec);
+  Py_RETURN_NONE;
+}
diff --git a/python/ext/py-musicutils.h b/python/ext/py-musicutils.h
new file mode 100644 (file)
index 0000000..ed15a02
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef _PY_AUBIO_MUSICUTILS_H_
+#define _PY_AUBIO_MUSICUTILS_H_
+
+static char Py_aubio_window_doc[] = ""
+"window(string, integer) -> fvec\n"
+"\n"
+"Create a window\n"
+"\n"
+"Example\n"
+"-------\n"
+"\n"
+">>> window('hanningz', 1024)";
+
+PyObject * Py_aubio_window(PyObject *self, PyObject *args);
+
+#endif /* _PY_AUBIO_MUSICUTILS_H_ */
index caf3eab..7c8fd24 100755 (executable)
@@ -46,6 +46,7 @@ aubio_extension = Extension("aubio._aubio", [
     "ext/aubiomodule.c",
     "ext/aubioproxy.c",
     "ext/ufuncs.c",
+    "ext/py-musicutils.c",
     "ext/py-cvec.c",
     # example without macro
     "ext/py-filter.c",
diff --git a/python/tests/test_musicutils.py b/python/tests/test_musicutils.py
new file mode 100755 (executable)
index 0000000..acbe08a
--- /dev/null
@@ -0,0 +1,13 @@
+#! /usr/bin/env python
+
+from numpy.testing import TestCase
+from aubio import window
+
+class aubio_window(TestCase):
+
+    def test_accept_name_and_size(self):
+        window("default", 1024)
+
+if __name__ == '__main__':
+    from unittest import main
+    main()