Changeset 9b23eb31 for interfaces/python
- Timestamp:
- Oct 6, 2009, 2:49:53 AM (15 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- f826349
- Parents:
- 998a8be
- Location:
- interfaces/python
- Files:
-
- 3 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
interfaces/python/aubio-types.h
r998a8be r9b23eb31 5 5 #include <aubio.h> 6 6 7 #define Py_fvec_default_length 1024 8 #define Py_fvec_default_channels 1 7 #define Py_default_vector_length 1024 8 #define Py_default_vector_channels 1 9 10 #define Py_aubio_default_samplerate 44100 9 11 10 12 #ifdef HAVE_AUBIO_DOUBLE … … 25 27 typedef struct 26 28 { 27 PyObject_HEAD fvec_t * o; 29 PyObject_HEAD 30 fvec_t * o; 28 31 uint_t length; 29 32 uint_t channels; … … 31 34 extern PyTypeObject Py_fvecType; 32 35 36 extern PyTypeObject Py_cvecType; 37 38 extern PyTypeObject Py_filterType; 39 33 40 extern PyObject *PyAubio_FvecToArray (Py_fvec * self); 34 41 -
interfaces/python/aubiomodule.c
r998a8be r9b23eb31 97 97 //return Py_None; 98 98 // however it is convenient to return the modified vector 99 //return (PyObject *) PyAubio_FvecToArray(vec);99 return (PyObject *) PyAubio_FvecToArray(vec); 100 100 // or even without converting it back to an array 101 Py_INCREF(vec);102 return (PyObject *)vec;101 //Py_INCREF(vec); 102 //return (PyObject *)vec; 103 103 } 104 105 106 107 104 108 105 static PyMethodDef aubio_methods[] = { … … 122 119 int err; 123 120 124 if (PyType_Ready (&Py_fvecType) < 0) { 121 if ((PyType_Ready (&Py_fvecType) < 0) || 122 (PyType_Ready (&Py_cvecType) < 0) || 123 (PyType_Ready (&Py_filterType) < 0)) { 125 124 return; 126 125 } … … 141 140 Py_INCREF (&Py_fvecType); 142 141 PyModule_AddObject (m, "fvec", (PyObject *) & Py_fvecType); 142 Py_INCREF (&Py_cvecType); 143 PyModule_AddObject (m, "cvec", (PyObject *) & Py_cvecType); 144 Py_INCREF (&Py_filterType); 145 PyModule_AddObject (m, "digital_filter", (PyObject *) & Py_filterType); 143 146 } -
interfaces/python/py-fvec.c
r998a8be r9b23eb31 28 28 self = (Py_fvec *) type->tp_alloc (type, 0); 29 29 30 self->length = Py_ fvec_default_length;31 self->channels = Py_ fvec_default_channels;30 self->length = Py_default_vector_length; 31 self->channels = Py_default_vector_channels; 32 32 33 33 if (self == NULL) { … … 51 51 } 52 52 53 54 53 return (PyObject *) self; 55 54 } … … 89 88 goto fail; 90 89 } 90 fvec_print ( self->o ); 91 91 92 92 result = PyString_Format (format, args); … … 97 97 98 98 return result; 99 }100 101 static PyObject *102 Py_fvec_print (Py_fvec * self, PyObject * unused)103 {104 fvec_print (self->o);105 return Py_None;106 99 } 107 100 … … 111 104 Py_fvec *vec; 112 105 uint_t i; 106 if (input == NULL) { 107 PyErr_SetString (PyExc_ValueError, "input array is not a python object"); 108 goto fail; 109 } 113 110 // parsing input object into a Py_fvec 114 111 if (PyObject_TypeCheck (input, &Py_fvecType)) { … … 267 264 268 265 static PyMethodDef Py_fvec_methods[] = { 269 {"dump", (PyCFunction) Py_fvec_print, METH_NOARGS,270 "Dumps the contents of the vector to stdout."},271 266 {"__array__", (PyCFunction) PyAubio_FvecToArray, METH_NOARGS, 272 267 "Returns the first channel as a numpy array."}, -
interfaces/python/setup.py
r998a8be r9b23eb31 4 4 ext_modules = [ 5 5 Extension("_aubio", 6 ["aubiomodule.c", "py-fvec.c" ],6 ["aubiomodule.c", "py-fvec.c", "py-cvec.c", "py-filter.c"], 7 7 include_dirs=['../../build/default/src', '../../src' ], 8 8 library_dirs=['../../build/default/src', '../../src/.libs' ], -
interfaces/python/test_aubio.py
r998a8be r9b23eb31 1 1 from numpy.testing import TestCase, run_module_suite 2 from numpy.testing import assert_equal as numpy_assert_equal2 from numpy.testing import assert_equal 3 3 from _aubio import * 4 4 from numpy import array 5 5 6 6 AUBIO_DO_CASTING = 0 7 8 def assert_equal(a, b):9 numpy_assert_equal(array(a),array(b))10 7 11 8 class aubiomodule_test_case(TestCase):
Note: See TracChangeset
for help on using the changeset viewer.