Changeset 9b23eb31


Ignore:
Timestamp:
Oct 6, 2009, 2:49:53 AM (15 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
f826349
Parents:
998a8be
Message:

interfaces/python: add cvec and filter types

Location:
interfaces/python
Files:
3 added
5 edited

Legend:

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

    r998a8be r9b23eb31  
    55#include <aubio.h>
    66
    7 #define Py_fvec_default_length   1024
    8 #define Py_fvec_default_channels 1
     7#define Py_default_vector_length   1024
     8#define Py_default_vector_channels 1
     9
     10#define Py_aubio_default_samplerate 44100
    911
    1012#ifdef HAVE_AUBIO_DOUBLE
     
    2527typedef struct
    2628{
    27   PyObject_HEAD fvec_t * o;
     29  PyObject_HEAD
     30  fvec_t * o;
    2831  uint_t length;
    2932  uint_t channels;
     
    3134extern PyTypeObject Py_fvecType;
    3235
     36extern PyTypeObject Py_cvecType;
     37
     38extern PyTypeObject Py_filterType;
     39
    3340extern PyObject *PyAubio_FvecToArray (Py_fvec * self);
    3441
  • interfaces/python/aubiomodule.c

    r998a8be r9b23eb31  
    9797  //return Py_None;
    9898  // however it is convenient to return the modified vector
    99   //return (PyObject *) PyAubio_FvecToArray(vec);
     99  return (PyObject *) PyAubio_FvecToArray(vec);
    100100  // or even without converting it back to an array
    101   Py_INCREF(vec);
    102   return (PyObject *)vec;
     101  //Py_INCREF(vec);
     102  //return (PyObject *)vec;
    103103}
    104 
    105  
    106 
    107104
    108105static PyMethodDef aubio_methods[] = {
     
    122119  int err;
    123120
    124   if (PyType_Ready (&Py_fvecType) < 0) {
     121  if ((PyType_Ready (&Py_fvecType) < 0) ||
     122      (PyType_Ready (&Py_cvecType) < 0) ||
     123      (PyType_Ready (&Py_filterType) < 0)) {
    125124    return;
    126125  }
     
    141140  Py_INCREF (&Py_fvecType);
    142141  PyModule_AddObject (m, "fvec", (PyObject *) & Py_fvecType);
     142  Py_INCREF (&Py_cvecType);
     143  PyModule_AddObject (m, "cvec", (PyObject *) & Py_cvecType);
     144  Py_INCREF (&Py_filterType);
     145  PyModule_AddObject (m, "digital_filter", (PyObject *) & Py_filterType);
    143146}
  • interfaces/python/py-fvec.c

    r998a8be r9b23eb31  
    2828  self = (Py_fvec *) type->tp_alloc (type, 0);
    2929
    30   self->length = Py_fvec_default_length;
    31   self->channels = Py_fvec_default_channels;
     30  self->length = Py_default_vector_length;
     31  self->channels = Py_default_vector_channels;
    3232
    3333  if (self == NULL) {
     
    5151  }
    5252
    53 
    5453  return (PyObject *) self;
    5554}
     
    8988    goto fail;
    9089  }
     90  fvec_print ( self->o );
    9191
    9292  result = PyString_Format (format, args);
     
    9797
    9898  return result;
    99 }
    100 
    101 static PyObject *
    102 Py_fvec_print (Py_fvec * self, PyObject * unused)
    103 {
    104   fvec_print (self->o);
    105   return Py_None;
    10699}
    107100
     
    111104  Py_fvec *vec;
    112105  uint_t i;
     106  if (input == NULL) {
     107    PyErr_SetString (PyExc_ValueError, "input array is not a python object");
     108    goto fail;
     109  }
    113110  // parsing input object into a Py_fvec
    114111  if (PyObject_TypeCheck (input, &Py_fvecType)) {
     
    267264
    268265static PyMethodDef Py_fvec_methods[] = {
    269   {"dump", (PyCFunction) Py_fvec_print, METH_NOARGS,
    270       "Dumps the contents of the vector to stdout."},
    271266  {"__array__", (PyCFunction) PyAubio_FvecToArray, METH_NOARGS,
    272267      "Returns the first channel as a numpy array."},
  • interfaces/python/setup.py

    r998a8be r9b23eb31  
    44      ext_modules = [
    55        Extension("_aubio",
    6             ["aubiomodule.c", "py-fvec.c"],
     6            ["aubiomodule.c", "py-fvec.c", "py-cvec.c", "py-filter.c"],
    77            include_dirs=['../../build/default/src', '../../src' ],
    88            library_dirs=['../../build/default/src', '../../src/.libs' ],
  • interfaces/python/test_aubio.py

    r998a8be r9b23eb31  
    11from numpy.testing import TestCase, run_module_suite
    2 from numpy.testing import assert_equal as numpy_assert_equal
     2from numpy.testing import assert_equal
    33from _aubio import *
    44from numpy import array
    55
    66AUBIO_DO_CASTING = 0
    7 
    8 def assert_equal(a, b):
    9   numpy_assert_equal(array(a),array(b))
    107
    118class aubiomodule_test_case(TestCase):
Note: See TracChangeset for help on using the changeset viewer.