return NULL;
}
- vec = PyAubio_ArrayToCFvec (input);
-
- if (vec == NULL) {
+ vec = (fvec_t *)malloc(sizeof(fvec_t));
+ if (!PyAubio_ArrayToCFvec(input, vec)) {
+ free(vec);
return NULL;
}
// compute the function
result = Py_BuildValue ("f", fvec_alpha_norm (vec, alpha));
+ free(vec);
if (result == NULL) {
return NULL;
}
return NULL;
}
- vec = PyAubio_ArrayToCFvec (input);
-
- if (vec == NULL) {
+ vec = (fvec_t *)malloc(sizeof(fvec_t));
+ if (!PyAubio_ArrayToCFvec(input, vec)) {
+ free(vec);
return NULL;
}
// compute the function
result = Py_BuildValue ("f", aubio_zero_crossing_rate (vec));
+ free(vec);
if (result == NULL) {
return NULL;
}
return NULL;
}
- vec = PyAubio_ArrayToCFvec (input);
-
- if (vec == NULL) {
+ vec = (fvec_t *)malloc(sizeof(fvec_t));
+ if (!PyAubio_ArrayToCFvec(input, vec)) {
+ free(vec);
return NULL;
}
PyObject_HEAD
aubio_fft_t * o;
uint_t win_s;
+ fvec_t *vecin;
cvec_t *out;
+ Py_cvec *py_out;
+ cvec_t *cvecin;
fvec_t *rout;
} Py_fft;
PyErr_SetString (PyExc_Exception, errstr);
return -1;
}
+
+ self->cvecin = (cvec_t *)malloc(sizeof(cvec_t));
+ self->vecin = (fvec_t *)malloc(sizeof(fvec_t));
+
self->out = new_cvec(self->win_s);
+ self->py_out = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType);
+ Py_XINCREF(self->py_out);
self->rout = new_fvec(self->win_s);
return 0;
static void
Py_fft_del (Py_fft *self, PyObject *unused)
{
+ Py_XDECREF((PyObject*)(self->py_out));
del_aubio_fft(self->o);
del_cvec(self->out);
del_fvec(self->rout);
+ free(self->cvecin);
+ free(self->vecin);
Py_TYPE(self)->tp_free((PyObject *) self);
}
-static PyObject *
+static PyObject *
Py_fft_do(Py_fft * self, PyObject * args)
{
PyObject *input;
- fvec_t *vec;
if (!PyArg_ParseTuple (args, "O", &input)) {
return NULL;
}
- vec = PyAubio_ArrayToCFvec (input);
-
- if (vec == NULL) {
+ if (!PyAubio_ArrayToCFvec(input, self->vecin)) {
return NULL;
}
// compute the function
- aubio_fft_do (((Py_fft *)self)->o, vec, self->out);
- return (PyObject *)PyAubio_CCvecToPyCvec(self->out);
+ aubio_fft_do (((Py_fft *)self)->o, self->vecin, self->out);
+#if 0
+ Py_cvec * py_out = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType);
+ PyObject* output = PyAubio_CCvecToPyCvec(self->out, py_out);
+ return output;
+#else
+ // convert cvec to py_cvec, incrementing refcount to keep a copy
+ return PyAubio_CCvecToPyCvec(self->out, self->py_out);
+#endif
}
static PyMemberDef Py_fft_members[] = {
{NULL}
};
-static PyObject *
+static PyObject *
Py_fft_rdo(Py_fft * self, PyObject * args)
{
PyObject *input;
- cvec_t *vec;
if (!PyArg_ParseTuple (args, "O", &input)) {
return NULL;
}
- vec = PyAubio_ArrayToCCvec (input);
-
- if (vec == NULL) {
+ if (!PyAubio_ArrayToCCvec (input, self->cvecin) ) {
return NULL;
}
// compute the function
- aubio_fft_rdo (((Py_fft *)self)->o, vec, self->rout);
- return (PyObject *)PyAubio_CFvecToArray(self->rout);
+ aubio_fft_rdo (self->o, self->cvecin, self->rout);
+ return PyAubio_CFvecToArray(self->rout);
}
static PyMethodDef Py_fft_methods[] = {
PyObject_HEAD
aubio_filter_t * o;
uint_t order;
+ fvec_t *vec;
fvec_t *out;
} Py_filter;
return -1;
}
self->out = new_fvec(Py_default_vector_length);
+ self->vec = (fvec_t *)malloc(sizeof(fvec_t));
return 0;
}
{
del_fvec(self->out);
del_aubio_filter (self->o);
+ free(self->vec);
Py_TYPE(self)->tp_free ((PyObject *) self);
}
Py_filter_do(Py_filter * self, PyObject * args)
{
PyObject *input;
- fvec_t *vec;
if (!PyArg_ParseTuple (args, "O:digital_filter.do", &input)) {
return NULL;
return NULL;
}
- vec = PyAubio_ArrayToCFvec (input);
-
- if (vec == NULL) {
+ if (!PyAubio_ArrayToCFvec(input, self->vec)) {
return NULL;
}
// reallocate the output if needed
- if (vec->length != self->out->length) {
+ if (self->vec->length != self->out->length) {
del_fvec(self->out);
- self->out = new_fvec(vec->length);
+ self->out = new_fvec(self->vec->length);
}
// compute the function
- aubio_filter_do_outplace (self->o, vec, self->out);
+ aubio_filter_do_outplace (self->o, self->vec, self->out);
return PyAubio_CFvecToArray(self->out);
}
aubio_filterbank_t * o;
uint_t n_filters;
uint_t win_s;
+ cvec_t *vec;
fvec_t *out;
+ fvec_t *freqs;
+ fmat_t *coeffs;
} Py_filterbank;
static PyObject *
}
self->out = new_fvec(self->n_filters);
+ self->vec = (cvec_t *)malloc(sizeof(cvec_t));
+
+ self->freqs = (fvec_t *)malloc(sizeof(fvec_t));
+
+ self->coeffs = (fmat_t *)malloc(sizeof(fmat_t));
+ self->coeffs->data = (smpl_t **)malloc(sizeof(smpl_t*) * self->n_filters);
+ self->coeffs->height = self->n_filters;
+
return 0;
}
{
del_aubio_filterbank(self->o);
del_fvec(self->out);
+ free(self->vec);
+ free(self->freqs);
+ free(self->coeffs->data);
+ free(self->coeffs);
Py_TYPE(self)->tp_free((PyObject *) self);
}
Py_filterbank_do(Py_filterbank * self, PyObject * args)
{
PyObject *input;
- cvec_t *vec;
if (!PyArg_ParseTuple (args, "O", &input)) {
return NULL;
}
- vec = PyAubio_ArrayToCCvec (input);
-
- if (vec == NULL) {
+ if (!PyAubio_ArrayToCCvec(input, self->vec)) {
return NULL;
}
// compute the function
- aubio_filterbank_do (self->o, vec, self->out);
+ aubio_filterbank_do (self->o, self->vec, self->out);
return (PyObject *)PyAubio_CFvecToArray(self->out);
}
PyObject *input;
uint_t samplerate;
- fvec_t *freqs;
if (!PyArg_ParseTuple (args, "OI", &input, &samplerate)) {
return NULL;
}
return NULL;
}
- freqs = PyAubio_ArrayToCFvec (input);
-
- if (freqs == NULL) {
+ if (!PyAubio_ArrayToCFvec(input, self->freqs)) {
return NULL;
}
err = aubio_filterbank_set_triangle_bands (self->o,
- freqs, samplerate);
+ self->freqs, samplerate);
if (err > 0) {
PyErr_SetString (PyExc_ValueError,
"error when setting filter to A-weighting");
uint_t err = 0;
PyObject *input;
- fmat_t *coeffs;
-
if (!PyArg_ParseTuple (args, "O", &input)) {
return NULL;
}
- coeffs = PyAubio_ArrayToCFmat (input);
-
- if (coeffs == NULL) {
- PyErr_SetString (PyExc_ValueError,
- "unable to parse input array");
+ if (!PyAubio_ArrayToCFmat(input, self->coeffs)) {
return NULL;
}
- err = aubio_filterbank_set_coeffs (self->o, coeffs);
+ err = aubio_filterbank_set_coeffs (self->o, self->coeffs);
if (err > 0) {
PyErr_SetString (PyExc_ValueError,
return NULL;
}
- vec = PyAubio_ArrayToCFvec (input);
- if (vec == NULL) {
+ vec = (fvec_t *)malloc(sizeof(fvec_t));
+ if (!PyAubio_ArrayToCFvec(input, vec)) {
+ free(vec);
return NULL;
}
level_lin = Py_BuildValue("f", aubio_level_lin(vec));
+ free(vec);
if (level_lin == NULL) {
PyErr_SetString (PyExc_ValueError, "failed computing level_lin");
return NULL;
return NULL;
}
- vec = PyAubio_ArrayToCFvec (input);
- if (vec == NULL) {
+ vec = (fvec_t *)malloc(sizeof(fvec_t));
+ if (!PyAubio_ArrayToCFvec(input, vec)) {
+ free(vec);
return NULL;
}
db_spl = Py_BuildValue("f", aubio_db_spl(vec));
+ free(vec);
if (db_spl == NULL) {
PyErr_SetString (PyExc_ValueError, "failed computing db_spl");
return NULL;
return NULL;
}
- vec = PyAubio_ArrayToCFvec (input);
- if (vec == NULL) {
+ vec = (fvec_t *)malloc(sizeof(fvec_t));
+ if (!PyAubio_ArrayToCFvec(input, vec)) {
+ free(vec);
return NULL;
}
silence_detection = Py_BuildValue("I", aubio_silence_detection(vec, threshold));
+ free(vec);
if (silence_detection == NULL) {
PyErr_SetString (PyExc_ValueError, "failed computing silence_detection");
return NULL;
return NULL;
}
- vec = PyAubio_ArrayToCFvec (input);
- if (vec == NULL) {
+ vec = (fvec_t *)malloc(sizeof(fvec_t));
+ if (!PyAubio_ArrayToCFvec(input, vec)) {
+ free(vec);
return NULL;
}
level_detection = Py_BuildValue("f", aubio_level_detection(vec, threshold));
+ free(vec);
if (level_detection == NULL) {
PyErr_SetString (PyExc_ValueError, "failed computing level_detection");
return NULL;
aubio_pvoc_t * o;
uint_t win_s;
uint_t hop_s;
+ fvec_t *vecin;
cvec_t *output;
+ Py_cvec *py_out;
+ cvec_t *cvecin;
fvec_t *routput;
} Py_pvoc;
return -1;
}
+ self->cvecin = (cvec_t *)malloc(sizeof(cvec_t));
+ self->vecin = (fvec_t *)malloc(sizeof(fvec_t));
+
self->output = new_cvec(self->win_s);
+ self->py_out = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType);
self->routput = new_fvec(self->hop_s);
return 0;
del_aubio_pvoc(self->o);
del_cvec(self->output);
del_fvec(self->routput);
+ free(self->cvecin);
+ free(self->vecin);
Py_TYPE(self)->tp_free((PyObject *) self);
}
-static PyObject *
+static PyObject *
Py_pvoc_do(Py_pvoc * self, PyObject * args)
{
PyObject *input;
- fvec_t *vec;
if (!PyArg_ParseTuple (args, "O", &input)) {
return NULL;
}
- vec = PyAubio_ArrayToCFvec (input);
-
- if (vec == NULL) {
+ if (!PyAubio_ArrayToCFvec (input, self->vecin)) {
return NULL;
}
// compute the function
- aubio_pvoc_do (self->o, vec, self->output);
- return (PyObject *)PyAubio_CCvecToPyCvec(self->output);
+ aubio_pvoc_do (self->o, self->vecin, self->output);
+#if 0
+ Py_cvec * py_out = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType);
+ PyObject* output = PyAubio_CCvecToPyCvec(self->output, py_out);
+ return output;
+#else
+ // convert cvec to py_cvec, incrementing refcount to keep a copy
+ return PyAubio_CCvecToPyCvec(self->output, self->py_out);
+#endif
}
static PyMemberDef Py_pvoc_members[] = {
Py_pvoc_rdo(Py_pvoc * self, PyObject * args)
{
PyObject *input;
- cvec_t *vec;
if (!PyArg_ParseTuple (args, "O", &input)) {
return NULL;
}
- vec = PyAubio_ArrayToCCvec (input);
-
- if (vec == NULL) {
+ if (!PyAubio_ArrayToCCvec (input, self->cvecin)) {
return NULL;
}
// compute the function
- aubio_pvoc_rdo (self->o, vec, self->routput);
- return (PyObject *)PyAubio_CFvecToArray(self->routput);
+ aubio_pvoc_rdo (self->o, self->cvecin, self->routput);
+ return PyAubio_CFvecToArray(self->routput);
}
static PyMethodDef Py_pvoc_methods[] = {
char_t* uri;
uint_t samplerate;
uint_t channels;
+ fvec_t *write_data;
+ fmat_t *mwrite_data;
} Py_sink;
static char Py_sink_doc[] = ""
self->samplerate = aubio_sink_get_samplerate ( self->o );
self->channels = aubio_sink_get_channels ( self->o );
+ self->write_data = (fvec_t *)malloc(sizeof(fvec_t));
+ self->mwrite_data = (fmat_t *)malloc(sizeof(fmat_t));
+ self->mwrite_data->height = self->channels;
+ self->mwrite_data->data = (smpl_t **)malloc(sizeof(smpl_t*) * self->channels);
return 0;
}
Py_sink_del (Py_sink *self, PyObject *unused)
{
del_aubio_sink(self->o);
+ free(self->write_data);
+ free(self->mwrite_data->data);
+ free(self->mwrite_data);
Py_TYPE(self)->tp_free((PyObject *) self);
}
PyObject * write_data_obj;
/* input vectors prototypes */
- fvec_t* write_data;
uint_t write;
return NULL;
}
-
/* input vectors parsing */
- write_data = PyAubio_ArrayToCFvec (write_data_obj);
-
- if (write_data == NULL) {
+ if (!PyAubio_ArrayToCFvec(write_data_obj, self->write_data)) {
return NULL;
}
-
-
-
/* compute _do function */
- aubio_sink_do (self->o, write_data, write);
+ aubio_sink_do (self->o, self->write_data, write);
Py_RETURN_NONE;
}
PyObject * write_data_obj;
/* input vectors prototypes */
- fmat_t * write_data;
uint_t write;
/* input vectors parsing */
- write_data = PyAubio_ArrayToCFmat (write_data_obj);
-
- if (write_data == NULL) {
+ if (!PyAubio_ArrayToCFmat(write_data_obj, self->mwrite_data)) {
return NULL;
}
-
-
-
-
/* compute _do function */
- aubio_sink_do_multi (self->o, write_data, write);
+ aubio_sink_do_multi (self->o, self->mwrite_data, write);
Py_RETURN_NONE;
}