Swig + Numpy.i with a const int16_t pointer
Christian Gollwitzer
auriocus at gmx.de
Thu Nov 12 04:17:38 EST 2015
Am 12.11.15 um 10:16 schrieb Christian Gollwitzer:
> Am 12.11.15 um 09:46 schrieb Christian Gollwitzer:
>> Am 11.11.15 um 02:09 schrieb shriphanip at gmail.com:
>>> I am trying to wrap the following function with SWIG so I can call it
>>> from Python. The signature is:
>>>
>>> ```
>>> int WebRtcVad_Process(VadInst* handle, int fs, const int16_t*
>>> audio_frame, size_t frame_length);
>>> ```
>>
>> This is thing is an array of 16 bit unsigned integers for input. The
>> closest object in Python is a numpy array. There is a numpy.i available
>> for Python, I'm not sure if it handles this case correctly. If you are
>> unlucky, you need to write your own typemap.
>
> http://docs.scipy.org/doc/numpy/reference/swig.interface-file.html
>
> It seems that you can create your own typemap easily using the macros
> provided by numpy.i; something like
>
> %numpy_typemaps(int16_t, NPY_UINT16, int)
>
> should be sufficient.
That should be
%numpy_typemaps(int16_t, NPY_INT16, int)
of course.
More information about the Python-list
mailing list