From 913a7f1ce68a6a1cb25ed900aaf2fe2b4eeb9ce9 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Fri, 10 Jul 2015 00:10:57 +0200 Subject: [PATCH] python/ext/py-musicutils.{c,h}: first .c and test --- python/ext/aubiomodule.c | 2 ++ python/ext/py-musicutils.c | 19 +++++++++++++++++++ python/ext/py-musicutils.h | 16 ++++++++++++++++ python/setup.py | 1 + python/tests/test_musicutils.py | 13 +++++++++++++ 5 files changed, 51 insertions(+) create mode 100644 python/ext/py-musicutils.c create mode 100644 python/ext/py-musicutils.h create mode 100755 python/tests/test_musicutils.py diff --git a/python/ext/aubiomodule.c b/python/ext/aubiomodule.c index 1db715af..a54a0cbf 100644 --- 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 @@ 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 index 00000000..e50939db --- /dev/null +++ b/python/ext/py-musicutils.c @@ -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 index 00000000..ed15a023 --- /dev/null +++ b/python/ext/py-musicutils.h @@ -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_ */ diff --git a/python/setup.py b/python/setup.py index caf3eabf..7c8fd24b 100755 --- a/python/setup.py +++ b/python/setup.py @@ -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 index 00000000..acbe08a5 --- /dev/null +++ b/python/tests/test_musicutils.py @@ -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() -- 2.11.0