コード例 #1
0
/* function Py_sink_do */
static PyObject *
Py_sink_do(Py_sink * self, PyObject * args)
{
  /* input vectors python prototypes */
  PyObject * write_data_obj;

  /* input vectors prototypes */
  fvec_t* write_data;
  uint_t write;


  if (!PyArg_ParseTuple (args, "OI", &write_data_obj, &write)) {
    return NULL;
  }


  /* input vectors parsing */
  write_data = PyAubio_ArrayToCFvec (write_data_obj);

  if (write_data == NULL) {
    return NULL;
  }





  /* compute _do function */
  aubio_sink_do (self->o, write_data, write);

  Py_RETURN_NONE;
}
コード例 #2
0
ファイル: py-filter.c プロジェクト: drogenlied/aubio
static PyObject * 
Py_filter_do(Py_filter * self, PyObject * args)
{
  PyObject *input;
  fvec_t *vec;

  if (!PyArg_ParseTuple (args, "O:digital_filter.do", &input)) {
    return NULL;
  }

  if (input == NULL) {
    return NULL;
  }

  vec = PyAubio_ArrayToCFvec (input);

  if (vec == NULL) {
    return NULL;
  }

  // compute the function
  fvec_t * out = new_fvec(vec->length);
  aubio_filter_do_outplace (self->o, vec, out);
  return PyAubio_CFvecToArray(out);
}
コード例 #3
0
ファイル: aubiomodule.c プロジェクト: XunjunYin/aubio
static PyObject *
Py_min_removal(PyObject * self, PyObject * args)
{
  PyObject *input;
  fvec_t vec;

  if (!PyArg_ParseTuple (args, "O:min_removal", &input)) {
    return NULL;
  }

  if (input == NULL) {
    return NULL;
  }

  if (!PyAubio_ArrayToCFvec(input, &vec)) {
    return NULL;
  }

  // compute the function
  fvec_min_removal (&vec);

  // since this function does not return, we could return None
  //Py_RETURN_NONE;
  // however it is convenient to return the modified vector
  return (PyObject *) PyAubio_CFvecToArray(&vec);
  // or even without converting it back to an array
  //Py_INCREF(vec);
  //return (PyObject *)vec;
}
コード例 #4
0
ファイル: aubiomodule.c プロジェクト: XunjunYin/aubio
static PyObject *
Py_alpha_norm (PyObject * self, PyObject * args)
{
  PyObject *input;
  fvec_t vec;
  smpl_t alpha;
  PyObject *result;

  if (!PyArg_ParseTuple (args, "O" AUBIO_NPY_SMPL_CHR ":alpha_norm", &input, &alpha)) {
    return NULL;
  }

  if (input == NULL) {
    return NULL;
  }

  if (!PyAubio_ArrayToCFvec(input, &vec)) {
    return NULL;
  }

  // compute the function
  result = Py_BuildValue (AUBIO_NPY_SMPL_CHR, fvec_alpha_norm (&vec, alpha));
  if (result == NULL) {
    return NULL;
  }

  return result;
}
コード例 #5
0
ファイル: aubiomodule.c プロジェクト: XunjunYin/aubio
static PyObject *
Py_zero_crossing_rate (PyObject * self, PyObject * args)
{
  PyObject *input;
  fvec_t vec;
  PyObject *result;

  if (!PyArg_ParseTuple (args, "O:zero_crossing_rate", &input)) {
    return NULL;
  }

  if (input == NULL) {
    return NULL;
  }

  if (!PyAubio_ArrayToCFvec(input, &vec)) {
    return NULL;
  }

  // compute the function
  result = Py_BuildValue (AUBIO_NPY_SMPL_CHR, aubio_zero_crossing_rate (&vec));
  if (result == NULL) {
    return NULL;
  }

  return result;
}
コード例 #6
0
static PyObject * 
Py_filterbank_set_triangle_bands (Py_filterbank * self, PyObject *args)
{
  uint_t err = 0;

  PyObject *input;
  uint_t samplerate;
  fvec_t *freqs;
  if (!PyArg_ParseTuple (args, "OI", &input, &samplerate)) {
    return NULL;
  }

  if (input == NULL) {
    return NULL;
  }

  freqs = PyAubio_ArrayToCFvec (input);

  if (freqs == NULL) {
    return NULL;
  }

  err = aubio_filterbank_set_triangle_bands (self->o,
      freqs, samplerate);
  if (err > 0) {
    PyErr_SetString (PyExc_ValueError,
        "error when setting filter to A-weighting");
    return NULL;
  }
  return Py_None;
}
コード例 #7
0
ファイル: aubiomodule.c プロジェクト: UIKit0/aubio
static PyObject *
Py_alpha_norm (PyObject * self, PyObject * args)
{
  PyObject *input;
  fvec_t *vec;
  smpl_t alpha;
  PyObject *result;

  if (!PyArg_ParseTuple (args, "Of:alpha_norm", &input, &alpha)) {
    return NULL;
  }

  if (input == NULL) {
    return NULL;
  }

  vec = PyAubio_ArrayToCFvec (input);

  if (vec == NULL) {
    return NULL;
  }

  // compute the function
  result = Py_BuildValue ("f", fvec_alpha_norm (vec, alpha));
  if (result == NULL) {
    return NULL;
  }

  return result;
}
コード例 #8
0
ファイル: py-fft.c プロジェクト: XunjunYin/aubio
static PyObject *
Py_fft_do(Py_fft * self, PyObject * args)
{
    PyObject *input;
    cvec_t c_out;

    if (!PyArg_ParseTuple (args, "O", &input)) {
        return NULL;
    }

    if (!PyAubio_ArrayToCFvec(input, &(self->vecin))) {
        return NULL;
    }

    if (self->vecin.length != self->win_s) {
        PyErr_Format(PyExc_ValueError,
                     "input array has length %d, but fft expects length %d",
                     self->vecin.length, self->win_s);
        return NULL;
    }

    Py_INCREF(self->doout);
    if (!PyAubio_PyCvecToCCvec(self->doout, &c_out)) {
        return NULL;
    }
    // compute the function
    aubio_fft_do (self->o, &(self->vecin), &c_out);
    return self->doout;
}
コード例 #9
0
ファイル: py-source.c プロジェクト: aubio/aubio
/* function Py_source_do */
static PyObject *
Py_source_do(Py_source * self, PyObject * args)
{
  PyObject *outputs;
  uint_t read;
  read = 0;

  Py_INCREF(self->read_to);
  if (!PyAubio_ArrayToCFvec(self->read_to, &(self->c_read_to))) {
    return NULL;
  }
  /* compute _do function */
  aubio_source_do (self->o, &(self->c_read_to), &read);

  if (PyErr_Occurred() != NULL) {
    return NULL;
  }

  outputs = PyTuple_New(2);
  PyTuple_SetItem( outputs, 0, self->read_to );
  PyTuple_SetItem( outputs, 1, (PyObject *)PyLong_FromLong(read));
  return outputs;
}