AudioKit version: 4.5.2
macOS version: 10.14
Xcode version: 10.0
I have some microphone recording code for a project (which can be seen here: https://github.com/vanshg/MacAssistant/blob/master/MacAssistant/Audio/AudioEngine.swift). This code works fine on my friend's laptop (Mid-2015 MacBook Pro). However, when trying to run this on my laptop (2018 MacBook Pro), it crashes upon initialization of AKMicrophone, before starting the AudioKit engine (Both laptops are running the same version of AudioKit, macOS, and Xcode). I thought this might be an issue with the specific code I had written, so I made a simple new project with only the following code:
import Cocoa
import AudioKit
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
let mic = AKMicrophone()
@IBOutlet weak var window: NSWindow!
func applicationDidFinishLaunching(_ aNotification: Notification) {
AudioKit.output = AKBooster(mic)
print("Start recording")
try? AudioKit.start()
}
}
and it continues to crash. The stack trace I get for this specific piece of code (and for my project) is:
2018-10-27 22:57:55.870774-0700 TestAudioKit[14733:224871] [avae] AVAEInternal.h:70:_AVAE_Check: required condition is false: [AVAudioIONodeImpl.mm:911:SetOutputFormat: (format.sampleRate == hwFormat.sampleRate)]
2018-10-27 22:57:55.872674-0700 TestAudioKit[14733:224871] [General] An uncaught exception was raised
2018-10-27 22:57:55.872690-0700 TestAudioKit[14733:224871] [General] required condition is false: format.sampleRate == hwFormat.sampleRate
2018-10-27 22:57:55.872763-0700 TestAudioKit[14733:224871] [General] (
0 CoreFoundation 0x00007fff3e10443d __exceptionPreprocess + 256
1 libobjc.A.dylib 0x00007fff6a015720 objc_exception_throw + 48
2 CoreFoundation 0x00007fff3e11f08e +[NSException raise:format:arguments:] + 98
3 AVFAudio 0x00007fff3a18bbac _Z19AVAE_RaiseExceptionP8NSStringz + 156
4 AVFAudio 0x00007fff3a191bbb _Z11_AVAE_CheckPKciS0_S0_b + 323
5 AVFAudio 0x00007fff3a1df053 _ZN17AVAudioIONodeImpl15SetOutputFormatEmP13AVAudioFormat + 349
6 AVFAudio 0x00007fff3a1bf773 _ZN18AVAudioEngineGraph8_ConnectEP19AVAudioNodeImplBaseS1_jjP13AVAudioFormat + 1653
7 AVFAudio 0x00007fff3a1c329e _ZN18AVAudioEngineGraph22ConnectMultipleOutputsEP11AVAudioNodeP7NSArraymP13AVAudioFormat + 3370
8 AVFAudio 0x00007fff3a1e75d7 _ZN17AVAudioEngineImpl22ConnectMultipleOutputsEP11AVAudioNodeP7NSArraymP13AVAudioFormat + 673
9 AVFAudio 0x00007fff3a1e72ee -[AVAudioEngine connect:toConnectionPoints:fromBus:format:] + 94
10 TestAudioKit 0x0000000100301c06 $S8AudioKitAAC7connect_2to7fromBus6formatySo11AVAudioNodeC_SaySo0H15ConnectionPointCGSiSo0H6FormatCSgtFZTf4nnnnd_n + 1990
11 TestAudioKit 0x000000010022def8 $S8AudioKit8AKOutputPAAE7connect2to3busAA7AKInput_pAaG_p_SitFAA18AKPeriodicFunctionC_Tg5Tf4nnn_g + 616
12 TestAudioKit 0x00000001002301d9 $S8AudioKit8AKOutputPAAE7connect2to3busAA7AKInput_pAaG_p_SitFSo16AVAudioInputNodeC_Tg5Tf4nnn_g + 9
13 TestAudioKit 0x000000010019cbec $S8AudioKit12AKMicrophoneCACycfc + 588
14 TestAudioKit 0x000000010019cc1f $S8AudioKit12AKMicrophoneCACycfcTo + 15
15 TestAudioKit 0x00000001000028b6 $S12TestAudioKit11AppDelegateCACycfc + 54
16 TestAudioKit 0x0000000100002983 $S12TestAudioKit11AppDelegateCACycfcTo + 19
17 AppKit 0x00007fff3b5e3322 -[NSClassSwapper initWithCoder:] + 584
18 Foundation 0x00007fff403ae1c1 _decodeObjectBinary + 2449
19 Foundation 0x00007fff403ad717 _decodeObject + 246
20 Foundation 0x00007fff403ad613 -[NSKeyedUnarchiver decodeObjectForKey:] + 205
21 AppKit 0x00007fff3b59734b -[NSNibConnector initWithCoder:] + 96
22 AppKit 0x00007fff3b5971d3 -[NSNibOutletConnector initWithCoder:] + 76
23 Foundation 0x00007fff403ae1c1 _decodeObjectBinary + 2449
24 Foundation 0x00007fff403afb25 -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1684
25 Foundation 0x00007fff403af0bc -[NSArray(NSArray) initWithCoder:] + 196
26 Foundation 0x00007fff403ae1c1 _decodeObjectBinary + 2449
27 Foundation 0x00007fff403ad717 _decodeObject + 246
28 Foundation 0x00007fff403ad613 -[NSKeyedUnarchiver decodeObjectForKey:] + 205
29 AppKit 0x00007fff3b595de8 -[NSIBObjectData initWithCoder:] + 200
30 Foundation 0x00007fff403ae1c1 _decodeObjectBinary + 2449
31 Foundation 0x00007fff403ad717 _decodeObject + 246
32 Foundation 0x00007fff403ad613 -[NSKeyedUnarchiver decodeObjectForKey:] + 205
33 AppKit 0x00007fff3b595b8d loadNib + 317
34 AppKit 0x00007fff3b5950a9 +[NSBundle(NSNibLoading) _loadNibFile:nameTable:options:withZone:ownerBundle:] + 696
35 AppKit 0x00007fff3b594cee -[NSBundle(NSNibLoading) loadNibNamed:owner:topLevelObjects:] + 204
36 AppKit 0x00007fff3b594aaf +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 447
37 AppKit 0x00007fff3b588d84 NSApplicationMain + 505
38 TestAudioKit 0x0000000100002a3d main + 13
39 libdyld.dylib 0x00007fff6b0e3085 start + 1
)
2018-10-27 22:57:55.873559-0700 TestAudioKit[14733:224871] *** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: format.sampleRate == hwFormat.sampleRate'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff3e10443d __exceptionPreprocess + 256
1 libobjc.A.dylib 0x00007fff6a015720 objc_exception_throw + 48
2 CoreFoundation 0x00007fff3e11f08e +[NSException raise:format:arguments:] + 98
3 AVFAudio 0x00007fff3a18bbac _Z19AVAE_RaiseExceptionP8NSStringz + 156
4 AVFAudio 0x00007fff3a191bbb _Z11_AVAE_CheckPKciS0_S0_b + 323
5 AVFAudio 0x00007fff3a1df053 _ZN17AVAudioIONodeImpl15SetOutputFormatEmP13AVAudioFormat + 349
6 AVFAudio 0x00007fff3a1bf773 _ZN18AVAudioEngineGraph8_ConnectEP19AVAudioNodeImplBaseS1_jjP13AVAudioFormat + 1653
7 AVFAudio 0x00007fff3a1c329e _ZN18AVAudioEngineGraph22ConnectMultipleOutputsEP11AVAudioNodeP7NSArraymP13AVAudioFormat + 3370
8 AVFAudio 0x00007fff3a1e75d7 _ZN17AVAudioEngineImpl22ConnectMultipleOutputsEP11AVAudioNodeP7NSArraymP13AVAudioFormat + 673
9 AVFAudio 0x00007fff3a1e72ee -[AVAudioEngine connect:toConnectionPoints:fromBus:format:] + 94
10 TestAudioKit 0x0000000100301c06 $S8AudioKitAAC7connect_2to7fromBus6formatySo11AVAudioNodeC_SaySo0H15ConnectionPointCGSiSo0H6FormatCSgtFZTf4nnnnd_n + 1990
11 TestAudioKit 0x000000010022def8 $S8AudioKit8AKOutputPAAE7connect2to3busAA7AKInput_pAaG_p_SitFAA18AKPeriodicFunctionC_Tg5Tf4nnn_g + 616
12 TestAudioKit 0x00000001002301d9 $S8AudioKit8AKOutputPAAE7connect2to3busAA7AKInput_pAaG_p_SitFSo16AVAudioInputNodeC_Tg5Tf4nnn_g + 9
13 TestAudioKit 0x000000010019cbec $S8AudioKit12AKMicrophoneCACycfc + 588
14 TestAudioKit 0x000000010019cc1f $S8AudioKit12AKMicrophoneCACycfcTo + 15
15 TestAudioKit 0x00000001000028b6 $S12TestAudioKit11AppDelegateCACycfc + 54
16 TestAudioKit 0x0000000100002983 $S12TestAudioKit11AppDelegateCACycfcTo + 19
17 AppKit 0x00007fff3b5e3322 -[NSClassSwapper initWithCoder:] + 584
18 Foundation 0x00007fff403ae1c1 _decodeObjectBinary + 2449
19 Foundation 0x00007fff403ad717 _decodeObject + 246
20 Foundation 0x00007fff403ad613 -[NSKeyedUnarchiver decodeObjectForKey:] + 205
21 AppKit 0x00007fff3b59734b -[NSNibConnector initWithCoder:] + 96
22 AppKit 0x00007fff3b5971d3 -[NSNibOutletConnector initWithCoder:] + 76
23 Foundation 0x00007fff403ae1c1 _decodeObjectBinary + 2449
24 Foundation 0x00007fff403afb25 -[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1684
25 Foundation 0x00007fff403af0bc -[NSArray(NSArray) initWithCoder:] + 196
26 Foundation 0x00007fff403ae1c1 _decodeObjectBinary + 2449
27 Foundation 0x00007fff403ad717 _decodeObject + 246
28 Foundation 0x00007fff403ad613 -[NSKeyedUnarchiver decodeObjectForKey:] + 205
29 AppKit 0x00007fff3b595de8 -[NSIBObjectData initWithCoder:] + 200
30 Foundation 0x00007fff403ae1c1 _decodeObjectBinary + 2449
31 Foundation 0x00007fff403ad717 _decodeObject + 246
32 Foundation 0x00007fff403ad613 -[NSKeyedUnarchiver decodeObjectForKey:] + 205
33 AppKit 0x00007fff3b595b8d loadNib + 317
34 AppKit 0x00007fff3b5950a9 +[NSBundle(NSNibLoading) _loadNibFile:nameTable:options:withZone:ownerBundle:] + 696
35 AppKit 0x00007fff3b594cee -[NSBundle(NSNibLoading) loadNibNamed:owner:topLevelObjects:] + 204
36 AppKit 0x00007fff3b594aaf +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 447
37 AppKit 0x00007fff3b588d84 NSApplicationMain + 505
38 TestAudioKit 0x0000000100002a3d main + 13
39 libdyld.dylib 0x00007fff6b0e3085 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
What stands out is reason: 'required condition is false: format.sampleRate == hwFormat.sampleRate'
I also tried downloading the AudioKit Playgrounds to make sure that I still wasn't doing anything wrong. When I try to run the Tracking Microphone Input, the code also serves up a stack trace. However, this stack trace is different:
error: Execution was interrupted, reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0).
The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation.
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
* frame #0: 0x00007fff3b9ae18f AppKit`-[NSApplication _crashOnException:] + 109
frame #1: 0x00007fff3b9ae072 AppKit`-[NSApplication reportException:] + 939
frame #2: 0x00007fff3ba6feb7 AppKit`uncaughtErrorProc + 157
frame #3: 0x00007fff3e17b2e1 CoreFoundation`__handleUncaughtException + 775
frame #4: 0x00007fff6a017c81 libobjc.A.dylib`_objc_terminate() + 91
frame #5: 0x00007fff68819dfe libc++abi.dylib`std::__terminate(void (*)()) + 8
frame #6: 0x00007fff68819be2 libc++abi.dylib`__cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) + 27
frame #7: 0x00007fff6880cbb9 libc++abi.dylib`__cxa_throw + 113
frame #8: 0x00007fff6a01585a libobjc.A.dylib`objc_exception_throw + 362
frame #9: 0x00007fff3e11f08e CoreFoundation`+[NSException raise:format:arguments:] + 98
frame #10: 0x00007fff3a18bbac AVFAudio`AVAE_RaiseException(NSString*, ...) + 156
frame #11: 0x00007fff3a191bbb AVFAudio`_AVAE_Check(char const*, int, char const*, char const*, bool) + 323
frame #12: 0x00007fff3a1df053 AVFAudio`AVAudioIONodeImpl::SetOutputFormat(unsigned long, AVAudioFormat*) + 349
frame #13: 0x00007fff3a1bf773 AVFAudio`AVAudioEngineGraph::_Connect(AVAudioNodeImplBase*, AVAudioNodeImplBase*, unsigned int, unsigned int, AVAudioFormat*) + 1653
frame #14: 0x00007fff3a1c329e AVFAudio`AVAudioEngineGraph::ConnectMultipleOutputs(AVAudioNode*, NSArray*, unsigned long, AVAudioFormat*) + 3370
frame #15: 0x00007fff3a1e75d7 AVFAudio`AVAudioEngineImpl::ConnectMultipleOutputs(AVAudioNode*, NSArray*, unsigned long, AVAudioFormat*) + 673
frame #16: 0x00007fff3a1e72ee AVFAudio`-[AVAudioEngine connect:toConnectionPoints:fromBus:format:] + 94
frame #17: 0x000000010ba11f16 AudioKitPlaygrounds`function signature specialization <Arg[4] = Dead> of static AudioKit.AudioKit.connect(_: __C.AVAudioNode, to: Swift.Array<__C.AVAudioConnectionPoint>, fromBus: Swift.Int, format: Swift.Optional<__C.AVAudioFormat>) -> () + 1990
frame #18: 0x000000010b931be8 AudioKitPlaygrounds`function signature specialization <Arg[18446744073709551615] = Owned To Guaranteed> of generic specialization <AudioKit.AKPeriodicFunction> of (extension in AudioKit):AudioKit.AKOutput.connect(to: AudioKit.AKInput, bus: Swift.Int) -> AudioKit.AKInput + 616
frame #19: 0x000000010b933ec9 AudioKitPlaygrounds`function signature specialization <Arg[18446744073709551615] = Owned To Guaranteed> of generic specialization <__C.AVAudioInputNode> of (extension in AudioKit):AudioKit.AKOutput.connect(to: AudioKit.AKInput, bus: Swift.Int) -> AudioKit.AKInput + 9
frame #20: 0x000000010b88beac AudioKitPlaygrounds`AudioKit.AKMicrophone.init() -> AudioKit.AKMicrophone + 588
frame #21: 0x000000010b88bedf AudioKitPlaygrounds`@objc AudioKit.AKMicrophone.init() -> AudioKit.AKMicrophone + 15
frame #22: 0x000000010bf2d057 $__lldb_expr5`main at Tracking Microphone Input.xcplaygroundpage:6
frame #23: 0x000000010648c1a0 com.apple.dt.Xcode.PlaygroundStub-macosx
frame #24: 0x00007fff3e059f8c CoreFoundation`__invoking___ + 140
frame #25: 0x00007fff3e059e5f CoreFoundation`-[NSInvocation invoke] + 311
frame #26: 0x00007fff3e0bb53d CoreFoundation`-[NSInvocation invokeWithTarget:] + 56
frame #27: 0x00007fff6715abf5 ViewBridge`__68-[NSVB_ViewServiceImplicitAnimationDecodingProxy forwardInvocation:]_block_invoke_2 + 46
frame #28: 0x00007fff6711fec6 ViewBridge`-[NSViewServiceMarshal withHostWindowFrameAnimationInProgress:perform:] + 53
frame #29: 0x00007fff6715abbe ViewBridge`__68-[NSVB_ViewServiceImplicitAnimationDecodingProxy forwardInvocation:]_block_invoke + 113
frame #30: 0x00007fff3b637731 AppKit`+[NSAnimationContext runAnimationGroup:] + 55
frame #31: 0x00007fff3b6376e7 AppKit`+[NSAnimationContext runAnimationGroup:completionHandler:] + 82
frame #32: 0x00007fff6717d154 ViewBridge`runAnimationGroup + 295
frame #33: 0x00007fff6715a695 ViewBridge`+[NSVB_View _animateWithAttributes:animations:completion:] + 490
frame #34: 0x00007fff6715ab28 ViewBridge`-[NSVB_ViewServiceImplicitAnimationDecodingProxy forwardInvocation:] + 206
frame #35: 0x00007fff3e0a380e CoreFoundation`___forwarding___ + 780
frame #36: 0x00007fff3e0a3478 CoreFoundation`__forwarding_prep_0___ + 120
frame #37: 0x00007fff3e059f8c CoreFoundation`__invoking___ + 140
frame #38: 0x00007fff3e059e5f CoreFoundation`-[NSInvocation invoke] + 311
frame #39: 0x00007fff3e0bb53d CoreFoundation`-[NSInvocation invokeWithTarget:] + 56
frame #40: 0x00007fff67122973 ViewBridge`-[NSVB_QueueingProxy forwardInvocation:] + 324
frame #41: 0x00007fff3e0a380e CoreFoundation`___forwarding___ + 780
frame #42: 0x00007fff3e0a3478 CoreFoundation`__forwarding_prep_0___ + 120
frame #43: 0x00007fff3e059f8c CoreFoundation`__invoking___ + 140
frame #44: 0x00007fff3e059e5f CoreFoundation`-[NSInvocation invoke] + 311
frame #45: 0x00007fff3e0bb53d CoreFoundation`-[NSInvocation invokeWithTarget:] + 56
frame #46: 0x00007fff3e0a380e CoreFoundation`___forwarding___ + 780
frame #47: 0x00007fff3e0a3478 CoreFoundation`__forwarding_prep_0___ + 120
frame #48: 0x00007fff3e059f8c CoreFoundation`__invoking___ + 140
frame #49: 0x00007fff3e059e5f CoreFoundation`-[NSInvocation invoke] + 311
frame #50: 0x00007fff670ef6cd ViewBridge`__deferNSXPCInvocationOntoMainThread_block_invoke + 237
frame #51: 0x00007fff670e4af3 ViewBridge`__wrapBlockWithVoucher_block_invoke + 37
frame #52: 0x00007fff670e48a4 ViewBridge`__deferBlockOntoMainThread_block_invoke_2 + 553
frame #53: 0x00007fff3e087ca7 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
frame #54: 0x00007fff3e04aced CoreFoundation`__CFRunLoopDoBlocks + 395
frame #55: 0x00007fff3e04a3eb CoreFoundation`__CFRunLoopRun + 1204
frame #56: 0x00007fff3e049ce4 CoreFoundation`CFRunLoopRunSpecific + 463
frame #57: 0x00007fff3d2e3895 HIToolbox`RunCurrentEventLoopInMode + 293
frame #58: 0x00007fff3d2e34d4 HIToolbox`ReceiveNextEventCommon + 371
frame #59: 0x00007fff3d2e3348 HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 64
frame #60: 0x00007fff3b5a095b AppKit`_DPSNextEvent + 997
frame #61: 0x00007fff3b59f6fa AppKit`-[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1362
frame #62: 0x00007fff670ed226 ViewBridge`-[NSViewServiceApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 92
frame #63: 0x00007fff3b59975d AppKit`-[NSApplication run] + 699
frame #64: 0x00007fff3b588e97 AppKit`NSApplicationMain + 780
frame #65: 0x00007fff6b319f1f libxpc.dylib`_xpc_objc_main + 612
frame #66: 0x00007fff6b3199e5 libxpc.dylib`xpc_main + 433
frame #67: 0x00007fff670dea76 ViewBridge`-[NSXPCSharedListener resume] + 16
frame #68: 0x00007fff670e7a03 ViewBridge`NSViewServiceApplicationMain + 2877
frame #69: 0x000000010648c1ca com.apple.dt.Xcode.PlaygroundStub-macosx`main + 42
frame #70: 0x00007fff6b0e3085 libdyld.dylib`start + 1
frame #71: 0x00007fff6b0e3085 libdyld.dylib`start + 1
Because even the Playground fails, my inclination is to believe that this is an AudioKit issue and not an implementation issue. Any ideas what this might be stemming from or ways to fix?
Its not an uncommon error to see. Do you have an Audio interface or is this going to the macbook's speakers?
This is through my MacBook's speakers. I tried connecting headphones as well to see if that made a difference, but no dice.
I just ran the code snippet no problem. Do you by any chance have your audio set to 48K? Here's my AudioMIDI Setup Audio Devices:

P.S. if 44.1K fixes it, I still will call it an AK problem and try to write a fix, just want to know all I can.
Yeah so mine was set to 48K. I just changed to 44.1K and it fixed running the sample program. But the actual project code doesn't seem to work still. I'll maybe try to diagnose that separately.
Interesting though, I don't remember setting my format to 48K. Do you know if the new MacBooks default to that when they ship? Or do you think I probably changed it and just forgot?
Mine is a 2018 as well, and I remember changing it, so its probably the default. We recently fixed a similar issue on the iOS side.
Okay fixed the issue on my project now too (the new issue was related to App Sandbox, irrelevant to discussion here). I think going forward, it would be great if AudioKit would handle the different formats, because those with 2018 MacBooks will surely be using apps with AudioKit in them. Thanks for the help and quick replies!
Btw, just tried plugging in my wired headphones (Apple EarPods) and they defaulted to 48K as well.
We'll be severely changing the way we deal with microphone soon, so I'll close this issue for now and see if issues arise with the new method.
Sounds good.
For anyone else who may be experiencing this issue with this version (4.5.2), I was able to fix the crash by writing AKSettings.sampleRate = AudioKit.engine.inputNode.inputFormat(forBus: 0).sampleRate before I initialized my microphone (from code found here: https://github.com/AudioKit/AudioKit/commit/a69b249338ee0d73676ca185969b23b493516d61#diff-0345b5e840a1686dfc15209bac76c73bL77)
A quick comment that may help others: it seems like the 3rd generation of iPad Pro devices changed the default microphone sample rate. If you want AKMicrophone to initialize correctly with these devices you have to implement vanshg's suggested fix above for version 4.5.2.
EDIT: It is not possible to set any other sample rate other than the device's default. This means that features that depend on sample rate, such as FFT analysis, will produce different result on different devices. I hope this will also be addressed as part of the microphone overhaul.
any update on this? Still we cant set different sample rates?
Sounds good.
For anyone else who may be experiencing this issue with this version (4.5.2), I was able to fix the crash by writing
AKSettings.sampleRate = AudioKit.engine.inputNode.inputFormat(forBus: 0).sampleRatebefore I initialized my microphone (from code found here: a69b249#diff-0345b5e840a1686dfc15209bac76c73bL77)
It works for me, but is it OK to just use bus[0] here?
Update:
Looks like it fixes not all the cases:
Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: format.sampleRate == hwFormat.sampleRate'
I am still getting this error, is there any update?
Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: format.sampleRate == hwFormat.sampleRate randomly pops up for me as well. Haven't been able to pinpoint it exactly because it happens so randomly like once in 40 runs.
I'm getting this error when I run my app in simulator on my brand new 2019 macbook, but not when I run it on my 2015 macbook air. I was able to get around the error by using the fix up above using "Audio MIDI Setup" to switch my speakers to 44100. Using that line up above by vanshg also seems to fix the crash.
Funny thing is when I initialize the AKMicrophone, when input device is in 44k while OUTPUT device is in 48k, it crashes!
Most helpful comment
Sounds good.
For anyone else who may be experiencing this issue with this version (4.5.2), I was able to fix the crash by writing
AKSettings.sampleRate = AudioKit.engine.inputNode.inputFormat(forBus: 0).sampleRatebefore I initialized my microphone (from code found here: https://github.com/AudioKit/AudioKit/commit/a69b249338ee0d73676ca185969b23b493516d61#diff-0345b5e840a1686dfc15209bac76c73bL77)