source: python/ext/py-fft.c @ 0546c1f3

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 0546c1f3 was bf63c61, checked in by Paul Brossier <piem@piem.org>, 11 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
RevLine 
[615ac7d]1#include "aubiowraphell.h"
2
3static char Py_fft_doc[] = "fft object";
4
[96fe713]5AUBIO_DECLARE(fft, uint_t win_s)
[615ac7d]6
7//AUBIO_NEW(fft)
8static PyObject *
9Py_fft_new (PyTypeObject * type, PyObject * args, PyObject * kwds)
10{
[96fe713]11  int win_s = 0;
[615ac7d]12  Py_fft *self;
[96fe713]13  static char *kwlist[] = { "win_s", NULL };
[615ac7d]14
[96fe713]15  if (!PyArg_ParseTupleAndKeywords (args, kwds, "|I", kwlist,
16          &win_s)) {
[615ac7d]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
[96fe713]40AUBIO_INIT(fft, self->win_s)
[615ac7d]41
42AUBIO_DEL(fft)
43
44static PyObject * 
45Py_fft_do(PyObject * self, PyObject * args)
46{
47  PyObject *input;
[965b302]48  fvec_t *vec;
49  cvec_t *output;
[615ac7d]50
51  if (!PyArg_ParseTuple (args, "O", &input)) {
52    return NULL;
53  }
54
[965b302]55  vec = PyAubio_ArrayToCFvec (input);
[615ac7d]56
57  if (vec == NULL) {
58    return NULL;
59  }
60
[965b302]61  output = new_cvec(((Py_fft *) self)->win_s);
[615ac7d]62
63  // compute the function
[965b302]64  aubio_fft_do (((Py_fft *)self)->o, vec, output);
65  return (PyObject *)PyAubio_CCvecToPyCvec(output);
[615ac7d]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 * 
[965b302]74Py_fft_rdo(Py_fft * self, PyObject * args)
[615ac7d]75{
76  PyObject *input;
[965b302]77  cvec_t *vec;
78  fvec_t *output;
[615ac7d]79
80  if (!PyArg_ParseTuple (args, "O", &input)) {
81    return NULL;
82  }
83
[965b302]84  vec = PyAubio_ArrayToCCvec (input);
[615ac7d]85
86  if (vec == NULL) {
87    return NULL;
88  }
89
[965b302]90  output = new_fvec(self->win_s);
[615ac7d]91
92  // compute the function
[965b302]93  aubio_fft_rdo (((Py_fft *)self)->o, vec, output);
94  return (PyObject *)PyAubio_CFvecToArray(output);
[615ac7d]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.