source: python/ext/py-fft.c @ bf63c61

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

ext/py-fft.c: remove doubled check

Signed-off-by: Paul Brossier <piem@piem.org>

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