source: python/ext/py-musicutils.c @ ee092a8

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

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

  • Property mode set to 100644
File size: 3.0 KB
Line 
1#include "aubio-types.h"
2
3PyObject *
4Py_aubio_window(PyObject *self, PyObject *args)
5{
6  char_t *wintype = NULL;
7  uint_t winlen = 0;
8  fvec_t *window = NULL;
9
10  if (!PyArg_ParseTuple (args, "|sI", &wintype, &winlen)) {
11    PyErr_SetString (PyExc_ValueError, "failed parsing arguments");
12    return NULL;
13  }
14
15  window = new_aubio_window(wintype, winlen);
16  if (window == NULL) {
17    PyErr_SetString (PyExc_ValueError, "failed computing window");
18    return NULL;
19  }
20
21  return (PyObject *) PyAubio_CFvecToArray(window);
22}
23
24PyObject *
25Py_aubio_level_lin(PyObject *self, PyObject *args)
26{
27  PyObject *input;
28  fvec_t vec;
29  PyObject *level_lin;
30
31  if (!PyArg_ParseTuple (args, "O:level_lin", &input)) {
32    PyErr_SetString (PyExc_ValueError, "failed parsing arguments");
33    return NULL;
34  }
35
36  if (input == NULL) {
37    return NULL;
38  }
39
40  if (!PyAubio_ArrayToCFvec(input, &vec)) {
41    return NULL;
42  }
43
44  level_lin = Py_BuildValue(AUBIO_NPY_SMPL_CHR, aubio_level_lin(&vec));
45  if (level_lin == NULL) {
46    PyErr_SetString (PyExc_ValueError, "failed computing level_lin");
47    return NULL;
48  }
49
50  return level_lin;
51}
52
53PyObject *
54Py_aubio_db_spl(PyObject *self, PyObject *args)
55{
56  PyObject *input;
57  fvec_t vec;
58  PyObject *db_spl;
59
60  if (!PyArg_ParseTuple (args, "O:db_spl", &input)) {
61    PyErr_SetString (PyExc_ValueError, "failed parsing arguments");
62    return NULL;
63  }
64
65  if (input == NULL) {
66    return NULL;
67  }
68
69  if (!PyAubio_ArrayToCFvec(input, &vec)) {
70    return NULL;
71  }
72
73  db_spl = Py_BuildValue(AUBIO_NPY_SMPL_CHR, aubio_db_spl(&vec));
74  if (db_spl == NULL) {
75    PyErr_SetString (PyExc_ValueError, "failed computing db_spl");
76    return NULL;
77  }
78
79  return db_spl;
80}
81
82PyObject *
83Py_aubio_silence_detection(PyObject *self, PyObject *args)
84{
85  PyObject *input;
86  fvec_t vec;
87  PyObject *silence_detection;
88  smpl_t threshold;
89
90  if (!PyArg_ParseTuple (args, "O" AUBIO_NPY_SMPL_CHR ":silence_detection", &input, &threshold)) {
91    PyErr_SetString (PyExc_ValueError, "failed parsing arguments");
92    return NULL;
93  }
94
95  if (input == NULL) {
96    return NULL;
97  }
98
99  if (!PyAubio_ArrayToCFvec(input, &vec)) {
100    return NULL;
101  }
102
103  silence_detection = Py_BuildValue("I", aubio_silence_detection(&vec, threshold));
104  if (silence_detection == NULL) {
105    PyErr_SetString (PyExc_ValueError, "failed computing silence_detection");
106    return NULL;
107  }
108
109  return silence_detection;
110}
111
112PyObject *
113Py_aubio_level_detection(PyObject *self, PyObject *args)
114{
115  PyObject *input;
116  fvec_t vec;
117  PyObject *level_detection;
118  smpl_t threshold;
119
120  if (!PyArg_ParseTuple (args, "O" AUBIO_NPY_SMPL_CHR ":level_detection", &input, &threshold)) {
121    PyErr_SetString (PyExc_ValueError, "failed parsing arguments");
122    return NULL;
123  }
124
125  if (input == NULL) {
126    return NULL;
127  }
128
129  if (!PyAubio_ArrayToCFvec(input, &vec)) {
130    return NULL;
131  }
132
133  level_detection = Py_BuildValue(AUBIO_NPY_SMPL_CHR, aubio_level_detection(&vec, threshold));
134  if (level_detection == NULL) {
135    PyErr_SetString (PyExc_ValueError, "failed computing level_detection");
136    return NULL;
137  }
138
139  return level_detection;
140}
Note: See TracBrowser for help on using the repository browser.