平移 AudioKit 的 AKMetronome

Panning AudioKit's AKMetronome

我正在制作一个节拍器应用程序,我需要将一个节拍器向左平移,另一个向右平移。我知道 AKMetronome class 没有声像 属性,但是谁能建议我可以做到这一点?

 let mixer = AKMixer(metronome, metronome2)

 AudioKit.output = mixer
 try AudioKit.start()
 metronome.start()
 metronome2.start()

以上代码有效,但两个节拍器都居中。谢谢

A​​KPanner 可以解决问题:

https://audiokit.io/docs/Classes/AKPanner.html

https://github.com/AudioKit/AudioKit/blob/master/AudioKit/Common/Nodes/Mixing/Panner/AKPanner.swift

let leftPan = AKPanner(metronome)
leftPan.pan = -1

let rightPan = AKPanner(metronome2)
rightPan.pan = 1

let mixer = AKMixer(leftPan, rightPan)