Changeset 4c4c9f6
- Timestamp:
- Jul 27, 2012, 5:30:11 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:
- 3bba0e0
- Parents:
- 7d50c5a (diff), bf34fbb (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 22 added
- 7 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
examples/utils.h
r7d50c5a r4c4c9f6 28 28 #include <aubio.h> 29 29 #include "config.h" 30 #include "sndfileio.h"31 30 #ifdef HAVE_JACK 32 31 #include "jackio.h" -
examples/wscript_build
r7d50c5a r4c4c9f6 2 2 3 3 # build examples 4 sndfileio = ctx.new_task_gen(features = 'c',5 includes = '../src',6 source = ['sndfileio.c'],7 target = 'sndfileio')8 9 4 utilsio = ctx.new_task_gen(name = 'utilsio', features = 'c', 10 5 includes = '../src', 11 add_objects = 'sndfileio',12 6 source = ['utils.c', 'jackio.c'], 13 uselib = ['LASH', 'JACK' , 'SNDFILE'],7 uselib = ['LASH', 'JACK'], 14 8 target = 'utilsio') 15 9 16 10 # loop over all *.c filenames in examples to build them all 17 for target_name in ctx.path.ant_glob('*.c', excl = ['utils.c', 'jackio.c' , 'sndfileio.c']):11 for target_name in ctx.path.ant_glob('*.c', excl = ['utils.c', 'jackio.c']): 18 12 ctx.new_task_gen(features = 'c cprogram', 19 13 add_objects = 'utilsio', -
interfaces/python/gen_pyobject.py
r7d50c5a r4c4c9f6 18 18 maintaining this bizarre file. 19 19 """ 20 21 param_numbers = { 22 'source': [0, 2], 23 'sink': [2, 0], 24 } 20 25 21 26 # TODO … … 81 86 # move into the C library at some point. 82 87 defaultsizes = { 83 'resampler': 'input->length * self->ratio', 84 'specdesc': '1', 85 'onset': '1', 86 'pitchyin': '1', 87 'pitchyinfft': '1', 88 'pitchschmitt': '1', 89 'pitchmcomb': '1', 90 'pitchfcomb': '1', 91 'pitch': '1', 92 'tss': 'self->hop_size', 93 'mfcc': 'self->n_coeffs', 94 'beattracking': 'self->hop_size', 95 'tempo': '1', 96 'peakpicker': '1', 88 'resampler': ['input->length * self->ratio'], 89 'specdesc': ['1'], 90 'onset': ['1'], 91 'pitchyin': ['1'], 92 'pitchyinfft': ['1'], 93 'pitchschmitt': ['1'], 94 'pitchmcomb': ['1'], 95 'pitchfcomb': ['1'], 96 'pitch': ['1'], 97 'tss': ['self->win_size', 'self->win_size'], 98 'mfcc': ['self->n_coeffs'], 99 'beattracking': ['self->hop_size'], 100 'tempo': ['1'], 101 'peakpicker': ['1'], 102 'source': ['self->hop_size', '1'], 97 103 } 98 104 … … 123 129 'ratio': '0.5', 124 130 'method': '"default"', 131 'uri': '"none"', 125 132 } 126 133 … … 139 146 'fvec_t*': 'PyAubio_ArrayToCFvec', 140 147 'cvec_t*': 'PyAubio_ArrayToCCvec', 148 'uint_t': '(uint_t)PyInt_AsLong', 141 149 } 142 150 … … 146 154 'cvec_t*': 'PyAubio_CCvecToPyCvec', 147 155 'smpl_t': 'PyFloat_FromDouble', 156 'uint_t*': 'PyInt_FromLong', 157 'uint_t': 'PyInt_FromLong', 148 158 } 149 159 … … 257 267 return s 258 268 269 def gen_do_input_params(inputparams): 270 inputdefs = '' 271 parseinput = '' 272 inputrefs = '' 273 inputvecs = '' 274 pytypes = '' 275 276 if len(inputparams): 277 # build the parsing string for PyArg_ParseTuple 278 pytypes = "".join([aubio2pytypes[p['type']] for p in inputparams]) 279 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 " 286 inputvecs += "\n ".join(map(lambda p: p['type'] + ' ' + p['name'] + ";", inputparams)) 287 288 parseinput = " /* input vectors parsing */\n " 289 for p in inputparams: 290 inputvec = p['name'] 291 if p['type'] != 'uint_t': 292 inputdef = p['name'] + "_obj" 293 else: 294 inputdef = p['name'] 295 converter = aubiovecfrompyobj[p['type']] 296 if p['type'] != 'uint_t': 297 parseinput += """%(inputvec)s = %(converter)s (%(inputdef)s); 298 299 if (%(inputvec)s == NULL) { 300 return NULL; 301 } 302 303 """ % locals() 304 305 # build the string for the input objects references 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) 313 # end of inputs strings 314 return inputdefs, parseinput, inputrefs, inputvecs, pytypes 315 316 def gen_do_output_params(outputparams, name): 317 outputvecs = "" 318 outputcreate = "" 319 if len(outputparams): 320 outputvecs = " /* output vectors prototypes */\n" 321 for p in outputparams: 322 params = { 323 'name': p['name'], 'pytype': p['type'], 'autype': p['type'][:-3], 324 'length': defaultsizes[name].pop(0) } 325 if (p['type'] == 'uint_t*'): 326 outputvecs += ' uint_t' + ' ' + p['name'] + ";\n" 327 outputcreate += " %(name)s = 0;\n" % params 328 else: 329 outputvecs += " " + p['type'] + ' ' + p['name'] + ";\n" 330 outputcreate += " /* creating output %(name)s as a new_%(autype)s of length %(length)s */\n" % params 331 outputcreate += " %(name)s = new_%(autype)s (%(length)s);\n" % params 332 333 returnval = ""; 334 if len(outputparams) > 1: 335 returnval += " PyObject *outputs = PyList_New(0);\n" 336 for p in outputparams: 337 returnval += " PyList_Append( outputs, (PyObject *)" + aubiovectopyobj[p['type']] + " (" + p['name'] + ")" +");\n" 338 returnval += " return outputs;" 339 elif len(outputparams) == 1: 340 if defaultsizes[name] == '1': 341 returnval += " return (PyObject *)PyFloat_FromDouble(" + p['name'] + "->data[0])" 342 else: 343 returnval += " return (PyObject *)" + aubiovectopyobj[p['type']] + " (" + p['name'] + ")" 344 else: 345 returnval = " return Py_None;"; 346 # end of output strings 347 return outputvecs, outputcreate, returnval 348 259 349 def gen_do(dofunc, name): 260 350 funcname = dofunc.split()[1].split('(')[0] … … 265 355 # and remove it 266 356 doparams = doparams[1:] 267 # guess the input/output params, assuming we have less than 3 268 assert len(doparams) > 0, \ 269 "no parameters for function do in object %s" % name 270 #assert (len(doparams) <= 2), \ 271 # "more than 3 parameters for do in object %s" % name 272 273 # build strings for inputs, assuming there is only one input 274 inputparams = [doparams[0]] 275 # build the parsing string for PyArg_ParseTuple 276 pytypes = "".join([aubio2pytypes[p['type']] for p in doparams[0:1]]) 277 278 inputdefs = "/* input vectors python prototypes */\n " 279 inputdefs += "\n ".join(["PyObject * " + p['name'] + "_obj;" for p in inputparams]) 280 281 inputvecs = "/* input vectors prototypes */\n " 282 inputvecs += "\n ".join(map(lambda p: p['type'] + ' ' + p['name'] + ";", inputparams)) 283 284 parseinput = "/* input vectors parsing */\n " 285 for p in inputparams: 286 inputvec = p['name'] 287 inputdef = p['name'] + "_obj" 288 converter = aubiovecfrompyobj[p['type']] 289 parseinput += """%(inputvec)s = %(converter)s (%(inputdef)s); 290 291 if (%(inputvec)s == NULL) { 292 return NULL; 293 }""" % locals() 294 295 # build the string for the input objects references 296 inputrefs = ", ".join(["&" + p['name'] + "_obj" for p in inputparams]) 297 # end of inputs strings 357 358 n_param = len(doparams) 359 360 if name in param_numbers.keys(): 361 n_input_param, n_output_param = param_numbers[name] 362 print name, n_output_param 363 else: 364 n_input_param, n_output_param = 1, n_param - 1 365 366 assert n_output_param + n_input_param == n_param, "n_output_param + n_input_param != n_param for %s" % name 367 368 inputparams = doparams[:n_input_param] 369 outputparams = doparams[n_input_param:n_input_param + n_output_param] 370 371 inputdefs, parseinput, inputrefs, inputvecs, pytypes = gen_do_input_params(inputparams); 372 outputvecs, outputcreate, returnval = gen_do_output_params(outputparams, name) 298 373 299 374 # build strings for outputs 300 outputparams = doparams[1:] 301 if len(outputparams) >= 1: 302 #assert len(outputparams) == 1, \ 303 # "too many output parameters" 304 outputvecs = "\n /* output vectors prototypes */\n " 305 outputvecs += "\n ".join([p['type'] + ' ' + p['name'] + ";" for p in outputparams]) 306 params = { 307 'name': p['name'], 'pytype': p['type'], 'autype': p['type'][:-3], 308 'length': defaultsizes[name]} 309 outputcreate = "\n ".join(["""/* creating output %(name)s as a new_%(autype)s of length %(length)s */""" % \ 310 params for p in outputparams]) 311 outputcreate += "\n" 312 outputcreate += "\n ".join([""" %(name)s = new_%(autype)s (%(length)s);""" % \ 313 params for p in outputparams]) 314 returnval = "" 315 if len(outputparams) > 1: 316 returnval += "PyObject *outputs = PyList_New(0);\n" 317 for p in outputparams: 318 returnval += " PyList_Append( outputs, (PyObject *)" + aubiovectopyobj[p['type']] + " (" + p['name'] + ")" +");\n" 319 returnval += " return outputs;" 320 else: 321 if defaultsizes[name] == '1': 322 returnval += "return (PyObject *)PyFloat_FromDouble(" + p['name'] + "->data[0])" 323 else: 324 returnval += "return (PyObject *)" + aubiovectopyobj[p['type']] + " (" + p['name'] + ")" 375 # build the parameters for the _do() call 376 doparams_string = "self->o" 377 for p in doparams: 378 if p['type'] == 'uint_t*': 379 doparams_string += ", &" + p['name'] 380 else: 381 doparams_string += ", " + p['name'] 382 383 if n_input_param: 384 arg_parse_tuple = """\ 385 if (!PyArg_ParseTuple (args, "%(pytypes)s", %(inputrefs)s)) { 386 return NULL; 387 } 388 """ % locals() 325 389 else: 326 # no output 327 outputvecs = "" 328 outputcreate = "" 329 #returnval = "Py_None"; 330 returnval = "return (PyObject *)" + aubiovectopyobj[p['type']] + " (" + p['name'] + ")" 331 # end of output strings 332 333 # build the parameters for the _do() call 334 doparams_string = "self->o, " + ", ".join([p['name'] for p in doparams]) 335 390 arg_parse_tuple = "" 336 391 # put it all together 337 392 s = """\ … … 340 395 Py_%(name)s_do(Py_%(name)s * self, PyObject * args) 341 396 { 342 %(inputdefs)s 343 %(inputvecs)s 344 %(outputvecs)s 345 346 if (!PyArg_ParseTuple (args, "%(pytypes)s", %(inputrefs)s)) { 347 return NULL; 348 } 349 350 %(parseinput)s 397 %(inputdefs)s 398 %(inputvecs)s 399 %(outputvecs)s 400 401 %(arg_parse_tuple)s 402 403 %(parseinput)s 351 404 352 405 %(outputcreate)s 353 406 354 407 /* compute _do function */ 355 408 %(funcname)s (%(doparams_string)s); 356 409 357 410 %(returnval)s; 358 411 } 359 412 """ % locals() -
interfaces/python/generator.py
r7d50c5a r4c4c9f6 34 34 generated_objects = [] 35 35 cpp_output, cpp_objects = get_cpp_objects() 36 skip_objects = ['fft', 'pvoc', 'filter', 'filterbank', 'resampler'] 36 skip_objects = ['fft', 37 'pvoc', 38 'filter', 39 'filterbank', 40 'resampler', 41 'sndfile', 42 'sink_apple_audio', 43 'sink_sndfile', 44 'source_apple_audio', 45 'source_sndfile'] 37 46 38 47 write_msg("-- INFO: %d objects in total" % len(cpp_objects)) -
src/aubio.h
r7d50c5a r4c4c9f6 175 175 #include "onset/peakpicker.h" 176 176 #include "tempo/tempo.h" 177 #include "io/sndfileio.h" 178 #include "io/source.h" 179 #include "io/source_sndfile.h" 180 #include "io/source_apple_audio.h" 181 #include "io/sink.h" 182 #include "io/sink_sndfile.h" 183 #include "io/sink_apple_audio.h" 177 184 178 185 #if AUBIO_UNSTABLE -
src/wscript_build
r7d50c5a r4c4c9f6 1 1 # vim:set syntax=python: 2 2 3 uselib = ['SAMPLERATE'] 3 source = ctx.path.ant_glob('*.c **/*.c') 4 uselib = [] 5 4 6 if 'HAVE_FFTW3' in conf.get_env(): 5 source = ctx.path.ant_glob('*.c **/*.c', excl = ['**/ooura_fft8g.c'])7 source.filter(lambda x: not x.endswith('ooura_fft8g.c')) 6 8 uselib += ['FFTW3', 'FFTW3F'] 7 else: 8 source = ctx.path.ant_glob('*.c **/*.c') 9 10 if 'HAVE_SAMPLERATE': 11 uselib += ['SAMPLERATE'] 12 13 if 'HAVE_SNDFILE': 14 uselib += ['SNDFILE'] 9 15 10 16 # build libaubio -
wscript
r7d50c5a r4c4c9f6 74 74 ctx.env.CC = 'llvm-gcc-4.2' 75 75 ctx.env.LINK_CC = 'llvm-gcc-4.2' 76 ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox'] 76 77 77 78 # check for required headers
Note: See TracChangeset
for help on using the changeset viewer.