I have the following function to process audio data in Obj-C (and then deeper in C++):
- (void) audioProcess: (int) numChannels
numSamples: (int) numSamples
stride: (int) stride
data: (float * const *) data;
This signature is classic for processing audio buffer data stored in contiguous memory. It could be interleaved or not, depending on the buffer.
Then in Swift, I want to process an audio buffer like so:
let buffer = ... // get AVAudioPCMBuffer from somewhere
if let floatChannelData = buffer.floatChannelData {
audioProcess(Int32(buffer.format.channelCount),
numSamples: Int32(buffer.frameLength),
stride: Int32(buffer.stride),
data: floatChannelData)
}
I get the following compilation error:
- Cannot convert value of type
'UnsafePointer<UnsafeMutablePointer<Float>>'
to expected argument type'UnsafePointer<UnsafeMutablePointer<Float>?>'
Notice the difference in optionality of the UnsafeMutablePointer<Float>
.
How can I pass the floatChannelData from Swift to Obj-C (C++)?
Edit: typos