History

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

Paul Brossier committed 11 years ago

Commit 913a7f11 parent 100ef145 files · +51 −0Browse files

Showing the changes to python (5 of 5 files). Show all

Unified · Split

5 files
  1. python/ext/aubiomodule.c +2 −0
  2. python/ext/py-musicutils.c +19 −0
  3. python/ext/py-musicutils.h +16 −0
  4. python/setup.py +1 −0
  5. python/tests/test_musicutils.py +13 −0
python/ext/aubiomodule.c+2−0
@@ -1,6 +1,7 @@
11 #define PY_AUBIO_MODULE_MAIN
22 #include "aubio-types.h"
33 #include "aubio-generated.h"
4+#include "py-musicutils.h"
45
56 static char aubio_module_doc[] = "Python module for the aubio library";
67
@@ -239,6 +240,7 @@ static PyMethodDef aubio_methods[] = { · 232 unmodified lines
239240 {"alpha_norm", Py_alpha_norm, METH_VARARGS, Py_alpha_norm_doc},
240241 {"zero_crossing_rate", Py_zero_crossing_rate, METH_VARARGS, Py_zero_crossing_rate_doc},
241242 {"min_removal", Py_min_removal, METH_VARARGS, Py_min_removal_doc},
243+ {"window", Py_aubio_window, METH_VARARGS, Py_aubio_window_doc},
242244 {NULL, NULL} /* Sentinel */
243245 };
244246
python/ext/py-musicutils.c+19−0
@@ -0,0 +1,19 @@
1+#include "aubio-types.h"
2+
3+PyObject *
4+Py_aubio_window(PyObject *self, PyObject *args)
5+{
6+ PyObject *output = NULL;
7+ char_t *wintype = NULL;
8+ uint_t winlen = 0;
9+ fvec_t *window;
10+
11+ if (!PyArg_ParseTuple (args, "|sd", &wintype, &winlen)) {
12+ PyErr_SetString (PyExc_ValueError,
13+ "failed parsing arguments");
14+ return NULL;
15+ }
16+
17+ //return (PyObject *) PyAubio_CFvecToArray(vec);
18+ Py_RETURN_NONE;
19+}
python/ext/py-musicutils.h+16−0
@@ -0,0 +1,16 @@
1+#ifndef _PY_AUBIO_MUSICUTILS_H_
2+#define _PY_AUBIO_MUSICUTILS_H_
3+
4+static char Py_aubio_window_doc[] = ""
5+"window(string, integer) -> fvec\n"
6+"\n"
7+"Create a window\n"
8+"\n"
9+"Example\n"
10+"-------\n"
11+"\n"
12+">>> window('hanningz', 1024)";
13+
14+PyObject * Py_aubio_window(PyObject *self, PyObject *args);
15+
16+#endif /* _PY_AUBIO_MUSICUTILS_H_ */
python/setup.py+1−0
@@ -46,6 +46,7 @@ aubio_extension = Extension("aubio._aubio", [ · 45 unmodified lines
4646 "ext/aubiomodule.c",
4747 "ext/aubioproxy.c",
4848 "ext/ufuncs.c",
49+ "ext/py-musicutils.c",
4950 "ext/py-cvec.c",
5051 # example without macro
5152 "ext/py-filter.c",
python/tests/test_musicutils.py+13−0
@@ -0,0 +1,13 @@
1+#! /usr/bin/env python
2+
3+from numpy.testing import TestCase
4+from aubio import window
5+
6+class aubio_window(TestCase):
7+
8+ def test_accept_name_and_size(self):
9+ window("default", 1024)
10+
11+if __name__ == '__main__':
12+ from unittest import main
13+ main()

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t