Changes in / [4c4c9f6:7d50c5a]
- Files:
-
- 2 added
- 24 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/utils.h
r4c4c9f6 r7d50c5a 28 28 #include <aubio.h> 29 29 #include "config.h" 30 #include "sndfileio.h" 30 31 #ifdef HAVE_JACK 31 32 #include "jackio.h" -
examples/wscript_build
r4c4c9f6 r7d50c5a 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 4 9 utilsio = ctx.new_task_gen(name = 'utilsio', features = 'c', 5 10 includes = '../src', 11 add_objects = 'sndfileio', 6 12 source = ['utils.c', 'jackio.c'], 7 uselib = ['LASH', 'JACK' ],13 uselib = ['LASH', 'JACK', 'SNDFILE'], 8 14 target = 'utilsio') 9 15 10 16 # loop over all *.c filenames in examples to build them all 11 for target_name in ctx.path.ant_glob('*.c', excl = ['utils.c', 'jackio.c' ]):17 for target_name in ctx.path.ant_glob('*.c', excl = ['utils.c', 'jackio.c', 'sndfileio.c']): 12 18 ctx.new_task_gen(features = 'c cprogram', 13 19 add_objects = 'utilsio', -
interfaces/python/gen_pyobject.py
r4c4c9f6 r7d50c5a 18 18 maintaining this bizarre file. 19 19 """ 20 21 param_numbers = {22 'source': [0, 2],23 'sink': [2, 0],24 }25 20 26 21 # TODO … … 86 81 # move into the C library at some point. 87 82 defaultsizes = { 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'], 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', 103 97 } 104 98 … … 129 123 'ratio': '0.5', 130 124 'method': '"default"', 131 'uri': '"none"',132 125 } 133 126 … … 146 139 'fvec_t*': 'PyAubio_ArrayToCFvec', 147 140 'cvec_t*': 'PyAubio_ArrayToCCvec', 148 'uint_t': '(uint_t)PyInt_AsLong',149 141 } 150 142 … … 154 146 'cvec_t*': 'PyAubio_CCvecToPyCvec', 155 147 'smpl_t': 'PyFloat_FromDouble', 156 'uint_t*': 'PyInt_FromLong',157 'uint_t': 'PyInt_FromLong',158 148 } 159 149 … … 267 257 return s 268 258 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_ParseTuple278 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 references306 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 strings314 return inputdefs, parseinput, inputrefs, inputvecs, pytypes315 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" % params328 else:329 outputvecs += " " + p['type'] + ' ' + p['name'] + ";\n"330 outputcreate += " /* creating output %(name)s as a new_%(autype)s of length %(length)s */\n" % params331 outputcreate += " %(name)s = new_%(autype)s (%(length)s);\n" % params332 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 strings347 return outputvecs, outputcreate, returnval348 349 259 def gen_do(dofunc, name): 350 260 funcname = dofunc.split()[1].split('(')[0] … … 355 265 # and remove it 356 266 doparams = doparams[1:] 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 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 298 299 # 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'] + ")" 363 325 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) 373 374 # build strings for outputs 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 375 333 # 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() 389 else: 390 arg_parse_tuple = "" 334 doparams_string = "self->o, " + ", ".join([p['name'] for p in doparams]) 335 391 336 # put it all together 392 337 s = """\ … … 395 340 Py_%(name)s_do(Py_%(name)s * self, PyObject * args) 396 341 { 397 %(inputdefs)s 398 %(inputvecs)s 399 %(outputvecs)s 400 401 %(arg_parse_tuple)s 402 403 %(parseinput)s 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 404 351 405 %(outputcreate)s352 %(outputcreate)s 406 353 407 354 /* compute _do function */ 408 355 %(funcname)s (%(doparams_string)s); 409 356 410 %(returnval)s;357 %(returnval)s; 411 358 } 412 359 """ % locals() -
interfaces/python/generator.py
r4c4c9f6 r7d50c5a 34 34 generated_objects = [] 35 35 cpp_output, cpp_objects = get_cpp_objects() 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'] 36 skip_objects = ['fft', 'pvoc', 'filter', 'filterbank', 'resampler'] 46 37 47 38 write_msg("-- INFO: %d objects in total" % len(cpp_objects)) -
src/aubio.h
r4c4c9f6 r7d50c5a 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"184 177 185 178 #if AUBIO_UNSTABLE -
src/wscript_build
r4c4c9f6 r7d50c5a 1 1 # vim:set syntax=python: 2 2 3 source = ctx.path.ant_glob('*.c **/*.c') 4 uselib = [] 5 3 uselib = ['SAMPLERATE'] 6 4 if 'HAVE_FFTW3' in conf.get_env(): 7 source .filter(lambda x: not x.endswith('ooura_fft8g.c'))5 source = ctx.path.ant_glob('*.c **/*.c', excl = ['**/ooura_fft8g.c']) 8 6 uselib += ['FFTW3', 'FFTW3F'] 9 10 if 'HAVE_SAMPLERATE': 11 uselib += ['SAMPLERATE'] 12 13 if 'HAVE_SNDFILE': 14 uselib += ['SNDFILE'] 7 else: 8 source = ctx.path.ant_glob('*.c **/*.c') 15 9 16 10 # build libaubio -
wscript
r4c4c9f6 r7d50c5a 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']77 76 78 77 # check for required headers
Note: See TracChangeset
for help on using the changeset viewer.