import numpy as np
import ctypes

class FAUSTDsp(object):

    def __init__(self, C, ffi, fs, faust_ui):

        self.__C   = C
        self.__ffi = ffi
        self.__dsp = C.newmydsp()

        # calls both classInitmydsp() and instanceInitmydsp()
        C.initmydsp(self.__dsp, fs)
        UI = faust_ui(self.__ffi, self)
        C.buildUserInterfacemydsp(self.__dsp, UI.ui)

        # self.__meta = MetaGlue()
        # self._metadata = C.metadatamydsp(meta)

    def __del__(self):

        self.__C.deletemydsp(self.__dsp)

    def compute(self, audio):

        audio = np.atleast_2d(audio)

        count = audio.shape[1]

        output = np.ndarray(audio.shape, dtype=np.float32)
        # ctypes.c_float.from_buffer(output)
        output_p = self.__ffi.new("float*[]", audio.shape[0])
        output_p[0] = self.__ffi.cast('float *', ctypes.addressof(ctypes.c_float.from_buffer(output[0])))

        input_p  = self.__ffi.new("float*[]", audio.shape[0])
        input_p[0] = self.__ffi.cast('float *', ctypes.addressof(ctypes.c_float.from_buffer(audio[0])))

        self.__C.computemydsp(self.__dsp, count, input_p, output_p)

        return output

    fs = property(fget=lambda s: s.__C.getSampleRatemydsp(s.__dsp))
    num_in = property(fget=lambda s: s.__C.getNumInputsmydsp(s.__dsp))
    num_out = property(fget=lambda s: s.__C.getNumOutputsmydsp(s.__dsp))

@@ -757,37 +757,42 @@
 self.__ffi.new(%22
-float
+FAUSTFLOAT
 *%5B%5D%22, audio.shap
@@ -828,37 +828,42 @@
 elf.__ffi.cast('
-float
+FAUSTFLOAT
  *', ctypes.addr
@@ -944,21 +944,26 @@
 fi.new(%22
-float
+FAUSTFLOAT
 *%5B%5D%22, au
@@ -1014,21 +1014,26 @@
 i.cast('
-float
+FAUSTFLOAT
  *', cty

use type "FAUSTFLOAT" instead of "float".