Changes in / [6203a70:81fe7d30]
- Files:
-
- 10 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
python/ext/aubiomodule.c
r6203a70 r81fe7d30 243 243 {"level_detection", Py_aubio_level_detection, METH_VARARGS, Py_aubio_level_detection_doc}, 244 244 {"window", Py_aubio_window, METH_VARARGS, Py_aubio_window_doc}, 245 {"shift", Py_aubio_shift, METH_VARARGS, Py_aubio_shift_doc},246 {"ishift", Py_aubio_ishift, METH_VARARGS, Py_aubio_ishift_doc},247 245 {NULL, NULL, 0, NULL} /* Sentinel */ 248 246 }; -
python/ext/py-musicutils.c
r6203a70 r81fe7d30 134 134 return level_detection; 135 135 } 136 137 PyObject *138 Py_aubio_shift(PyObject *self, PyObject *args)139 {140 PyObject *input;141 fvec_t vec;142 143 if (!PyArg_ParseTuple (args, "O:shift", &input)) {144 return NULL;145 }146 147 if (input == NULL) {148 return NULL;149 }150 151 if (!PyAubio_ArrayToCFvec(input, &vec)) {152 return NULL;153 }154 155 fvec_shift(&vec);156 157 //Py_RETURN_NONE;158 return (PyObject *) PyAubio_CFvecToArray(&vec);159 }160 161 PyObject *162 Py_aubio_ishift(PyObject *self, PyObject *args)163 {164 PyObject *input;165 fvec_t vec;166 167 if (!PyArg_ParseTuple (args, "O:shift", &input)) {168 return NULL;169 }170 171 if (input == NULL) {172 return NULL;173 }174 175 if (!PyAubio_ArrayToCFvec(input, &vec)) {176 return NULL;177 }178 179 fvec_ishift(&vec);180 181 //Py_RETURN_NONE;182 return (PyObject *) PyAubio_CFvecToArray(&vec);183 } -
python/ext/py-musicutils.h
r6203a70 r81fe7d30 72 72 PyObject * Py_aubio_level_detection(PyObject *self, PyObject *args); 73 73 74 static char Py_aubio_shift_doc[] = ""75 "Swap left and right partitions of a vector\n"76 "\n"77 "Returns the swapped vector. The input vector is also modified.\n"78 "\n"79 "For a vector of length N, the partition is split at index N - N//2.\n"80 "\n"81 "Example\n"82 "-------\n"83 "\n"84 ">>> import numpy\n"85 ">>> shift(numpy.arange(3, dtype=aubio.float_type))\n"86 "array([2., 0., 1.], dtype=" AUBIO_NPY_SMPL_STR ")";87 PyObject * Py_aubio_shift(PyObject *self, PyObject *args);88 89 static char Py_aubio_ishift_doc[] = ""90 "Swap right and left partitions of a vector\n"91 "\n"92 "Returns the swapped vector. The input vector is also modified.\n"93 "\n"94 "Unlike with shift(), the partition is split at index N//2.\n"95 "\n"96 "Example\n"97 "-------\n"98 "\n"99 ">>> import numpy\n"100 ">>> ishift(numpy.arange(3, dtype=aubio.float_type))\n"101 "array([1., 2., 0.], dtype=" AUBIO_NPY_SMPL_STR ")";102 PyObject * Py_aubio_ishift(PyObject *self, PyObject *args);103 104 74 #endif /* PY_AUBIO_MUSICUTILS_H */ -
python/lib/gen_code.py
r6203a70 r81fe7d30 85 85 'filterbank': 'self->n_filters', 86 86 'tss': 'self->buf_size', 87 'dct': 'self->size',88 87 'constantq': 'aubio_constantq_get_numbins (self->o)', 89 88 } … … 181 180 self.do_outputs = get_params_types_names(self.do_proto)[2:] 182 181 struct_output_str = ["PyObject *{0[name]}; {1} c_{0[name]}".format(i, i['type'][:-1]) for i in self.do_outputs] 183 if len(self.prototypes['rdo']):184 rdo_outputs = get_params_types_names(prototypes['rdo'][0])[2:]185 struct_output_str += ["PyObject *{0[name]}; {1} c_{0[name]}".format(i, i['type'][:-1]) for i in rdo_outputs]186 self.outputs += rdo_outputs187 182 self.struct_outputs = ";\n ".join(struct_output_str) 188 183 … … 199 194 out += self.gen_del() 200 195 out += self.gen_do() 201 if len(self.prototypes['rdo']):202 self.do_proto = self.prototypes['rdo'][0]203 self.do_inputs = [get_params_types_names(self.do_proto)[1]]204 self.do_outputs = get_params_types_names(self.do_proto)[2:]205 out += self.gen_do(method='rdo')206 196 out += self.gen_memberdef() 207 197 out += self.gen_set() … … 384 374 return out 385 375 386 def gen_do(self , method = 'do'):376 def gen_do(self): 387 377 out = """ 388 378 // do {shortname} 389 379 static PyObject* 390 Py aubio_{shortname}_{method}(Py_{shortname} * self, PyObject * args)391 {{""".format( method = method,**self.__dict__)380 Py_{shortname}_do (Py_{shortname} * self, PyObject * args) 381 {{""".format(**self.__dict__) 392 382 input_params = self.do_inputs 393 383 output_params = self.do_outputs … … 529 519 {{"{shortname}", (PyCFunction) Py{name}, 530 520 METH_NOARGS, ""}},""".format(name = name, shortname = shortname) 531 for m in self.prototypes['rdo']:532 name = get_name(m)533 shortname = name.replace('aubio_%s_' % self.shortname, '')534 out += """535 {{"{shortname}", (PyCFunction) Py{name},536 METH_VARARGS, ""}},""".format(name = name, shortname = shortname)537 521 out += """ 538 522 {NULL} /* sentinel */ … … 560 544 0, 561 545 0, 562 (ternaryfunc)Py aubio_{shortname}_do,546 (ternaryfunc)Py_{shortname}_do, 563 547 0, 564 548 0, -
python/lib/gen_external.py
r6203a70 r81fe7d30 182 182 shortname = o[6:-2] # without aubio_ prefix and _t suffix 183 183 184 lib[shortname] = {'struct': [], 'new': [], 'del': [], 'do': [], ' rdo': [], 'get': [], 'set': [], 'other': []}184 lib[shortname] = {'struct': [], 'new': [], 'del': [], 'do': [], 'get': [], 'set': [], 'other': []} 185 185 lib[shortname]['longname'] = o 186 186 lib[shortname]['shortname'] = shortname … … 196 196 elif '_do' in fn: 197 197 lib[shortname]['do'].append(fn) 198 elif '_rdo' in fn:199 lib[shortname]['rdo'].append(fn)200 198 elif 'new_' in fn: 201 199 lib[shortname]['new'].append(fn) -
src/aubio.h
r6203a70 r81fe7d30 183 183 #include "temporal/c_weighting.h" 184 184 #include "spectral/fft.h" 185 #include "spectral/dct.h"186 185 #include "spectral/phasevoc.h" 187 186 #include "spectral/constantq.h" -
src/aubio_priv.h
r6203a70 r81fe7d30 86 86 #define aubio_vDSP_mmov vDSP_mmov 87 87 #define aubio_vDSP_vmul vDSP_vmul 88 #define aubio_vDSP_vsmul vDSP_vsmul89 #define aubio_vDSP_vsadd vDSP_vsadd90 88 #define aubio_vDSP_vfill vDSP_vfill 91 89 #define aubio_vDSP_meanv vDSP_meanv … … 100 98 #define aubio_vDSP_mmov vDSP_mmovD 101 99 #define aubio_vDSP_vmul vDSP_vmulD 102 #define aubio_vDSP_vsmul vDSP_vsmulD103 #define aubio_vDSP_vsadd vDSP_vsaddD104 100 #define aubio_vDSP_vfill vDSP_vfillD 105 101 #define aubio_vDSP_meanv vDSP_meanvD -
src/spectral/mfcc.c
r6203a70 r81fe7d30 29 29 #include "spectral/filterbank.h" 30 30 #include "spectral/filterbank_mel.h" 31 #include "spectral/dct.h"32 31 #include "spectral/mfcc.h" 33 34 #undef HAVE_SLOW_DCT35 32 36 33 /** Internal structure for mfcc object */ … … 44 41 aubio_filterbank_t *fb; /** filter bank */ 45 42 fvec_t *in_dct; /** input buffer for dct * [fb->n_filters] */ 46 #if defined(HAVE_SLOW_DCT)47 43 fmat_t *dct_coeffs; /** DCT transform n_filters * n_coeffs */ 48 #else49 aubio_dct_t *dct;50 fvec_t *output;51 #endif52 44 }; 53 45 … … 60 52 /* allocate space for mfcc object */ 61 53 aubio_mfcc_t *mfcc = AUBIO_NEW (aubio_mfcc_t); 62 #if defined(HAVE_SLOW_DCT)63 54 smpl_t scaling; 64 55 65 56 uint_t i, j; 66 #endif67 57 68 58 mfcc->win_s = win_s; … … 78 68 mfcc->in_dct = new_fvec (n_filters); 79 69 80 #if defined(HAVE_SLOW_DCT)81 70 mfcc->dct_coeffs = new_fmat (n_coefs, n_filters); 82 71 … … 91 80 mfcc->dct_coeffs->data[0][i] *= SQRT (2.) / 2.; 92 81 } 93 #else94 mfcc->dct = new_aubio_dct (n_filters);95 mfcc->output = new_fvec (n_filters);96 #endif97 82 98 83 return mfcc; … … 108 93 /* delete buffers */ 109 94 del_fvec (mf->in_dct); 110 #if defined(HAVE_SLOW_DCT)111 95 del_fmat (mf->dct_coeffs); 112 #else113 del_aubio_dct (mf->dct);114 del_fvec (mf->output);115 #endif116 96 117 97 /* delete mfcc object */ … … 123 103 aubio_mfcc_do (aubio_mfcc_t * mf, const cvec_t * in, fvec_t * out) 124 104 { 125 #ifndef HAVE_SLOW_DCT126 fvec_t tmp;127 #endif128 105 /* compute filterbank */ 129 106 aubio_filterbank_do (mf->fb, in, mf->in_dct); … … 136 113 137 114 /* compute mfccs */ 138 #if defined(HAVE_SLOW_DCT)139 115 fmat_vecmul(mf->dct_coeffs, mf->in_dct, out); 140 #else141 aubio_dct_do(mf->dct, mf->in_dct, mf->output);142 // copy only first n_coeffs elements143 // TODO assert mf->output->length == n_coeffs144 tmp.data = mf->output->data;145 tmp.length = out->length;146 fvec_copy(&tmp, out);147 #endif148 116 149 117 return;
Note: See TracChangeset
for help on using the changeset viewer.