我使用AudioKit *** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'player started when in a disconnected state'
收到此崩溃当我以一个顺序创建和添加节点但在我以其他顺序添加节点时不会发生这种情况。这是理想的链条:
[player] - > [booster1] - > [mixer1] - > [booster2] - > [mixer2] - > [peak limiter] - > [output]
当我按此顺序构建它时,它会崩溃:
let mixer2 = AKMixer()
let peakLimiter = AKPeakLimiter(mixer2)
AudioKit.output = peakLimiter
AudioKit.start()
let mixer1 = AKMixer()
let booster2 = AKBooster(mixer1)
mixer2.connect(input: booster2)
let booster1 = AKBooster(player)
mixer1.connect(input: booster1)
player.play()
但是当我按照这个顺序构建它时,它可以工作:
let booster1 = AKBooster(player)
let mixer1 = AKMixer()
mixer1.connect(input: booster1)
let booster2 = AKBooster(mixer1)
let mixer2 = AKMixer()
mixer2.connect(input: booster2)
let peakLimiter = AKPeakLimiter(mixer2)
AudioKit.output = peakLimiter
AudioKit.start()
player.play()
任何想法为什么?由于应用程序中的动态原因,第一个示例(崩溃)是它需要的创建顺序。
同样奇怪的是,如果我使用第一个创建顺序示例并省略第二个助推器,它可以工作。 [player] - > [booster1] - > [mixer1] - > [mixer2] - > [peak limiter] - > [output]
let mixer2 = AKMixer()
let peakLimiter = AKPeakLimiter(mixer2)
AudioKit.output = peakLimiter
AudioKit.start()
let mixer1 = AKMixer()
mixer2.connect(input: mixer1)
let booster1 = AKBooster(player)
mixer1.connect(input: booster1)
player.play()
答案 0 :(得分:3)
您可以尝试在output
之前移动start
和play
(但在所有connect
之后):
AudioKit.output = peakLimiter
AudioKit.start()
player.play()