The first few lines of this code generate audio noise of arbitrary length. What would be the equivalent for generation of uncompressed video noise (analog tv static)?
import AVFoundation
let srcNode = AVAudioSourceNode { _, _, frameCount, bufferList in
for frame in 0..<Int(frameCount) {
let buf: UnsafeMutableBufferPointer<Float> =
UnsafeMutableBufferPointer(bufferList.pointee.mBuffers)
buf[frame] = Float.random(in: -1...1)
}
return noErr
}
let engine = AVAudioEngine()
let output = engine.outputNode
let format = output.inputFormat(forBus: 0)
engine.attach(srcNode)
engine.connect(srcNode, to: output, format: format)
try? engine.start()
CFRunLoopRunInMode(.defaultMode, CFTimeInterval(5.0), false)
engine.stop()