Changes in / [c6c9fe9:c43c459]


Ignore:
Files:
2 added
23 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • examples/utils.h

    rc6c9fe9 rc43c459  
    2828#include <aubio.h>
    2929#include "config.h"
     30#include "sndfileio.h"
    3031#ifdef HAVE_JACK
    3132#include "jackio.h"
  • examples/wscript_build

    rc6c9fe9 rc43c459  
    22
    33# build examples
     4sndfileio = ctx.new_task_gen(features = 'c',
     5    includes = '../src',
     6    source = ['sndfileio.c'],
     7    target = 'sndfileio')
     8
    49utilsio = ctx.new_task_gen(name = 'utilsio', features = 'c',
    510      includes = '../src',
     11      add_objects = 'sndfileio',
    612      source = ['utils.c', 'jackio.c'],
    7       uselib = ['LASH', 'JACK'],
     13      uselib = ['LASH', 'JACK', 'SNDFILE'],
    814      target = 'utilsio')
    915
    1016# 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']):
     17for target_name in ctx.path.ant_glob('*.c', excl = ['utils.c', 'jackio.c', 'sndfileio.c']):
    1218  ctx.new_task_gen(features = 'c cprogram',
    1319      add_objects = 'utilsio',
  • interfaces/python/gen_pyobject.py

    rc6c9fe9 rc43c459  
    1818maintaining this bizarre file.
    1919"""
    20 
    21 param_numbers = {
    22   'source': [0, 2],
    23 }
    2420
    2521# TODO
     
    8581# move into the C library at some point.
    8682defaultsizes = {
    87     'resampler':    ['input->length * self->ratio'],
    88     'specdesc':     ['1'],
    89     'onset':        ['1'],
    90     'pitchyin':     ['1'],
    91     'pitchyinfft':  ['1'],
    92     'pitchschmitt': ['1'],
    93     'pitchmcomb':   ['1'],
    94     'pitchfcomb':   ['1'],
    95     'pitch':        ['1'],
    96     'tss':          ['self->hop_size', 'self->hop_size'],
    97     'mfcc':         ['self->n_coeffs'],
    98     'beattracking': ['self->hop_size'],
    99     'tempo':        ['1'],
    100     'peakpicker':   ['1'],
    101     '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',
    10297}
    10398
     
    128123    'ratio': '0.5',
    129124    'method': '"default"',
    130     'uri': '"none"',
    131125    }
    132126
     
    152146    'cvec_t*': 'PyAubio_CCvecToPyCvec',
    153147    'smpl_t': 'PyFloat_FromDouble',
    154     'uint_t*': 'PyInt_FromLong',
    155148}
    156149
     
    264257    return s
    265258
    266 def gen_do_input_params(inputparams):
    267   inputdefs = ''
    268   parseinput = ''
    269   inputrefs = ''
    270   inputvecs = ''
    271   pytypes = ''
    272 
    273   if len(inputparams):
    274     # build the parsing string for PyArg_ParseTuple
    275     pytypes = "".join([aubio2pytypes[p['type']] for p in inputparams])
    276 
    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  "
    281     inputvecs += "\n  ".join(map(lambda p: p['type'] + ' ' + p['name'] + ";", inputparams))
    282 
    283     parseinput = "/* input vectors parsing */\n  "
    284     for p in inputparams:
    285         inputvec = p['name']
    286         inputdef = p['name'] + "_obj"
    287         converter = aubiovecfrompyobj[p['type']]
    288         parseinput += """%(inputvec)s = %(converter)s (%(inputdef)s);
    289 
    290   if (%(inputvec)s == NULL) {
    291     return NULL;
    292   }""" % locals()
    293 
    294     # build the string for the input objects references
    295     inputrefs = ", ".join(["&" + p['name'] + "_obj" for p in inputparams])
    296     # end of inputs strings
    297   return inputdefs, parseinput, inputrefs, inputvecs, pytypes
    298 
    299 def gen_do_output_params(outputparams, name):
    300   outputvecs = ""
    301   outputcreate = ""
    302   if len(outputparams):
    303     outputvecs = "  /* output vectors prototypes */\n"
    304     for p in outputparams:
    305       params = {
    306         'name': p['name'], 'pytype': p['type'], 'autype': p['type'][:-3],
    307         'length': defaultsizes[name].pop(0) }
    308       if (p['type'] == 'uint_t*'):
    309         outputvecs += '  uint_t' + ' ' + p['name'] + ";\n"
    310         outputcreate += "  %(name)s = 0;\n" % params
    311       else:
    312         outputvecs += "  " + p['type'] + ' ' + p['name'] + ";\n"
    313         outputcreate += "  /* creating output %(name)s as a new_%(autype)s of length %(length)s */\n" % params
    314         outputcreate += "  %(name)s = new_%(autype)s (%(length)s);\n" % params
    315 
    316   returnval = "";
    317   if len(outputparams) > 1:
    318     returnval += "  PyObject *outputs = PyList_New(0);\n"
    319     for p in outputparams:
    320       returnval += "  PyList_Append( outputs, (PyObject *)" + aubiovectopyobj[p['type']] + " (" + p['name'] + ")" +");\n"
    321     returnval += "  return outputs;"
    322   elif len(outputparams) == 1:
    323     if defaultsizes[name] == '1':
    324       returnval += "  return (PyObject *)PyFloat_FromDouble(" + p['name'] + "->data[0])"
    325     else:
    326       returnval += "  return (PyObject *)" + aubiovectopyobj[p['type']] + " (" + p['name'] + ")"
    327   else:
    328     returnval = "  return Py_None;";
    329   # end of output strings
    330   return outputvecs, outputcreate, returnval
    331 
    332259def gen_do(dofunc, name):
    333260    funcname = dofunc.split()[1].split('(')[0]
     
    338265    # and remove it
    339266    doparams = doparams[1:]
    340 
    341     n_param = len(doparams)
    342 
    343     if name in param_numbers.keys():
    344       n_input_param, n_output_param = param_numbers[name]
     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'] + ")"
    345325    else:
    346       n_input_param, n_output_param = 1, n_param - 1
    347 
    348     assert n_output_param + n_input_param == n_param, "n_output_param + n_input_param != n_param for %s" % name
    349 
    350     inputparams = doparams[:n_input_param]
    351     outputparams = doparams[n_input_param:n_input_param + n_output_param]
    352 
    353     inputdefs, parseinput, inputrefs, inputvecs, pytypes = gen_do_input_params(inputparams);
    354     outputvecs, outputcreate, returnval = gen_do_output_params(outputparams, name)
    355 
    356     # 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
    357333    # build the parameters for the  _do() call
    358     doparams_string = "self->o"
    359     for p in doparams:
    360       if p['type'] == 'uint_t*':
    361         doparams_string += ", &" + p['name']
    362       else:
    363         doparams_string += ", " + p['name']
    364 
    365     if n_input_param:
    366       arg_parse_tuple = """\
    367   if (!PyArg_ParseTuple (args, "%(pytypes)s", %(inputrefs)s)) {
    368     return NULL;
    369   }
    370 """ % locals()
    371     else:
    372       arg_parse_tuple = ""
     334    doparams_string = "self->o, " + ", ".join([p['name'] for p in doparams])
     335
    373336    # put it all together
    374337    s = """\
     
    377340Py_%(name)s_do(Py_%(name)s * self, PyObject * args)
    378341{
    379 %(inputdefs)s
    380 %(inputvecs)s
    381 %(outputvecs)s
    382 
    383 %(arg_parse_tuple)s
    384 
    385 %(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
    386351 
    387 %(outputcreate)s
     352  %(outputcreate)s
    388353
    389354  /* compute _do function */
    390355  %(funcname)s (%(doparams_string)s);
    391356
    392 %(returnval)s;
     357  %(returnval)s;
    393358}
    394359""" % locals()
  • interfaces/python/generator.py

    rc6c9fe9 rc43c459  
    3232  generated_objects = []
    3333  cpp_output, cpp_objects = get_cpp_objects()
    34   skip_objects = ['fft',
    35       'pvoc',
    36       'filter',
    37       'filterbank',
    38       'resampler',
    39       'sndfile',
    40       'sink',
    41       'sink_apple_audio',
    42       'sink_sndfile',
    43       'source_apple_audio',
    44       'source_sndfile']
     34  skip_objects = ['fft', 'pvoc', 'filter', 'filterbank', 'resampler']
    4535
    4636  write_msg("-- INFO: %d objects in total" % len(cpp_objects))
  • src/aubio.h

    rc6c9fe9 rc43c459  
    175175#include "onset/peakpicker.h"
    176176#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"
    184177
    185178#if AUBIO_UNSTABLE
  • src/wscript_build

    rc6c9fe9 rc43c459  
    11# vim:set syntax=python:
    22
    3 source = ctx.path.ant_glob('*.c **/*.c')
    4 uselib = []
    5 
     3uselib = ['SAMPLERATE']
    64if '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'])
    86  uselib += ['FFTW3', 'FFTW3F']
    9 
    10 if 'HAVE_SAMPLERATE':
    11   uselib += ['SAMPLERATE']
    12 
    13 if 'HAVE_SNDFILE':
    14   uselib += ['SNDFILE']
     7else:
     8  source = ctx.path.ant_glob('*.c **/*.c')
    159
    1610# build libaubio
  • wscript

    rc6c9fe9 rc43c459  
    7474    ctx.env.CC = 'llvm-gcc-4.2'
    7575    ctx.env.LINK_CC = 'llvm-gcc-4.2'
    76     ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox']
    7776
    7877  # check for required headers
Note: See TracChangeset for help on using the changeset viewer.