i want to convert unsafemutablepointer to data, here is my sample code
let u8ptr: UnsafeMutablePointer<UInt8> = buffer.mData!.assumingMemoryBound(to: UInt8.self)
I am trying to convert AudioBuffer to NSData or Data. Any help is appreciated.
When working with AudioBuffer, the byte size of the data is given int the property mDataByteSize. And when creating a Data, you have no need to convert the pointer type using assumingMemoryBound.
let data = Data(bytes: buffer.mData!, count: Int(buffer.mDataByteSize))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With