Ignore:
Timestamp:
Dec 5, 2009, 1:44:11 AM (15 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:
0f045b2
Parents:
7a7b00f
Message:

interfaces/python: towards mono

File:
1 edited

Legend:

Unmodified
Added
Removed
  • interfaces/python/gen_pyobject.py

    r7a7b00f r96fe713  
    6969# move into the C library at some point.
    7070defaultsizes = {
    71     'resampler':    ('input->length * self->ratio', 'input->channels'),
    72     'specdesc':     ('1', 'fftgrain->channels'),
    73     'onset':        ('1', 'self->channels'),
    74     'pitchyin':     ('1', 'in->channels'),
    75     'pitchyinfft':  ('1', 'in->channels'),
    76     'pitchschmitt': ('1', 'in->channels'),
    77     'pitchmcomb':   ('1', 'self->channels'),
    78     'pitchfcomb':   ('1', 'self->channels'),
    79     'pitch':        ('1', 'self->channels'),
    80     'tss':          ('self->hop_size', 'self->channels'),
    81     'mfcc':         ('self->n_coeffs', 'in->channels'),
    82     'beattracking': ('self->hop_size', 'self->channels'),
    83     'tempo':        ('1', 'self->channels'),
    84     'peakpicker':   ('1', 'self->channels'),
     71    'resampler':    'input->length * self->ratio',
     72    'specdesc':     '1',
     73    'onset':        '1',
     74    'pitchyin':     '1',
     75    'pitchyinfft':  '1',
     76    'pitchschmitt': '1',
     77    'pitchmcomb':   '1',
     78    'pitchfcomb':   '1',
     79    'pitch':        '1',
     80    'tss':          'self->hop_size',
     81    'mfcc':         'self->n_coeffs',
     82    'beattracking': 'self->hop_size',
     83    'tempo':        '1',
     84    'peakpicker':   '1',
    8585}
    8686
     
    9999    'hop_size': 'Py_default_vector_length / 2',
    100100    # these should be alright
    101     'channels': 'Py_default_vector_channels',
    102101    'samplerate': 'Py_aubio_default_samplerate',
    103102    # now for the non obvious ones
     
    151150    newparams = get_params_types_names(newfunc)
    152151    # self->param1, self->param2, self->param3
    153     selfparams = ', self->'.join([p[1] for p in newparams])
     152    if len(newparams):
     153        selfparams = ', self->'+', self->'.join([p[1] for p in newparams])
     154    else:
     155        selfparams = ''
    154156    # "param1", "param2", "param3"
    155157    paramnames = ", ".join(["\""+p[1]+"\"" for p in newparams])
     
    179181Py_%(name)s_new (PyTypeObject * pytype, PyObject * args, PyObject * kwds)
    180182{
     183  Py_%(name)s *self;
    181184""" % locals()
    182185    for ptype, pname in newparams:
     
    186189""" % locals()
    187190    # now the actual PyArg_Parse
    188     s += """\
    189   Py_%(name)s *self;
     191    if len(paramnames):
     192        s += """\
    190193  static char *kwlist[] = { %(paramnames)s, NULL };
    191194
     
    194197    return NULL;
    195198  }
     199""" % locals()
     200    s += """\
    196201
    197202  self = (Py_%(name)s *) pytype->tp_alloc (pytype, 0);
     
    238243}
    239244
    240 AUBIO_INIT(%(name)s, self->%(selfparams)s)
     245AUBIO_INIT(%(name)s %(selfparams)s)
    241246
    242247AUBIO_DEL(%(name)s)
     
    287292        outputvecs = "\n  ".join([aubio2pyaubio[p[0]]+" * " + p[-1] + ";" for p in outputparams])
    288293        outputcreate = "\n  ".join(["""\
    289 AUBIO_NEW_VEC(%(name)s, %(pytype)s, %(length)s, %(channels)s)
    290   %(name)s->o = new_%(autype)s (%(length)s, %(channels)s);""" % \
     294AUBIO_NEW_VEC(%(name)s, %(pytype)s, %(length)s)
     295  %(name)s->o = new_%(autype)s (%(length)s);""" % \
    291296    {'name': p[-1], 'pytype': aubio2pyaubio[p[0]], 'autype': p[0][:-3],
    292         'length': defaultsizes[name][0], 'channels': defaultsizes[name][1]} \
     297        'length': defaultsizes[name]} \
    293298        for p in outputparams])
    294299        if len(outputparams) > 1:
Note: See TracChangeset for help on using the changeset viewer.