创建一个从麦克风跟踪音频的Swift iOS项目。目前正在使用AudioKit3.0框架。我有以下代码在Xcode模拟器中工作,但当我在设备上运行它时,它似乎没有正确读取麦克风信号。
// Prepare Microphone
let mic = AKMicrophone()
// Connect Microphone to High Pass Filter
let mixer = AKMixer(mic)
let highPassFilter = AKHighPassFilter(mic)
// Set Parameters of Hi Pass filter
highPassFilter.cutoffFrequency = 7000 // Hz
highPassFilter.resonance = 0 // dB
let tracker = AKFrequencyTracker(highPassFilter, minimumFrequency: 7000, maximumFrequency: 8000)
highPassFilter.play()
audioKit.audioOutput = tracker
audioKit.start()
AKPlaygroundLoop(every: 0.1) {
let freq = tracker.frequency
print(freq)
}
最佳答案
我将此代码与AudioKit 3一起使用,它工作正常:
let mic = AKMicrophone()
amplitudeTracker = AKAmplitudeTracker(mic)
AKSettings.audioInputEnabled = true
AudioKit.output = amplitudeTracker
AudioKit.start()
mic.start()
amplitudeTracker.start()
这是一个振幅跟踪器,但情况和你差不多。Try AKSettings.audioInputEnabled=真
希望这有帮助。
关于ios - 使用AudioKit从麦克风跟踪频率,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35044742/