Changeset 6500367


Ignore:
Timestamp:
Jul 17, 2012, 12:54:51 AM (12 years ago)
Author:
Paul Brossier <piem@piem.org>
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
Message:

generator.py, gen_pyobject.py: more hacks for sink

Location:
interfaces/python
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • interfaces/python/gen_pyobject.py

    r6fd8d7e r6500367  
    2121param_numbers = {
    2222  'source': [0, 2],
     23  'sink':   [2, 0],
    2324}
    2425
     
    145146    'fvec_t*': 'PyAubio_ArrayToCFvec',
    146147    'cvec_t*': 'PyAubio_ArrayToCCvec',
     148    'uint_t': '(uint_t)PyInt_AsLong',
    147149}
    148150
     
    153155    'smpl_t': 'PyFloat_FromDouble',
    154156    'uint_t*': 'PyInt_FromLong',
     157    'uint_t': 'PyInt_FromLong',
    155158}
    156159
     
    275278    pytypes = "".join([aubio2pytypes[p['type']] for p in inputparams])
    276279
    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  "
    281286    inputvecs += "\n  ".join(map(lambda p: p['type'] + ' ' + p['name'] + ";", inputparams))
    282287
    283     parseinput = "/* input vectors parsing */\n  "
     288    parseinput = "  /* input vectors parsing */\n  "
    284289    for p in inputparams:
    285290        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']
    287295        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);
    289298
    290299  if (%(inputvec)s == NULL) {
    291300    return NULL;
    292   }""" % locals()
     301  }
     302
     303  """ % locals()
    293304
    294305    # 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)
    296313    # end of inputs strings
    297314  return inputdefs, parseinput, inputrefs, inputvecs, pytypes
     
    343360    if name in param_numbers.keys():
    344361      n_input_param, n_output_param = param_numbers[name]
     362      print name, n_output_param
    345363    else:
    346364      n_input_param, n_output_param = 1, n_param - 1
  • interfaces/python/generator.py

    r6fd8d7e r6500367  
    4040      'resampler',
    4141      'sndfile',
    42       'sink',
    4342      'sink_apple_audio',
    4443      'sink_sndfile',
Note: See TracChangeset for help on using the changeset viewer.