Changeset 6500367
- Timestamp:
- Jul 17, 2012, 12:54:51 AM (12 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- 3ff62e9
- Parents:
- 6fd8d7e
- Location:
- interfaces/python
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
interfaces/python/gen_pyobject.py
r6fd8d7e r6500367 21 21 param_numbers = { 22 22 'source': [0, 2], 23 'sink': [2, 0], 23 24 } 24 25 … … 145 146 'fvec_t*': 'PyAubio_ArrayToCFvec', 146 147 'cvec_t*': 'PyAubio_ArrayToCCvec', 148 'uint_t': '(uint_t)PyInt_AsLong', 147 149 } 148 150 … … 153 155 'smpl_t': 'PyFloat_FromDouble', 154 156 'uint_t*': 'PyInt_FromLong', 157 'uint_t': 'PyInt_FromLong', 155 158 } 156 159 … … 275 278 pytypes = "".join([aubio2pytypes[p['type']] for p in inputparams]) 276 279 277 inputdefs = "/* input vectors python prototypes */\n " 278 inputdefs += "\n ".join(["PyObject * " + p['name'] + "_obj;" for p in inputparams]) 279 280 inputvecs = "/* input vectors prototypes */\n " 280 inputdefs = " /* input vectors python prototypes */\n" 281 for p in inputparams: 282 if p['type'] != 'uint_t': 283 inputdefs += " PyObject * " + p['name'] + "_obj;\n" 284 285 inputvecs = " /* input vectors prototypes */\n " 281 286 inputvecs += "\n ".join(map(lambda p: p['type'] + ' ' + p['name'] + ";", inputparams)) 282 287 283 parseinput = " /* input vectors parsing */\n "288 parseinput = " /* input vectors parsing */\n " 284 289 for p in inputparams: 285 290 inputvec = p['name'] 286 inputdef = p['name'] + "_obj" 291 if p['type'] != 'uint_t': 292 inputdef = p['name'] + "_obj" 293 else: 294 inputdef = p['name'] 287 295 converter = aubiovecfrompyobj[p['type']] 288 parseinput += """%(inputvec)s = %(converter)s (%(inputdef)s); 296 if p['type'] != 'uint_t': 297 parseinput += """%(inputvec)s = %(converter)s (%(inputdef)s); 289 298 290 299 if (%(inputvec)s == NULL) { 291 300 return NULL; 292 }""" % locals() 301 } 302 303 """ % locals() 293 304 294 305 # build the string for the input objects references 295 inputrefs = ", ".join(["&" + p['name'] + "_obj" for p in inputparams]) 306 inputreflist = [] 307 for p in inputparams: 308 if p['type'] != 'uint_t': 309 inputreflist += [ "&" + p['name'] + "_obj" ] 310 else: 311 inputreflist += [ "&" + p['name'] ] 312 inputrefs = ", ".join(inputreflist) 296 313 # end of inputs strings 297 314 return inputdefs, parseinput, inputrefs, inputvecs, pytypes … … 343 360 if name in param_numbers.keys(): 344 361 n_input_param, n_output_param = param_numbers[name] 362 print name, n_output_param 345 363 else: 346 364 n_input_param, n_output_param = 1, n_param - 1 -
interfaces/python/generator.py
r6fd8d7e r6500367 40 40 'resampler', 41 41 'sndfile', 42 'sink',43 42 'sink_apple_audio', 44 43 'sink_sndfile',
Note: See TracChangeset
for help on using the changeset viewer.