Esempio n. 1
0
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;
}
void
aubio_pitchmcomb_spectral_pp (aubio_pitchmcomb_t * p, fvec_t * newmag)
{
  fvec_t *mag = (fvec_t *) p->scratch;
  fvec_t *tmp = (fvec_t *) p->scratch2;
  uint_t j;
  uint_t length = mag->length;
  /* copy newmag to mag (scracth) */
  for (j = 0; j < length; j++) {
    mag->data[j] = newmag->data[j];
  }
  fvec_min_removal (mag);       /* min removal          */
  fvec_alpha_normalise (mag, p->alpha); /* alpha normalisation  */
  /* skipped *//* low pass filtering   */
  /** \bug fvec_moving_thres may write out of bounds */
  fvec_adapt_thres (mag, tmp, p->win_post, p->win_pre);      /* adaptative threshold */
  fvec_add (mag, -p->threshold);        /* fixed threshold      */
  {
    aubio_spectralpeak_t *peaks = (aubio_spectralpeak_t *) p->peaks;
    uint_t count;
    /*  return bin and ebin */
    count = aubio_pitchmcomb_quadpick (peaks, mag);
    for (j = 0; j < count; j++)
      peaks[j].mag = newmag->data[peaks[j].bin];
    /* reset non peaks */
    for (j = count; j < length; j++)
      peaks[j].mag = 0.;
    p->peaks = peaks;
    p->count = count;
  }
}