Changeset 73e068d for python


Ignore:
Timestamp:
Aug 20, 2016, 7:24:11 PM (8 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:
1bd8334
Parents:
eeb4538
Message:

python/lib/gen_code.py: add support for multiple _do outputs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/lib/gen_code.py

    reeb4538 r73e068d  
    8282        'tempo': '1',
    8383        'filterbank': 'self->n_filters',
    84         'tss': 'self->hop_size',
     84        'tss': 'self->buf_size',
    8585        }
    8686
     
    9494        'tempo': 'self->hop_size',
    9595        'wavetable': 'self->hop_size',
     96        'tss': 'self->buf_size / 2 + 1',
    9697        }
    9798
     
    374375        #print input_params
    375376        #print output_params
     377        out += """
     378    PyObject *outputs;"""
    376379        for input_param in input_params:
    377380            out += """
     
    416419
    417420    {do_fn}(self->o, {inputs}, {c_outputs});
    418 
    419     return {outputs};
     421""".format(
     422        do_fn = do_fn,
     423        inputs = inputs, c_outputs = c_outputs,
     424        )
     425        if len(self.do_outputs) > 1:
     426            out += """
     427    outputs = PyTuple_New(2);""".format(len(self.do_outputs))
     428            for i, p in enumerate(self.do_outputs):
     429                out += """
     430    PyTuple_SetItem( outputs, {i}, self->{p[name]});""".format(i = i, p = p)
     431        else:
     432            out += """
     433    outputs = self->{p[name]};""".format(p = self.do_outputs[0])
     434        out += """
     435
     436    return outputs;
    420437}}
    421438""".format(
    422         do_fn = do_fn,
    423         inputs = inputs, outputs = outputs, c_outputs = c_outputs,
     439        outputs = outputs,
    424440        )
    425441        return out
Note: See TracChangeset for help on using the changeset viewer.