我已经实现installTap
了方法,它为我提供了音频缓冲区浮点样本。我已经通过我的 C++ DSP 库过滤了它们。我想将此缓冲区“发送”到耳机/扬声器。我AVAudioPCMBuffer
又从样品中做了一次。有谁知道该怎么做?
代码:
node.installTap(onBus: bus, bufferSize: AVAudioFrameCount(BUFFER_SIZE), format: node.inputFormat(forBus: bus), block: { (buffer : AVAudioPCMBuffer ,time : AVAudioTime) in
let root = buffer.floatChannelData!.pointee
// First pointer defines chanels
// Second pointer defines floats values
for i in 0 ..< BUFFER_SIZE{
self.signalData[i] = Double(root.advanced(by: i).pointee) * self.gainCorrection
}
let signalDataPreEq = self.signalData
let filteredSignal = shared.EQ.filterBuffer(UnsafeMutablePointer<Double>(mutating: self.signalData), with_count: Int32(BUFFER_SIZE))
self.signalData = Array(UnsafeBufferPointer(start : filteredSignal, count : BUFFER_SIZE))
for i in 0 ..< BUFFER_SIZE{
root.advanced(by: i).pointee = Float(self.signalData[i])
}
// HERE I WANT TO LISTEN(PLAYBACK) AUDIO FROM BUFFER
谢谢