Using AudioBufferList with Swift

前端 未结 4 1405
野的像风
野的像风 2020-12-05 07:51

I have a bridging function in Swift, one of whose arguments in C is AudioBufferList *. In Swift this generates an UnsafePointer

4条回答
  •  没有蜡笔的小新
    2020-12-05 08:18

    I've found this works OK. abl is an AudioBufferList created from loading a 16bit AIFF audio file.

    let mBuffers=abl.memory.mBuffers
    
    let data=UnsafePointer(mBuffers.mData)
    let dataArray=UnsafeBufferPointer(start:data, count: Int(mBuffers.mDataByteSize)/sizeof(Int16))
    
    //checking resulting array
    let count=dataArray.count //this matches the expected number of samples in my case
    for i in 0..

提交回复
热议问题