AudioKit AK3DPanner not working

1

I've been playing aroung with AudioKit v3.3 lately for a new project and am hitting a wall with the 3D spatialization node called AK3DPanner. At one point I got it to run, although it seemed extremely crude, either playing all sound in the left or the right ear. Not at all what one would expect.

In any case, the issue now it that it fails to even start. Putting this in a playground should work s far as I can tell, but it crashes:

let drip = AKDrip(intensity: 1)
let pan = AK3DPanner(drip)
AudioKit.output = pan

AudioKit.start() // Crashes here

drip.start()

AKPlaygroundLoop(every: 1) {
    drip.trigger()
}

The console logs this:

2016-09-13 13:52:52.395 FM Oscillator Operation[54225:910643] 13:52:52.395 ERROR:    AVAudioEngineGraph.mm:2510: PerformCommand: error -10875
2016-09-13 13:52:52.398 FM Oscillator Operation[54225:910643] *** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'error -10875'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010f22bd85 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010ec9fdeb objc_exception_throw + 48
    2   CoreFoundation                      0x000000010f22bbea +[NSException raise:format:arguments:] + 106
    3   libAVFAudio.dylib                   0x000000011c566ff3 _Z19AVAE_RaiseExceptionP8NSStringz + 176
    4   libAVFAudio.dylib                   0x000000011c5783fb _ZNK18AVAudioEngineGraph14PerformCommandER11AUGraphNodeNS_12ENodeCommandEPvj + 1571
    5   libAVFAudio.dylib                   0x000000011c581bcd _ZNSt3__110__function6__funcIZN13AUGraphParser34InitializeActiveNodesInOutputChainER18AVAudioEngineGraph14ETraversalModeR11AUGraphNodeRbE3$_8NS_9allocatorIS9_EEF16ETraversalStatusS7_P17AUGraphConnectionEEclES7_OSE_ + 231
    6   libAVFAudio.dylib                   0x000000011c582c2f _ZNKSt3__18functionIF16ETraversalStatusR11AUGraphNodeP17AUGraphConnectionEEclES3_S5_ + 31
    7   libAVFAudio.dylib                   0x000000011c575208 _ZN13AUGraphParser18TraverseGraphNodesERK18AVAudioEngineGraph10EDirection10ERecursionR11AUGraphNodeP17AUGraphConnectionRKNSt3__18functionIF16ETraversalStatusS6_S8_EEE + 48
    8   libAVFAudio.dylib                   0x000000011c5762bb _ZN13AUGraphParser34InitializeActiveNodesInOutputChainER18AVAudioEngineGraph14ETraversalModeR11AUGraphNodeRb + 833
    9   libAVFAudio.dylib                   0x000000011c57921f _ZN18AVAudioEngineGraph10InitializeEv + 1031
    10  libAVFAudio.dylib                   0x000000011c5b12b5 _ZN17AVAudioEngineImpl10InitializeEv + 29
    11  libAVFAudio.dylib                   0x000000011c5b0827 -[AVAudioEngine prepare] + 58
    12  AudioKit                            0x000000011d23fb92 _TZFC8AudioKit8AudioKit5startfT_T_ + 258
    13  ???                                 0x000000011a3f86d5 0x0 + 4735338197
    14  FM Oscillator Operation             0x000000010e72fab0 main + 0
    15  FM Oscillator Operation             0x000000010e7329a1 _TTRXFo__dT__XFo_iT__iT__ + 17
    16  FM Oscillator Operation             0x000000010e732401 _TPA__TTRXFo__dT__XFo_iT__iT__ + 81
    17  FM Oscillator Operation             0x000000010e7329d0 _TTRXFo_iT__iT__XFo__dT__ + 32
    18  FM Oscillator Operation             0x000000010e732a07 _TTRXFo__dT__XFdCb__dT__ + 39
    19  CoreFoundation                      0x000000010f1512ec __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
    20  CoreFoundation                      0x000000010f146f75 __CFRunLoopDoBlocks + 341
    21  CoreFoundation                      0x000000010f1466d2 __CFRunLoopRun + 850
    22  CoreFoundation                      0x000000010f1460f8 CFRunLoopRunSpecific + 488
    23  GraphicsServices                    0x0000000115d0bad2 GSEventRunModal + 161
    24  UIKit                               0x000000010f5e1f09 UIApplicationMain + 171
    25  FM Oscillator Operation             0x000000010e72ff39 main + 1161
    26  libdyld.dylib                       0x0000000111f7192d start + 1
    27  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Furthermore, if I print(AudioKit.engine) right before the crash I get this:

________ GraphDescription ________
AVAudioEngineGraph 0x7f97d9437f40: initialized = 0, running = 0, number of nodes = 3

     ******** output chain ********

     node 0x7f97d9611d90 {'auou' 'rioc' 'appl'}, 'U'
         inputs = 1
             (bus0) <- (bus0) 0x7f97d943c910, {'aumx' '3dem' 'appl'}, [ 2 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]

     node 0x7f97d943c910 {'aumx' '3dem' 'appl'}, 'U'
         inputs = 33
             (bus0) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus1) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus2) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus3) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus4) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus5) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus6) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus7) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus8) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus9) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus10) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus11) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus12) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus13) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus14) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus15) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus16) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus17) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus18) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus19) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus20) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus21) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus22) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus23) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus24) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus25) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus26) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus27) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus28) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus29) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus30) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus31) <- (bus0) 0x0, {}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
             (bus32) <- (bus0) 0x7f97d9437780, {'augn' 'drip' 'AuKt'}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
         outputs = 1
             (bus0) -> (bus0) 0x7f97d9611d90, {'auou' 'rioc' 'appl'}, [ 2 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]

     node 0x7f97d9437780 {'augn' 'drip' 'AuKt'}, 'U'
         outputs = 1
             (bus0) -> (bus32) 0x7f97d943c910, {'aumx' '3dem' 'appl'}, [ 1 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
______________________________________

I should note also that I always get this error when running the AudioKit playgrounds, but things still always work:

2016-09-13 13:52:52.364 FM Oscillator Operation[54225:910777] 13:52:52.363 WARNING:  40: ERROR: couldn't get default input device, ID = 0, err = 0!
2016-09-13 13:52:52.375 FM Oscillator Operation[54225:910777] 13:52:52.375 WARNING:  803: The default input device 0x0 '(null)' has no input channels.

Finally, if I remove the panner node like below, it works fine:

let drip = AKDrip(intensity: 1)
AudioKit.output = drip

AudioKit.start()

drip.start()

AKPlaygroundLoop(every: 1) {
    drip.trigger()
}

Very grateful for any insight on this. Since binaural audio is crucial for the project, we need to switch audio engines if we can't figure this one out!

swift
audio
swift-playground
avaudioengine
audiokit
asked on Stack Overflow Sep 13, 2016 by Gusutafu

1 Answer

1

Can you try this again with the most recent AudioKit? If it still doesn't work, try sending the drip sound into an AKMixer first, let mixer = AKMixer(drip) and then send it to the 3D Panner.

answered on Stack Overflow Jan 20, 2017 by Aurelius Prochazka

User contributions licensed under CC BY-SA 3.0