使用多个 Taps 的 AudioKit v5

AudioKit v5 using multiple Taps

我希望能够从我的 AudioPlayer 中获取振幅和频谱数据,但由于每个节点只能进行一次点击,我不确定如何在 AudioKit 5 中实现此功能

player = AudioPlayer(file: fileToPlay)!
fftTap = FFTTap(player, bufferSize: 4096, handler: { _ in })
ampTap = AmplitudeTap(player)
ampTap.analysisMode = .peak

do
{
    try engine.start()
    fftTap.start()     // installs this tap on the player bus
    ampTracker.start() // removes the fftTap and installs this one
 }
 catch
 {
    print("Could not start engine: %\(error)")
    return
}

这其实很简单,只需制作多个节点,这些节点只是数据的副本,然后分别点击它们。应该这样做:

player = AudioPlayer(file: fileToPlay)!
let playerCopy = Mixer(player)
fftTap = FFTTap(player, bufferSize: 4096, handler: { _ in })
ampTap = AmplitudeTap(playerCopy)
...