shithub: aubio

Download patch

ref: 913a7f1ce68a6a1cb25ed900aaf2fe2b4eeb9ce9
parent: 100ef1457c1823fffd24a871181ce6e4de56527c
author: Paul Brossier <piem@piem.org>
date: Thu Jul 9 20:10:57 EDT 2015

python/ext/py-musicutils.{c,h}: first .c and test

--- a/python/ext/aubiomodule.c
+++ b/python/ext/aubiomodule.c
@@ -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 @@
   {"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 */
 };
 
--- /dev/null
+++ b/python/ext/py-musicutils.c
@@ -1,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;
+}
--- /dev/null
+++ b/python/ext/py-musicutils.h
@@ -1,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_ */
--- a/python/setup.py
+++ b/python/setup.py
@@ -46,6 +46,7 @@
     "ext/aubiomodule.c",
     "ext/aubioproxy.c",
     "ext/ufuncs.c",
+    "ext/py-musicutils.c",
     "ext/py-cvec.c",
     # example without macro
     "ext/py-filter.c",
--- /dev/null
+++ b/python/tests/test_musicutils.py
@@ -1,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()