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

feature/autosinkfeature/constantqfeature/pitchshiftfeature/pydocstringsfeature/timestretchpitchshiftsamplertimestretchyinfft+
Last change on this file since b5bef11 was b5bef11, checked in by Paul Brossier <piem@piem.org>, 6 years ago

ext/: use new proxy functions

  • Property mode set to 100644
File size: 3.2 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  vec = (fvec_t *)malloc(sizeof(fvec_t));
41  if (!PyAubio_ArrayToCFvec(input, vec)) {
42    free(vec);
43    return NULL;
44  }
45
46  level_lin = Py_BuildValue("f", aubio_level_lin(vec));
47  free(vec);
48  if (level_lin == NULL) {
49    PyErr_SetString (PyExc_ValueError, "failed computing level_lin");
50    return NULL;
51  }
52
53  return level_lin;
54}
55
56PyObject *
57Py_aubio_db_spl(PyObject *self, PyObject *args)
58{
59  PyObject *input;
60  fvec_t *vec;
61  PyObject *db_spl;
62
63  if (!PyArg_ParseTuple (args, "O:db_spl", &input)) {
64    PyErr_SetString (PyExc_ValueError, "failed parsing arguments");
65    return NULL;
66  }
67
68  if (input == NULL) {
69    return NULL;
70  }
71
72  vec = (fvec_t *)malloc(sizeof(fvec_t));
73  if (!PyAubio_ArrayToCFvec(input, vec)) {
74    free(vec);
75    return NULL;
76  }
77
78  db_spl = Py_BuildValue("f", aubio_db_spl(vec));
79  free(vec);
80  if (db_spl == NULL) {
81    PyErr_SetString (PyExc_ValueError, "failed computing db_spl");
82    return NULL;
83  }
84
85  return db_spl;
86}
87
88PyObject *
89Py_aubio_silence_detection(PyObject *self, PyObject *args)
90{
91  PyObject *input;
92  fvec_t *vec;
93  PyObject *silence_detection;
94  smpl_t threshold;
95
96  if (!PyArg_ParseTuple (args, "Of:silence_detection", &input, &threshold)) {
97    PyErr_SetString (PyExc_ValueError, "failed parsing arguments");
98    return NULL;
99  }
100
101  if (input == NULL) {
102    return NULL;
103  }
104
105  vec = (fvec_t *)malloc(sizeof(fvec_t));
106  if (!PyAubio_ArrayToCFvec(input, vec)) {
107    free(vec);
108    return NULL;
109  }
110
111  silence_detection = Py_BuildValue("I", aubio_silence_detection(vec, threshold));
112  free(vec);
113  if (silence_detection == NULL) {
114    PyErr_SetString (PyExc_ValueError, "failed computing silence_detection");
115    return NULL;
116  }
117
118  return silence_detection;
119}
120
121PyObject *
122Py_aubio_level_detection(PyObject *self, PyObject *args)
123{
124  PyObject *input;
125  fvec_t *vec;
126  PyObject *level_detection;
127  smpl_t threshold;
128
129  if (!PyArg_ParseTuple (args, "Of:level_detection", &input, &threshold)) {
130    PyErr_SetString (PyExc_ValueError, "failed parsing arguments");
131    return NULL;
132  }
133
134  if (input == NULL) {
135    return NULL;
136  }
137
138  vec = (fvec_t *)malloc(sizeof(fvec_t));
139  if (!PyAubio_ArrayToCFvec(input, vec)) {
140    free(vec);
141    return NULL;
142  }
143
144  level_detection = Py_BuildValue("f", aubio_level_detection(vec, threshold));
145  free(vec);
146  if (level_detection == NULL) {
147    PyErr_SetString (PyExc_ValueError, "failed computing level_detection");
148    return NULL;
149  }
150
151  return level_detection;
152}
Note: See TracBrowser for help on using the repository browser.