Changeset c6388f4


Ignore:
Timestamp:
Apr 24, 2016, 11:45:45 PM (4 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
Children:
fbcee4f
Parents:
81984a7
Message:

python/{ext,lib}: prepare for double precision

Location:
python
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • python/ext/aubio-types.h

    r81984a7 rc6388f4  
    3434
    3535#if HAVE_AUBIO_DOUBLE
    36 #error "Ouch! Python interface for aubio has not been much tested yet."
     36#warning "double mode needs love"
    3737#define AUBIO_NPY_SMPL NPY_DOUBLE
     38#define AUBIO_NPY_SMPL_STR "float64"
     39#define AUBIO_NPY_SMPL_CHR "d"
    3840#else
    3941#define AUBIO_NPY_SMPL NPY_FLOAT
     42#define AUBIO_NPY_SMPL_STR "float32"
     43#define AUBIO_NPY_SMPL_CHR "f"
    4044#endif
    4145
  • python/ext/aubiomodule.c

    r81984a7 rc6388f4  
    8888  PyObject *result;
    8989
    90   if (!PyArg_ParseTuple (args, "Of:alpha_norm", &input, &alpha)) {
     90  if (!PyArg_ParseTuple (args, "O" AUBIO_NPY_SMPL_CHR ":alpha_norm", &input, &alpha)) {
    9191    return NULL;
    9292  }
     
    101101
    102102  // compute the function
    103   result = Py_BuildValue ("f", fvec_alpha_norm (&vec, alpha));
     103  result = Py_BuildValue (AUBIO_NPY_SMPL_CHR, fvec_alpha_norm (&vec, alpha));
    104104  if (result == NULL) {
    105105    return NULL;
     
    115115  smpl_t output;
    116116
    117   if (!PyArg_ParseTuple (args, "|fff", &input, &samplerate, &fftsize)) {
     117  if (!PyArg_ParseTuple (args, "|" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR , &input, &samplerate, &fftsize)) {
    118118    return NULL;
    119119  }
     
    130130  smpl_t output;
    131131
    132   if (!PyArg_ParseTuple (args, "|fff", &input, &samplerate, &fftsize)) {
     132  if (!PyArg_ParseTuple (args, "|" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR , &input, &samplerate, &fftsize)) {
    133133    return NULL;
    134134  }
     
    145145  smpl_t output;
    146146
    147   if (!PyArg_ParseTuple (args, "|fff", &input, &samplerate, &fftsize)) {
     147  if (!PyArg_ParseTuple (args, "|" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR, &input, &samplerate, &fftsize)) {
    148148    return NULL;
    149149  }
     
    160160  smpl_t output;
    161161
    162   if (!PyArg_ParseTuple (args, "|fff", &input, &samplerate, &fftsize)) {
     162  if (!PyArg_ParseTuple (args, "|" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR, &input, &samplerate, &fftsize)) {
    163163    return NULL;
    164164  }
     
    189189
    190190  // compute the function
    191   result = Py_BuildValue ("f", aubio_zero_crossing_rate (&vec));
     191  result = Py_BuildValue (AUBIO_NPY_SMPL_CHR, aubio_zero_crossing_rate (&vec));
    192192  if (result == NULL) {
    193193    return NULL;
     
    309309  PyModule_AddObject (m, "sink", (PyObject *) & Py_sinkType);
    310310
     311  PyModule_AddStringConstant(m, "float_type", AUBIO_NPY_SMPL_STR);
     312
    311313  // add generated objects
    312314  add_generated_objects(m);
  • python/ext/aubioproxy.c

    r81984a7 rc6388f4  
    3131      return 0;
    3232    } else if (PyArray_TYPE ((PyArrayObject *)input) != AUBIO_NPY_SMPL) {
    33       PyErr_SetString (PyExc_ValueError, "input array should be float32");
     33      PyErr_SetString (PyExc_ValueError, "input array should be " AUBIO_NPY_SMPL_STR);
    3434      return 0;
    3535    }
     
    7474      return 1;
    7575  } else {
    76       PyErr_SetString (PyExc_ValueError, "input array should be float32");
     76      PyErr_SetString (PyExc_ValueError, "input array should be aubio.cvec");
    7777      return 0;
    7878  }
     
    120120      return 0;
    121121    } else if (PyArray_TYPE ((PyArrayObject *)input) != AUBIO_NPY_SMPL) {
    122       PyErr_SetString (PyExc_ValueError, "input array should be float32");
     122      PyErr_SetString (PyExc_ValueError, "input array should be " AUBIO_NPY_SMPL_STR);
    123123      return 0;
    124124    }
  • python/ext/py-cvec.c

    r81984a7 rc6388f4  
    9494{
    9595  npy_intp dims[] = { self->o->length, 1 };
    96   return PyArray_SimpleNewFromData (1, dims, NPY_FLOAT, self->o->norm);
     96  return PyArray_SimpleNewFromData (1, dims, AUBIO_NPY_SMPL, self->o->norm);
    9797}
    9898
     
    102102{
    103103  npy_intp dims[] = { self->o->length, 1 };
    104   return PyArray_SimpleNewFromData (1, dims, NPY_FLOAT, self->o->phas);
     104  return PyArray_SimpleNewFromData (1, dims, AUBIO_NPY_SMPL, self->o->phas);
    105105}
    106106
  • python/ext/py-musicutils.c

    r81984a7 rc6388f4  
    4242  }
    4343
    44   level_lin = Py_BuildValue("f", aubio_level_lin(&vec));
     44  level_lin = Py_BuildValue(AUBIO_NPY_SMPL_CHR, aubio_level_lin(&vec));
    4545  if (level_lin == NULL) {
    4646    PyErr_SetString (PyExc_ValueError, "failed computing level_lin");
     
    7171  }
    7272
    73   db_spl = Py_BuildValue("f", aubio_db_spl(&vec));
     73  db_spl = Py_BuildValue(AUBIO_NPY_SMPL_CHR, aubio_db_spl(&vec));
    7474  if (db_spl == NULL) {
    7575    PyErr_SetString (PyExc_ValueError, "failed computing db_spl");
     
    8888  smpl_t threshold;
    8989
    90   if (!PyArg_ParseTuple (args, "Of:silence_detection", &input, &threshold)) {
     90  if (!PyArg_ParseTuple (args, "O" AUBIO_NPY_SMPL_CHR ":silence_detection", &input, &threshold)) {
    9191    PyErr_SetString (PyExc_ValueError, "failed parsing arguments");
    9292    return NULL;
     
    118118  smpl_t threshold;
    119119
    120   if (!PyArg_ParseTuple (args, "Of:level_detection", &input, &threshold)) {
     120  if (!PyArg_ParseTuple (args, "O" AUBIO_NPY_SMPL_CHR ":level_detection", &input, &threshold)) {
    121121    PyErr_SetString (PyExc_ValueError, "failed parsing arguments");
    122122    return NULL;
     
    131131  }
    132132
    133   level_detection = Py_BuildValue("f", aubio_level_detection(&vec, threshold));
     133  level_detection = Py_BuildValue(AUBIO_NPY_SMPL_CHR, aubio_level_detection(&vec, threshold));
    134134  if (level_detection == NULL) {
    135135    PyErr_SetString (PyExc_ValueError, "failed computing level_detection");
  • python/lib/gen_code.py

    r81984a7 rc6388f4  
    2626        'char_t*': 'T_STRING',
    2727        'uint_t': 'T_INT',
    28         'smpl_t': 'T_FLOAT',
     28        'smpl_t': 'AUBIO_NPY_SMPL',
    2929        }
    3030
Note: See TracChangeset for help on using the changeset viewer.