gpt4 book ai didi

ios - AUSampler : referencing external (downloaded) audio files

转载 作者:行者123 更新时间:2023-11-29 01:53:36 24 4
gpt4 key购买 nike

我有一个使用 .aupreset 的应用程序文件连同 .wav样本来定义加载到 AUSampler 音频单元中的乐器。.aupreset文件引用 .wav具有绝对路径的文件。如 Technical Note 2283 中所述,如果在原路径下找不到音频文件,则系统会在Bundle DirectoryNSLibraryDirectoryNSDocumentsDirectory中搜索>NSDownloadsDirectory,按此顺序。

我可以让应用程序包中的乐器正常工作,但现在我正在尝试支持下载的乐器。如果我把内容放在<NSLibraryDirectory>/Sounds/ , AUSampler 找不到 .wav sample ,但如果我把它放在 <NSDocumentsDirectory>/Sounds/ , 有用。不过,我不想将乐器放在 Documents 目录中,因为该文件夹显示在 iTunes 中。

这是 AUSampler 打印的错误:

09:27:25.251 ERROR:     [0x19989c310] 372: Failed to locate sample 'file:///Sounds/trance/square-lead/Square-12000Hz.wav'

此外,我什至无法在 NSDownloadsDirectory 位置创建目录 - 我只是收到不允许操作的错误。

以前有没有人成功从库中加载过样本?

(这是在 iOS 8 上。)

最佳答案

我收到了 this explanation from an Apple Engineer :

It turns out the documentation for this is incorrect for iOS: AUSampler will only look in NSDocumentDirectory and the NSDownloadsDirectory in addition to the bundle. These are the recommended locations for storing application-specific data, if you aren't going to store it in the bundle, or you wish to enable users to add additional content to the app.

For OSX, the NSLibraryDirectory is also available.

然而,根据我自己的测试,您也不能使用 NSDownloadsDirectory,因为尝试创建目录会返回错误(“操作无法完成。不允许操作”)。因此,iOS 上的唯一选项似乎是从 bundle 或 Documents 目录加载。

当你还想为其他内容启用 iTunes 文件共享时,这并不理想,所以我确实想到了另一个解决方法:将内容放在任意位置,并在加载 .aupreset 文件时,重写所有文件引用在音频单元上设置之前引用该位置。

关于ios - AUSampler : referencing external (downloaded) audio files,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31129884/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com