Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用Audiokit v5实现麦克风分析_Ios_Swift_Audiokit - Fatal编程技术网

Ios 使用Audiokit v5实现麦克风分析

Ios 使用Audiokit v5实现麦克风分析,ios,swift,audiokit,Ios,Swift,Audiokit,我需要运行我的应用程序,它使用AudioKit作为Xcode 12中的库之一,这样我就可以为即将发布的iOS 14版本做准备,因为Xcode 12中包含了我需要采用的所有类的更改 然而,目前稳定的4.10.1版本并没有在Xcode 12中编译。然后我尝试安装最新的v5开发版本5.0.b1,该版本编译成功,但是API经历了重大更改-->AudioKit。例如,输出已被弃用。我找不到有关这些更改的任何文档。我认为这是因为它仍处于测试阶段 我以前使用的代码取自他们的麦克风分析示例: func setu

我需要运行我的应用程序,它使用AudioKit作为Xcode 12中的库之一,这样我就可以为即将发布的iOS 14版本做准备,因为Xcode 12中包含了我需要采用的所有类的更改

然而,目前稳定的4.10.1版本并没有在Xcode 12中编译。然后我尝试安装最新的v5开发版本5.0.b1,该版本编译成功,但是API经历了重大更改-->
AudioKit。例如,输出
已被弃用。我找不到有关这些更改的任何文档。我认为这是因为它仍处于测试阶段

我以前使用的代码取自他们的麦克风分析示例:

func setup(completion: @escaping TaskHandler) {
    // Setup the microphone
    AKSettings.audioInputEnabled = true
    mic = AKMicrophone()
    tracker = AKFrequencyTracker(mic)
    silence = AKBooster(tracker, gain: 0)

    // Start the audio engine
    AudioKit.output = silence
    do {
        try AudioKit.start()
        completion(true, nil)
    } catch {
        completion(false, ErrorMessage.microphoneFailedToStart)
        AKLog("AudioKit did not start!")
    }
}
然后我访问振幅和频率,如下所示:

timer?.setEventHandler(handler: {
        let currentAmp = self.tracker.amplitude
        let currentFreq = self.tracker.frequency
        // ... some processing here
}
在新版本中,我在Xcode中进行了深入研究,找到并尝试使
AKMicrophoneTrackerEngine
正常工作,并将其编译并运行:

let engine = AKMicrophoneTrackerEngine()

func setup(completion: @escaping TaskHandler) {
    engine.start()
    completion(true, nil)
}

// ..later in code

timer?.setEventHandler(handler: {
        let currentAmp = self.engine.amplitude
        let currentFreq = self.engine.frequency
        // ... some processing here
}
但是,频率(可能还有振幅)略有偏离。使用4.10.1播放1000Hz测试音时,输出正好为1000,但我的新方法产生的值约为918

有人能给我一份文档或建议我如何使用新的API实现相同的功能吗


谢谢。

应该通过更新到AudioKit 4.11.1
pod'AudioKit',“~>4.11.1”来解决此问题。
。此版本在Xcode 12中成功编译。您还需要将所有
AudioKit
实例替换为
AKManager
,例如:
AudioKit.output=…
替换为
AKManager.output=…

您找到iOS 14上麦克风的解决方案了吗?是的,请参考下面的答案。