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 @@
1#define PY_AUBIO_MODULE_MAIN1#define PY_AUBIO_MODULE_MAIN
2#include "aubio-types.h"2#include "aubio-types.h"
3#include "aubio-generated.h"3#include "aubio-generated.h"
4#include "py-musicutils.h"
4 5
5static char aubio_module_doc[] = "Python module for the aubio library";6static char aubio_module_doc[] = "Python module for the aubio library";
6 7
@@ -239,6 +240,7 @@ static PyMethodDef aubio_methods[] = { · 232 unmodified lines
239 {"alpha_norm", Py_alpha_norm, METH_VARARGS, Py_alpha_norm_doc},240 {"alpha_norm", Py_alpha_norm, METH_VARARGS, Py_alpha_norm_doc},
240 {"zero_crossing_rate", Py_zero_crossing_rate, METH_VARARGS, Py_zero_crossing_rate_doc},241 {"zero_crossing_rate", Py_zero_crossing_rate, METH_VARARGS, Py_zero_crossing_rate_doc},
241 {"min_removal", Py_min_removal, METH_VARARGS, Py_min_removal_doc},242 {"min_removal", Py_min_removal, METH_VARARGS, Py_min_removal_doc},
243 {"window", Py_aubio_window, METH_VARARGS, Py_aubio_window_doc},
242 {NULL, NULL} /* Sentinel */244 {NULL, NULL} /* Sentinel */
243};245};
244 246
python/ext/py-musicutils.c+19−0
@@ -0,0 +1,19 @@
1#include "aubio-types.h"
2
3PyObject *
4Py_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
4static 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
14PyObject * 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
46 "ext/aubiomodule.c",46 "ext/aubiomodule.c",
47 "ext/aubioproxy.c",47 "ext/aubioproxy.c",
48 "ext/ufuncs.c",48 "ext/ufuncs.c",
49 "ext/py-musicutils.c",
49 "ext/py-cvec.c",50 "ext/py-cvec.c",
50 # example without macro51 # example without macro
51 "ext/py-filter.c",52 "ext/py-filter.c",
python/tests/test_musicutils.py+13−0
@@ -0,0 +1,13 @@
1#! /usr/bin/env python
2
3from numpy.testing import TestCase
4from aubio import window
5
6class aubio_window(TestCase):
7
8 def test_accept_name_and_size(self):
9 window("default", 1024)
10
11if __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