Audiokit路线变更

时间:2019-07-15 16:14:39

标签: swift avaudiosession audiokit notificationcenter

是否可以在更改路线(扬声器/耳机)后播放声音而无需在 Sampler 中重新加载样本?

仅此项工作

func loadSamples(byIndex: Int) {
    sampler1.unloadAllSamples()

    if byIndex < 0 || byIndex > 3 { return }

    let info = ProcessInfo.processInfo
    let begin = info.systemUptime

    let sfzFiles = [ "City Piano.sfz", "ShortPiano.sfz", "LongPiano.sfz" ]
    sampler1.loadSfzWithEmbeddedSpacesInSampleNames(folderPath: Bundle.main.bundleURL.appendingPathComponent("Sounds/sfz").path,
                                                   sfzFileName: sfzFiles[byIndex])

    let elapsedTime = info.systemUptime - begin
    AKLog("Time to load samples \(elapsedTime) seconds")

}

导体类,我在.sfz中加载.wv样本

{{1}}

0 个答案:

没有答案