I've created a shared library. And I'm using it like that
class CAudioRecoveryStrategy(AbstractAudioRecoveryStrategy):
def __init__(self):
array_1d_double = npct.ndpointer(dtype=numpy.double, ndim=1, flags='CONTIGUOUS')
self.lib = npct.load_library("libhello", ".")
self.lib.demodulate.argtypes = [array_1d_double, array_1d_double, ctypes.c_int]
def demodulate(self, input):
output = numpy.empty_like(input)
self.lib.demodulate(input, output, input.size)
return output
Right now I have a problem, which is in c++ code I only have pointer to array of output data, not the array. So I can't return the array, unless I manually copy it.
What is the right way to do it? It must be efficient (like aligned memory etc.)