You can create a new buffer that's a segment of the original. AVAudioPCMBuffer and AudioBufferlist are kind of a pain in Swift. There are a few ways to do this, if you are using floats you can access AVAUdioPCMBuffer.floatChannelData, but here's a method that works for both float and int samples.
func segment(of buffer: AVAudioPCMBuffer, from startFrame: AVAudioFramePosition, to endFrame: AVAudioFramePosition) -> AVAudioPCMBuffer? {
let framesToCopy = AVAudioFrameCount(endFrame - startFrame)
guard let segment = AVAudioPCMBuffer(pcmFormat: buffer.format, frameCapacity: framesToCopy) else { return nil }
let sampleSize = buffer.format.streamDescription.pointee.mBytesPerFrame
let srcPtr = UnsafeMutableAudioBufferListPointer(buffer.mutableAudioBufferList)
let dstPtr = UnsafeMutableAudioBufferListPointer(segment.mutableAudioBufferList)
for (src, dst) in zip(srcPtr, dstPtr) {
memcpy(dst.mData, src.mData?.advanced(by: Int(startFrame) * Int(sampleSize)), Int(framesToCopy) * Int(sampleSize))
}
segment.frameLength = framesToCopy
return segment
}