I use "AudioKit v5-main" to implement the recording function. The recording function is working properly, but it crashes when I try to tap the input from the microphone.
The code is:
class ViewController: UIViewController {
let engine = AudioEngine()
var silence: Fader!
var boostMic: Fader!
var tracker: PitchTap!
var recorder: NodeRecorder!
var player = AudioPlayer()
var mixer = Mixer()
override func viewDidLoad() {
super.viewDidLoad()
guard let mic = engine.input else {
debugPrint("error")
return
}
boostMic = Fader(mic, gain: 5)
tracker = PitchTap(boostMic, handler: { (pitch, amp) in
DispatchQueue.main.async {
debugPrint("amp: \(amp.first!.description)")
}
})
do {
recorder = try NodeRecorder(node: boostMic)
} catch {
debugPrint(error.localizedDescription)
}
silence = Fader(boostMic, gain: 0)
mixer.addInput(silence)
mixer.addInput(player)
engine.output = mixer
Settings.audioInputEnabled = true
do {
try engine.start()
tracker.start()
NodeRecorder.removeTempFiles()
try recorder.record()
} catch {
debugPrint(error.localizedDescription)
}
}
}
The errors output during a crash are:
[avae] AVAEInternal.h:76 required condition is false: [AVAEGraphNode.mm:817:CreateRecordingTap: (nullptr == Tap())]
*** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: nullptr == Tap()'
The development environment is as follows:
macOS 10.15.7
xCode 12.2 (12B45b)
AudioKit v5-main branch
Test with actual iPhoneX
Is there a way to avoid the crash?
I solved this problem by modifying the AudioKit framework.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.