I'm trying to access a AVAudioPCMBuffer.floatChannelData and getting a EXEC_BAD_ACCESS error when setting the frameLength above a certain value. I initially set frameLength to 16384 no problems there. I tried increasing it to 44100 - figuring this would make my buffer exactly 1 second long with a sampleRate of 44100. When going to lower values, I'm getting choppy audio from the buffer (not sure why, but one issue at a time i guess). The format of the Buffer should be UnsafePointer<UnsafeMutablePointer<Float>>. The floatChannelData should have the 'counts' of buffer[channels][frameLength].
buffer : AVAudioPCMBuffer
init(){
//set my format
let format = AVAudioFormat(commonFormat: AVAudioCommonFormat.pcmFormatFloat32,
sampleRate: 44100.0,
channels: 1,
interleaved: true)!
let frameLength = 44100
audioPlayerNode = AVAudioPlayerNode()
buffer = AVAudioPCMBuffer(pcmFormat: format, frameCapacity: frameLength)!
audioInputNode.installTap(onBus: 0, bufferSize:frameLength, format: format, block: {(buffer, time) in
let channels = buffer.floatChannelData
let floats = channels![0]
for i in stride(from:0, to:Int(self.activeBuffer.frameLength), by: Int(self.audioMixerNode.outputFormat(forBus: 0).channelCount)){
self.activeBuffer.floatChannelData![0][i] = floats[i] //get EXEC_BAD_ACCESS at index 17408
}
})
}```