我真的为一个愚蠢且看似简单的问题而发疯......我必须将 a 转换Data
为AVAudioPCMBuffer
.
看着这个问题似乎很容易,但是 Swift 3 改变了一切。这种被诅咒的语言不断变化(抱歉爆发)!
我有这段代码
let audioBuffer = AVAudioPCMBuffer(pcmFormat: audioFormat!, frameCapacity: UInt32(data.count)/(audioFormat?.streamDescription.pointee.mBytesPerFrame)!)
audioBuffer.frameLength = audioBuffer.frameCapacity
let channels = UnsafeBufferPointer(start: audioBuffer.floatChannelData, count: Int(audioFormat!.channelCount))
data.copyBytes(to: UnsafeMutablePointer<Float>(channels[0]))
但是最后一行给了我这个错误:
Cannot convert value of type 'UnsafeMutablePointer<Float>' to expected
argument type 'UnsafeMutablePointer<_>'
有人可以解决这个问题吗?