- Timestamp:
- Apr 24, 2016, 11:45:45 PM (9 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:
- fbcee4f
- Parents:
- 81984a7
- Location:
- python
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
python/ext/aubio-types.h
r81984a7 rc6388f4 34 34 35 35 #if HAVE_AUBIO_DOUBLE 36 # error "Ouch! Python interface for aubio has not been much tested yet."36 #warning "double mode needs love" 37 37 #define AUBIO_NPY_SMPL NPY_DOUBLE 38 #define AUBIO_NPY_SMPL_STR "float64" 39 #define AUBIO_NPY_SMPL_CHR "d" 38 40 #else 39 41 #define AUBIO_NPY_SMPL NPY_FLOAT 42 #define AUBIO_NPY_SMPL_STR "float32" 43 #define AUBIO_NPY_SMPL_CHR "f" 40 44 #endif 41 45 -
python/ext/aubiomodule.c
r81984a7 rc6388f4 88 88 PyObject *result; 89 89 90 if (!PyArg_ParseTuple (args, "O f:alpha_norm", &input, &alpha)) {90 if (!PyArg_ParseTuple (args, "O" AUBIO_NPY_SMPL_CHR ":alpha_norm", &input, &alpha)) { 91 91 return NULL; 92 92 } … … 101 101 102 102 // compute the function 103 result = Py_BuildValue ( "f", fvec_alpha_norm (&vec, alpha));103 result = Py_BuildValue (AUBIO_NPY_SMPL_CHR, fvec_alpha_norm (&vec, alpha)); 104 104 if (result == NULL) { 105 105 return NULL; … … 115 115 smpl_t output; 116 116 117 if (!PyArg_ParseTuple (args, "| fff", &input, &samplerate, &fftsize)) {117 if (!PyArg_ParseTuple (args, "|" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR , &input, &samplerate, &fftsize)) { 118 118 return NULL; 119 119 } … … 130 130 smpl_t output; 131 131 132 if (!PyArg_ParseTuple (args, "| fff", &input, &samplerate, &fftsize)) {132 if (!PyArg_ParseTuple (args, "|" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR , &input, &samplerate, &fftsize)) { 133 133 return NULL; 134 134 } … … 145 145 smpl_t output; 146 146 147 if (!PyArg_ParseTuple (args, "| fff", &input, &samplerate, &fftsize)) {147 if (!PyArg_ParseTuple (args, "|" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR, &input, &samplerate, &fftsize)) { 148 148 return NULL; 149 149 } … … 160 160 smpl_t output; 161 161 162 if (!PyArg_ParseTuple (args, "| fff", &input, &samplerate, &fftsize)) {162 if (!PyArg_ParseTuple (args, "|" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR, &input, &samplerate, &fftsize)) { 163 163 return NULL; 164 164 } … … 189 189 190 190 // compute the function 191 result = Py_BuildValue ( "f", aubio_zero_crossing_rate (&vec));191 result = Py_BuildValue (AUBIO_NPY_SMPL_CHR, aubio_zero_crossing_rate (&vec)); 192 192 if (result == NULL) { 193 193 return NULL; … … 309 309 PyModule_AddObject (m, "sink", (PyObject *) & Py_sinkType); 310 310 311 PyModule_AddStringConstant(m, "float_type", AUBIO_NPY_SMPL_STR); 312 311 313 // add generated objects 312 314 add_generated_objects(m); -
python/ext/aubioproxy.c
r81984a7 rc6388f4 31 31 return 0; 32 32 } else if (PyArray_TYPE ((PyArrayObject *)input) != AUBIO_NPY_SMPL) { 33 PyErr_SetString (PyExc_ValueError, "input array should be float32");33 PyErr_SetString (PyExc_ValueError, "input array should be " AUBIO_NPY_SMPL_STR); 34 34 return 0; 35 35 } … … 74 74 return 1; 75 75 } else { 76 PyErr_SetString (PyExc_ValueError, "input array should be float32");76 PyErr_SetString (PyExc_ValueError, "input array should be aubio.cvec"); 77 77 return 0; 78 78 } … … 120 120 return 0; 121 121 } else if (PyArray_TYPE ((PyArrayObject *)input) != AUBIO_NPY_SMPL) { 122 PyErr_SetString (PyExc_ValueError, "input array should be float32");122 PyErr_SetString (PyExc_ValueError, "input array should be " AUBIO_NPY_SMPL_STR); 123 123 return 0; 124 124 } -
python/ext/py-cvec.c
r81984a7 rc6388f4 94 94 { 95 95 npy_intp dims[] = { self->o->length, 1 }; 96 return PyArray_SimpleNewFromData (1, dims, NPY_FLOAT, self->o->norm);96 return PyArray_SimpleNewFromData (1, dims, AUBIO_NPY_SMPL, self->o->norm); 97 97 } 98 98 … … 102 102 { 103 103 npy_intp dims[] = { self->o->length, 1 }; 104 return PyArray_SimpleNewFromData (1, dims, NPY_FLOAT, self->o->phas);104 return PyArray_SimpleNewFromData (1, dims, AUBIO_NPY_SMPL, self->o->phas); 105 105 } 106 106 -
python/ext/py-musicutils.c
r81984a7 rc6388f4 42 42 } 43 43 44 level_lin = Py_BuildValue( "f", aubio_level_lin(&vec));44 level_lin = Py_BuildValue(AUBIO_NPY_SMPL_CHR, aubio_level_lin(&vec)); 45 45 if (level_lin == NULL) { 46 46 PyErr_SetString (PyExc_ValueError, "failed computing level_lin"); … … 71 71 } 72 72 73 db_spl = Py_BuildValue( "f", aubio_db_spl(&vec));73 db_spl = Py_BuildValue(AUBIO_NPY_SMPL_CHR, aubio_db_spl(&vec)); 74 74 if (db_spl == NULL) { 75 75 PyErr_SetString (PyExc_ValueError, "failed computing db_spl"); … … 88 88 smpl_t threshold; 89 89 90 if (!PyArg_ParseTuple (args, "O f:silence_detection", &input, &threshold)) {90 if (!PyArg_ParseTuple (args, "O" AUBIO_NPY_SMPL_CHR ":silence_detection", &input, &threshold)) { 91 91 PyErr_SetString (PyExc_ValueError, "failed parsing arguments"); 92 92 return NULL; … … 118 118 smpl_t threshold; 119 119 120 if (!PyArg_ParseTuple (args, "O f:level_detection", &input, &threshold)) {120 if (!PyArg_ParseTuple (args, "O" AUBIO_NPY_SMPL_CHR ":level_detection", &input, &threshold)) { 121 121 PyErr_SetString (PyExc_ValueError, "failed parsing arguments"); 122 122 return NULL; … … 131 131 } 132 132 133 level_detection = Py_BuildValue( "f", aubio_level_detection(&vec, threshold));133 level_detection = Py_BuildValue(AUBIO_NPY_SMPL_CHR, aubio_level_detection(&vec, threshold)); 134 134 if (level_detection == NULL) { 135 135 PyErr_SetString (PyExc_ValueError, "failed computing level_detection"); -
python/lib/gen_code.py
r81984a7 rc6388f4 26 26 'char_t*': 'T_STRING', 27 27 'uint_t': 'T_INT', 28 'smpl_t': ' T_FLOAT',28 'smpl_t': 'AUBIO_NPY_SMPL', 29 29 } 30 30
Note: See TracChangeset
for help on using the changeset viewer.