I'm currently trying to convert the audio samples from AVAudioPCMBuffer
to NSData
- I had taken a look at the accepted answer on this SO Post and this code from GitHub but it appears some of the AVFAudio
API's have changed...below is the extension I have for AVAudioPCMBuffer
:
private extension AVAudioPCMBuffer {
func toNSData() -> NSData {
let channels = UnsafeBufferPointer(start: int16ChannelData, count: 1)
let ch0Data = NSData(bytes: channels[0], length:Int(frameCapacity * format.streamDescription.inTotalBitsPerChannel))
return ch0Data
}
}
I'm seeing an error of Value of type 'UnsafePointer<AudioStreamBasicDescription>' has no member 'inTotalBitsPerChannel'
. So far, I've not been able to find out any other way to find out the inTotalBitsPerChannel
value...any help appreciated!