AudioKit - 音频引擎配置定期更改

时间:2018-01-08 01:15:15

标签: ios swift audio avaudioengine audiokit

我有一个使用采样器播放循环的应用。我正在将我的应用程序从使用AVAudioEngine转换为AudioKit。我的应用程序现在运行良好除外:大约每1-3分钟,我的应用程序连续收到两个.AVAudioEngineConfigurationChange通知。它的重复没有明显的模式,这种情况发生在我的iPhone 6s和新iPad上。

这是我的"指挥家的初始代码"单:

init() {        
    //sampler array
    //sampler array is cycled through as user changes sounds
    samplerArray = [sampler0, sampler1, sampler2, sampler3]

    //start by loading samplers with default preset
    for sampler in samplerArray {
        //get the sampler preset
        let presetPath = Bundle.main.path(forResource: currentSound, ofType: "aupreset")
        let presetURL = NSURL.fileURL(withPath: presetPath!)

        do {
            try sampler.samplerUnit.loadPreset(at: presetURL)
            print("rrob: loaded sample")
        } catch {
            print("rrob: failed to load sample")
        }
    }

    //signal chain
    samplerMixer = AKMixer(samplerArray)
    filter = AKMoogLadder(samplerMixer)
    reverb = AKCostelloReverb(filter)
    reverbMixer = AKDryWetMixer(filter, reverb, balance: 0.3)
    outputMixer = AKMixer(reverbMixer)

    AudioKit.output = outputMixer

    //AKSettings.enableRouteChangeHandling = false
    AKSettings.playbackWhileMuted = true

    do {
        try AKSettings.setSession(category: AKSettings.SessionCategory.playback, with: AVAudioSessionCategoryOptions.mixWithOthers)
    } catch {
        print("rrob: failed to set audio session")
    }

    //AudioBus recommended buffer length
    AKSettings.bufferLength = .medium

    AudioKit.start()

    print("rrob: did init autoEngine")

}

任何AudioKit专家都有我可以开始排除故障的想法?很高兴提供更多信息。感谢。

0 个答案:

没有答案