Pointers

Jamie john <[email protected]>
Newsgroups gmane.comp.programming.swig
Message-ID <[email protected]>
Hi All,



We have this issue with SWIG it was our first time and it all worked perfect apart from pointers!



We wrapped C++ code to use in python we are stuck with this function the audioBuffer pointer is meant to take a 32bit floating array.



DecodeAudioBuffer(float *audioBuffer, int size);





We Used portaudio to record audio to a numpty array:



stream = p.open(format=pyaudio.paInt16, channels=1, rate=RATE, input=True, frames_per_buffer=CHUNKSIZE)



frames = [] # A python-list of chunks(numpy.ndarray)

for _ in range(0, int(RATE / CHUNKSIZE * RECORD_SECONDS)):

    data = stream.read(CHUNKSIZE)

    frames.append(numpy.frombuffer(data, dtype=numpy.int16)) #/ 32768.0



#Convert the list of numpy-arrays into a 1D array (column-wise)

numpydata = numpy.hstack(frames)







/* OxySDK interface */

%module OxySDK



%include "stdint.i"

%include "carrays.i"

%include cpointer.i



%{

#define SWIG_FILE_WITH_INIT

#include "Lib_api.h"

%}



%include "numpy.i"

%init %{

import_array();

%}



%pointer_functions(double ,doubleP)



%include "Lib_api.h"







Any ideas how we can record in python and pass it our pointer

_______________________________________________
Swig-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/swig-user
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.