AudioBufferList highlights in Swift
I am struggling with this API and syntax in Swift
audioBufferList = AudioBufferList(mNumberBuffers: 2, mBuffers: (AudioBuffer))
I don't know what (AudioBuffer) with () means? Any ideas and how to initialize them? This is from the headers:
public struct AudioBufferList {
public var mNumberBuffers: UInt32
public var mBuffers: (AudioBuffer) // this is a variable length array of mNumberBuffers elements
public init()
public init(mNumberBuffers: UInt32, mBuffers: (AudioBuffer))
}
+3
source to share
1 answer
Here is one way to initialize an AudioBufferList with one empty array, a mono buffer that you can pass to Audio Unit calls such as AudioUnitRender (), which then allocates and fills the buffer as needed:
var bufferList = AudioBufferList(
mNumberBuffers: 1,
mBuffers: AudioBuffer(
mNumberChannels: UInt32(1),
mDataByteSize: 1024,
mData: nil))
0
source to share