Changeset 09b1777


Ignore:
Timestamp:
Oct 21, 2009, 3:40:23 PM (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:
3ad2ef6
Parents:
1f8e522
Message:

gen_pyobject.py: fix initialisation of strings and tempo output size

File:
1 edited

Legend:

Unmodified
Added
Removed
  • interfaces/python/gen_pyobject.py

    r1f8e522 r09b1777  
    4141    'mfcc':         ('self->n_coeffs', 'in->channels'),
    4242    'beattracking': ('self->winlen', 'self->channels'),
    43     'tempo':        ('self->buf_size', 'self->channels'),
     43    'tempo':        ('1', 'self->channels'),
    4444    'peakpicker':   ('1', 'self->channels'),
    4545}
     
    147147""" % locals()
    148148    for ptype, pname in newparams:
    149         defval = aubioinitvalue[ptype]
     149        initval = aubioinitvalue[ptype]
    150150        s += """\
    151   %(ptype)s %(pname)s = %(defval)s;
    152 """ % locals()
     151  %(ptype)s %(pname)s = %(initval)s;
     152""" % locals()
     153    # now the actual PyArg_Parse
    153154    s += """\
    154155  Py_%(name)s *self;
     
    169170    for ptype, pname in newparams:
    170171        defval = aubiodefvalue[pname]
    171         s += """\
     172        if ptype == 'char_t*':
     173            s += """\
     174
     175  self->%(pname)s = %(defval)s;
     176  if (%(pname)s != NULL) {
     177    self->%(pname)s = %(pname)s;
     178  }
     179""" % locals()
     180        elif ptype == 'uint_t':
     181            s += """\
    172182
    173183  self->%(pname)s = %(defval)s;
     
    176186  } else if (%(pname)s < 0) {
    177187    PyErr_SetString (PyExc_ValueError,
    178         "can not use negative window size");
    179     return NULL;
    180   }
    181 """ % locals()
     188        "can not use negative value for %(pname)s");
     189    return NULL;
     190  }
     191""" % locals()
     192        elif ptype == 'smpl_t':
     193            s += """\
     194
     195  self->%(pname)s = %(defval)s;
     196  if (%(pname)s != %(defval)s) {
     197    self->%(pname)s = %(pname)s;
     198  }
     199""" % locals()
     200        else:
     201            print "ERROR, unknown type of parameter %s %s" % (ptype, pname)
    182202    s += """\
    183203
     
    280300AUBIO_MEMBERS_START(%(name)s)""" % locals()
    281301    for param in newparams:
    282         s += """
     302        if param[0] == 'char_t*':
     303            s += """
     304  {"%(pname)s", T_STRING, offsetof (Py_%(name)s, %(pname)s), READONLY, ""},""" \
     305        % { 'pname': param[1], 'ptype': param[0], 'name': name}
     306        elif param[0] == 'uint_t':
     307            s += """
    283308  {"%(pname)s", T_INT, offsetof (Py_%(name)s, %(pname)s), READONLY, ""},""" \
    284309        % { 'pname': param[1], 'ptype': param[0], 'name': name}
     310        else:
     311            print "-- ERROR, unknown member type ", param
    285312    s += """
    286313AUBIO_MEMBERS_STOP(%(name)s)
Note: See TracChangeset for help on using the changeset viewer.