source: interfaces/python/py-phasevoc.c @ 299c2b0

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 299c2b0 was c04d250, checked in by Paul Brossier <piem@piem.org>, 15 years ago

py-phasevoc.c: use new proxy functions

  • Property mode set to 100644
File size: 2.3 KB
Line 
1#include "aubiowraphell.h"
2
3static char Py_pvoc_doc[] = "pvoc object";
4
5AUBIO_DECLARE(pvoc, uint_t win_s; uint_t hop_s)
6
7//AUBIO_NEW(pvoc)
8static PyObject *
9Py_pvoc_new (PyTypeObject * type, PyObject * args, PyObject * kwds)
10{
11  int win_s = 0, hop_s = 0;
12  Py_pvoc *self;
13  static char *kwlist[] = { "win_s", "hop_s", NULL };
14
15  if (!PyArg_ParseTupleAndKeywords (args, kwds, "|II", kwlist,
16          &win_s, &hop_s)) {
17    return NULL;
18  }
19
20  self = (Py_pvoc *) type->tp_alloc (type, 0);
21
22  if (self == NULL) {
23    return NULL;
24  }
25
26  self->win_s = Py_default_vector_length;
27  self->hop_s = Py_default_vector_length/2;
28
29  if (self == NULL) {
30    return NULL;
31  }
32
33  if (win_s > 0) {
34    self->win_s = win_s;
35  } else if (win_s < 0) {
36    PyErr_SetString (PyExc_ValueError,
37        "can not use negative window size");
38    return NULL;
39  }
40
41  if (hop_s > 0) {
42    self->hop_s = hop_s;
43  } else if (hop_s < 0) {
44    PyErr_SetString (PyExc_ValueError,
45        "can not use negative hop size");
46    return NULL;
47  }
48
49  return (PyObject *) self;
50}
51
52
53AUBIO_INIT(pvoc, self->win_s, self->hop_s)
54
55AUBIO_DEL(pvoc)
56
57static PyObject * 
58Py_pvoc_do(Py_pvoc * self, PyObject * args)
59{
60  PyObject *input;
61  fvec_t *vec;
62  cvec_t *output;
63
64  if (!PyArg_ParseTuple (args, "O", &input)) {
65    return NULL;
66  }
67
68  vec = PyAubio_ArrayToCFvec (input);
69
70  if (vec == NULL) {
71    return NULL;
72  }
73
74  output = new_cvec(self->win_s);
75
76  // compute the function
77  aubio_pvoc_do (self->o, vec, output);
78  return (PyObject *)PyAubio_CCvecToPyCvec(output);
79}
80
81AUBIO_MEMBERS_START(pvoc) 
82  {"win_s", T_INT, offsetof (Py_pvoc, win_s), READONLY,
83    "size of the window"},
84  {"hop_s", T_INT, offsetof (Py_pvoc, hop_s), READONLY,
85    "size of the hop"},
86AUBIO_MEMBERS_STOP(pvoc)
87
88static PyObject * 
89Py_pvoc_rdo(Py_pvoc * self, PyObject * args)
90{
91  PyObject *input;
92  cvec_t *vec;
93  fvec_t *output;
94
95  if (!PyArg_ParseTuple (args, "O", &input)) {
96    return NULL;
97  }
98
99  vec = PyAubio_ArrayToCCvec (input);
100
101  if (vec == NULL) {
102    return NULL;
103  }
104
105  output = new_fvec(self->hop_s);
106
107  // compute the function
108  aubio_pvoc_rdo (self->o, vec, output);
109  return (PyObject *)PyAubio_CFvecToArray(output);
110}
111
112static PyMethodDef Py_pvoc_methods[] = {
113  {"rdo", (PyCFunction) Py_pvoc_rdo, METH_VARARGS,
114    "synthesis of spectral grain"},
115  {NULL}
116};
117
118AUBIO_TYPEOBJECT(pvoc, "aubio.pvoc")
Note: See TracBrowser for help on using the repository browser.