Changeset 96fe713 for interfaces/python/gen_pyobject.py
- Timestamp:
- Dec 5, 2009, 1:44:11 AM (15 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
interfaces/python/gen_pyobject.py
r7a7b00f r96fe713 69 69 # move into the C library at some point. 70 70 defaultsizes = { 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', 85 85 } 86 86 … … 99 99 'hop_size': 'Py_default_vector_length / 2', 100 100 # these should be alright 101 'channels': 'Py_default_vector_channels',102 101 'samplerate': 'Py_aubio_default_samplerate', 103 102 # now for the non obvious ones … … 151 150 newparams = get_params_types_names(newfunc) 152 151 # 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 = '' 154 156 # "param1", "param2", "param3" 155 157 paramnames = ", ".join(["\""+p[1]+"\"" for p in newparams]) … … 179 181 Py_%(name)s_new (PyTypeObject * pytype, PyObject * args, PyObject * kwds) 180 182 { 183 Py_%(name)s *self; 181 184 """ % locals() 182 185 for ptype, pname in newparams: … … 186 189 """ % locals() 187 190 # now the actual PyArg_Parse 188 s += """\189 Py_%(name)s *self;191 if len(paramnames): 192 s += """\ 190 193 static char *kwlist[] = { %(paramnames)s, NULL }; 191 194 … … 194 197 return NULL; 195 198 } 199 """ % locals() 200 s += """\ 196 201 197 202 self = (Py_%(name)s *) pytype->tp_alloc (pytype, 0); … … 238 243 } 239 244 240 AUBIO_INIT(%(name)s , self->%(selfparams)s)245 AUBIO_INIT(%(name)s %(selfparams)s) 241 246 242 247 AUBIO_DEL(%(name)s) … … 287 292 outputvecs = "\n ".join([aubio2pyaubio[p[0]]+" * " + p[-1] + ";" for p in outputparams]) 288 293 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);""" % \294 AUBIO_NEW_VEC(%(name)s, %(pytype)s, %(length)s) 295 %(name)s->o = new_%(autype)s (%(length)s);""" % \ 291 296 {'name': p[-1], 'pytype': aubio2pyaubio[p[0]], 'autype': p[0][:-3], 292 'length': defaultsizes[name] [0], 'channels': defaultsizes[name][1]} \297 'length': defaultsizes[name]} \ 293 298 for p in outputparams]) 294 299 if len(outputparams) > 1:
Note: See TracChangeset
for help on using the changeset viewer.