diff --git a/PyAutoTuner.c b/PyAutoTuner.c index d9cf24e..28d2170 100644 --- a/PyAutoTuner.c +++ b/PyAutoTuner.c @@ -27,44 +27,41 @@ static PyObject *Tuner(PyObject *self, PyObject *args) { - float *signal, *buffer, concert_a, fixed_pitch, fixed_pull, corr_str, corr_smooth, pitch_shift, lfo_depth, lfo_rate, lfo_shape, lfo_symm, form_warp, mix; - + float *buffer, concert_a, fixed_pitch, fixed_pull, corr_str, corr_smooth, pitch_shift, lfo_depth, lfo_rate, lfo_shape, lfo_symm, form_warp, mix; char *key; + int fs, FrameSize, scale_rotate, lfo_quant, form_corr; + PyArrayObject *arr; + PyObject *In_object; - int fs, FrameSize, zz, i, scale_rotate, lfo_quant, form_corr; - PyObject *obj; - PyArrayObject *arr; - if (!PyArg_ParseTuple(args, "s#iiiiiffffffffffffc", &signal,&zz,&fs,&FrameSize,&scale_rotate,&lfo_quant,&form_corr,&concert_a,&fixed_pitch,&fixed_pull,&corr_str,&corr_smooth,&pitch_shift,&lfo_depth,&lfo_rate,&lfo_shape,&lfo_symm,&form_warp,&mix,&key)) + if (!PyArg_ParseTuple(args, "Oiiiiiffffffffffffc", &In_object,&fs,&FrameSize,&scale_rotate,&lfo_quant,&form_corr,&concert_a,&fixed_pitch,&fixed_pull,&corr_str,&corr_smooth,&pitch_shift,&lfo_depth,&lfo_rate,&lfo_shape,&lfo_symm,&form_warp,&mix,&key)) return NULL; + npy_intp ArrLen[1]={FrameSize}; + Py_BEGIN_ALLOW_THREADS; instantiateAutotalentInstance(fs); - buffer = (float*)malloc(FrameSize*sizeof(float)); - - if (!buffer) { - printf("\nError: No memory\n"); - exit(1); - } + PyArrayObject *x_array = PyArray_FROM_OTF(In_object, NPY_FLOAT, NPY_IN_ARRAY); + if (x_array == NULL) { + Py_XDECREF(x_array); + return NULL; + } + buffer = (float*)PyArray_DATA(x_array); initializeAutotalent(&concert_a, &key, &fixed_pitch, &fixed_pull, &corr_str, &corr_smooth, &pitch_shift, &scale_rotate, &lfo_depth, &lfo_rate, &lfo_shape, &lfo_symm, &lfo_quant, &form_corr, &form_warp, &mix); - for(i=0; i