I'm trying to call the function DSPSplitComplex
:
var real = [Float](input_windowed)
var imaginary = [Float](repeating: 0.0, count: input_windowed.count)
var splitComplex = DSPSplitComplex(realp: &real, imagp: &imaginary)
but that gives the warning:
Cannot use inout expression here; argument 'realp' must be a pointer that outlives the call to 'init(realp:imagp:)'
so after that I tried:
var splitComplex = DSPSplitComplex(
realp: UnsafeMutablePointer(mutating: real),
imagp: UnsafeMutablePointer(mutating: imaginary) )
and that gives the warning:
Initialization of 'UnsafeMutablePointer<Float>' results in a dangling pointer
so finally I tried this:
var splitComplex =
withUnsafeMutablePointer(to: &real) { realpPtr in
withUnsafeMutablePointer(to: &imaginary) { imaginaryPtr in
DSPSplitComplex(realp: realpPtr, imagp: imaginaryPtr)
}
}
and that gives the following compile error:
Cannot convert value of type 'UnsafeMutablePointer<[Float]>' to expected argument type 'UnsafeMutablePointer<Float>'
What is the correct way to call this function (and similar functions in the Accelerate framework) ?