gpt4 book ai didi

xcode - iOS LoadPresetDemo 示例代码中的 AU Preset (.aupreset) 资源路径问题

转载 作者:行者123 更新时间:2023-12-04 16:11:54 26 4
gpt4 key购买 nike

我一直在使用 iOS LoadPresetDemo示例代码 - 如果加载 AUPreset 文件以配置不同类型的采样器(非常酷) - 并且遇到了问题/问题。

演示代码运行良好,但是当我尝试在从头构建的测试项目中重用 .aupreset 文件时,Trombone.aupreset 不起作用。深入研究,我注意到 .aupreset 文件中的音频样本路径似乎有些奇怪。

plist 中的路径(下图)指向:

file://localhost//Library/Audio/Sounds/Tbone/1a%23.caf

但这不是正确的路径 - 根据项目目录结构。没有“图书馆/音频”目录 - 虚拟或真实。所以我很困惑。 Apple 演示工作正常,但我的从头开始的项目没有(尝试加载示例时出现错误 -43)。加载样本的代码(在底部)在运行时没有做任何相对化路径的事情。

有没有人看到我在这里误解了什么? - 谢谢!

directory structure

.aupreset plist
// Load a synthesizer preset file and apply it to the Sampler unit
- (OSStatus) loadSynthFromPresetURL: (NSURL *) presetURL {

CFDataRef propertyResourceData = 0;
Boolean status;
SInt32 errorCode = 0;
OSStatus result = noErr;

// Read from the URL and convert into a CFData chunk
status = CFURLCreateDataAndPropertiesFromResource (
kCFAllocatorDefault,
(__bridge CFURLRef) presetURL,
&propertyResourceData,
NULL,
NULL,
&errorCode
);

NSAssert (status == YES && propertyResourceData != 0, @"Unable to create data and properties from a preset. Error code: %d '%.4s'", (int) errorCode, (const char *)&errorCode);

// Convert the data object into a property list
CFPropertyListRef presetPropertyList = 0;
CFPropertyListFormat dataFormat = 0;
CFErrorRef errorRef = 0;
presetPropertyList = CFPropertyListCreateWithData (
kCFAllocatorDefault,
propertyResourceData,
kCFPropertyListImmutable,
&dataFormat,
&errorRef
);

// Set the class info property for the Sampler unit using the property list as the value.
if (presetPropertyList != 0) {

result = AudioUnitSetProperty(
self.samplerUnit,
kAudioUnitProperty_ClassInfo,
kAudioUnitScope_Global,
0,
&presetPropertyList,
sizeof(CFPropertyListRef)
);

CFRelease(presetPropertyList);
}

if (errorRef) CFRelease(errorRef);
CFRelease (propertyResourceData);

return result;
}

最佳答案

我遇到了同样的问题,在将“加载预设”-Demo 与我的代码进行了 2 个小时的比较后,我找到了解决方案:

添加声音文件夹时,请检查选项:

  • 复制项目
  • 为任何添加的文件夹创建文件夹引用 -- 并且添加的文件夹将是蓝色的,就像在“加载预设”-演示项目中一样!
  • 关于xcode - iOS LoadPresetDemo 示例代码中的 AU Preset (.aupreset) 资源路径问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9135764/

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