Tyler White
Tyler White

Reputation: 398

AudioKit "disconnected state" crash related to creation order of nodes in the chain

I am getting this crash using AudioKit *** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'player started when in a disconnected state' This happens when I create and add the nodes in one order but does not happen when I add them in another order. Here is the desired chain:

[player]->[booster1]->[mixer1]->[booster2]->[mixer2]->[peak limiter]->[output]

When I build it in this order, it crashes:

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()

But when I build it in this order, it works:

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()

Any ideas why? For dynamic reasons in the app, the first example (crashing) is the creation order that it needs.

What's also strange is that if I use the first creation order example and omit the 2nd booster, it works. [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()

Upvotes: 2

Views: 696

Answers (1)

mugx
mugx

Reputation: 10105

you may try to move output and start, just before play (but after all the connect):

AudioKit.output = peakLimiter
AudioKit.start()
player.play()

Upvotes: 4

Related Questions