I just updated to the latest AudioKit version 4.2.3 and Swift 4.1 I'm getting a crash at audiokit.start() that I can't decipher. Please lmk if you need more of the error code.
AURemoteIO::IOThread (21): EXC_BAD_ACCESS (code=1, address=0x100900000)
FYI I am also using AVAudioRecorder to record the microphone input to file and playing it with AVKit AVAudioPlayer later on in the ViewController. However, since I did not get this crash before updating I do not believe those factors are responsible - but something with the tracker input.
import UIKit
import Speech
import AudioKit
class RecordVoiceViewController: UIViewController {
var tracker: AKFrequencyTracker!
var silence: AKBooster!
var mic: AKMicrophone!
let noteFrequencies = [16.35, 17.32, 18.35, 19.45, 20.6, 21.83, 23.12, 24.5, 25.96, 27.5, 29.14, 30.87]
let noteNamesWithSharps = ["C", "C♯","D","D♯","E","F","F♯","G","G♯","A","A♯","B"]
let noteNamesWithFlats = ["C", "D♭","D","E♭","E","F","G♭","G","A♭","A","B♭","B"]
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
AKSettings.audioInputEnabled = true
mic = AKMicrophone()
tracker = AKFrequencyTracker.init(mic, hopSize: 200, peakCount: 2000)
silence = AKBooster(tracker, gain: 0)
}
func startAudioKit(){
AudioKit.output = self.silence
do {
try AudioKit.start()
} catch {
AKLog("Something went wrong.")
}
}
}
What's interesting is when I initialize the tracker without the hopSize and peakCount, like:
tracker = AKFrequencyTracker.init(mic)
it does not crash, however it also doesn't return the correct frequency. I'm super thankful for any help. Thanks!!!