gpt4 book ai didi

avfoundation - 从 UnsafePointer> 到 Swift 中的 float 组?

转载 作者:IT王子 更新时间:2023-10-29 05:43:02 25 4
gpt4 key购买 nike

我正在尝试访问 AVAudioPCMBuffer.floatChannelData使用 Swift 但它的类型是 UnsafePointer<UnsafePointer<CFloat>> (在 Objective-C 中,@property(nonatomic, readonly) float *const *floatChannelData)并且我访问它的任何尝试都会导致执行失败。

在 Swift Playground 中设置快速 AVAudioPCMBuffer 的示例代码包含在上一个问题中:

Getting AVAudioPCMBuffer working (AVAudioFile.mm error code -50)

最佳答案

这个有用吗?

let channels = UnsafeBufferPointer(start: myAudioBuffer.floatChannelData, count: Int(myAudioBuffer.format.channelCount))
let floats = UnsafeBufferPointer(start: channels[0], count: Int(myAudioBuffer.frameLength))

关于avfoundation - 从 UnsafePointer<UnsafePointer<CFloat>> 到 Swift 中的 float 组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24090119/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com