我目前正在尝试将音频样本从转换AVAudioPCMBuffer
为NSData
- 我已经查看了这个SO Post上接受的答案和来自 GitHub的这段代码,但似乎一些AVFAudio
API 已经改变......下面是我的扩展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
}
}
我看到Value of type 'UnsafePointer<AudioStreamBasicDescription>' has no member 'inTotalBitsPerChannel'
. 到目前为止,我还没有找到任何其他方法来找出inTotalBitsPerChannel
价值......任何帮助表示赞赏!