Showing the changes to python (3 of 3 files). Show all
Unified · Split
| @@ -242,6 +242,8 @@ static PyMethodDef aubio_methods[] = { · 241 unmodified lines | ||
| 242 | 242 | {"silence_detection", Py_aubio_silence_detection, METH_VARARGS, Py_aubio_silence_detection_doc}, |
| 243 | 243 | {"level_detection", Py_aubio_level_detection, METH_VARARGS, Py_aubio_level_detection_doc}, |
| 244 | 244 | {"window", Py_aubio_window, METH_VARARGS, Py_aubio_window_doc}, |
| 245 | + {"shift", Py_aubio_shift, METH_VARARGS, Py_aubio_shift_doc}, | |
| 246 | + {"ishift", Py_aubio_ishift, METH_VARARGS, Py_aubio_ishift_doc}, | |
| 245 | 247 | {NULL, NULL, 0, NULL} /* Sentinel */ |
| 246 | 248 | }; |
| 247 | 249 | |
| @@ -133,3 +133,51 @@ Py_aubio_level_detection(PyObject *self, PyObject *args) · 132 unmodified lines | ||
| 133 | 133 | |
| 134 | 134 | return level_detection; |
| 135 | 135 | } |
| 136 | + | |
| 137 | +PyObject * | |
| 138 | +Py_aubio_shift(PyObject *self, PyObject *args) | |
| 139 | +{ | |
| 140 | + PyObject *input; | |
| 141 | + fvec_t vec; | |
| 142 | + | |
| 143 | + if (!PyArg_ParseTuple (args, "O:shift", &input)) { | |
| 144 | + return NULL; | |
| 145 | + } | |
| 146 | + | |
| 147 | + if (input == NULL) { | |
| 148 | + return NULL; | |
| 149 | + } | |
| 150 | + | |
| 151 | + if (!PyAubio_ArrayToCFvec(input, &vec)) { | |
| 152 | + return NULL; | |
| 153 | + } | |
| 154 | + | |
| 155 | + fvec_shift(&vec); | |
| 156 | + | |
| 157 | + //Py_RETURN_NONE; | |
| 158 | + return (PyObject *) PyAubio_CFvecToArray(&vec); | |
| 159 | +} | |
| 160 | + | |
| 161 | +PyObject * | |
| 162 | +Py_aubio_ishift(PyObject *self, PyObject *args) | |
| 163 | +{ | |
| 164 | + PyObject *input; | |
| 165 | + fvec_t vec; | |
| 166 | + | |
| 167 | + if (!PyArg_ParseTuple (args, "O:shift", &input)) { | |
| 168 | + return NULL; | |
| 169 | + } | |
| 170 | + | |
| 171 | + if (input == NULL) { | |
| 172 | + return NULL; | |
| 173 | + } | |
| 174 | + | |
| 175 | + if (!PyAubio_ArrayToCFvec(input, &vec)) { | |
| 176 | + return NULL; | |
| 177 | + } | |
| 178 | + | |
| 179 | + fvec_ishift(&vec); | |
| 180 | + | |
| 181 | + //Py_RETURN_NONE; | |
| 182 | + return (PyObject *) PyAubio_CFvecToArray(&vec); | |
| 183 | +} | |
| @@ -71,4 +71,34 @@ static char Py_aubio_level_detection_doc[] = "" · 70 unmodified lines | ||
| 71 | 71 | |
| 72 | 72 | PyObject * Py_aubio_level_detection(PyObject *self, PyObject *args); |
| 73 | 73 | |
| 74 | +static char Py_aubio_shift_doc[] = "" | |
| 75 | +"Swap left and right partitions of a vector\n" | |
| 76 | +"\n" | |
| 77 | +"Returns the swapped vector. The input vector is also modified.\n" | |
| 78 | +"\n" | |
| 79 | +"For a vector of length N, the partition is split at index N - N//2.\n" | |
| 80 | +"\n" | |
| 81 | +"Example\n" | |
| 82 | +"-------\n" | |
| 83 | +"\n" | |
| 84 | +">>> import numpy\n" | |
| 85 | +">>> shift(numpy.arange(3, dtype=aubio.float_type))\n" | |
| 86 | +"array([2., 0., 1.], dtype=" AUBIO_NPY_SMPL_STR ")"; | |
| 87 | +PyObject * Py_aubio_shift(PyObject *self, PyObject *args); | |
| 88 | + | |
| 89 | +static char Py_aubio_ishift_doc[] = "" | |
| 90 | +"Swap right and left partitions of a vector\n" | |
| 91 | +"\n" | |
| 92 | +"Returns the swapped vector. The input vector is also modified.\n" | |
| 93 | +"\n" | |
| 94 | +"Unlike with shift(), the partition is split at index N//2.\n" | |
| 95 | +"\n" | |
| 96 | +"Example\n" | |
| 97 | +"-------\n" | |
| 98 | +"\n" | |
| 99 | +">>> import numpy\n" | |
| 100 | +">>> ishift(numpy.arange(3, dtype=aubio.float_type))\n" | |
| 101 | +"array([1., 2., 0.], dtype=" AUBIO_NPY_SMPL_STR ")"; | |
| 102 | +PyObject * Py_aubio_ishift(PyObject *self, PyObject *args); | |
| 103 | + | |
| 74 | 104 | #endif /* PY_AUBIO_MUSICUTILS_H */ |