No *_*ing 4 xcode core-audio ios5
我一直在使用iOS LoadPresetDemo示例代码 - 如果加载AUPreset文件来配置不同类型的采样器(非常酷) - 并且遇到了问题/问题.
演示代码运行正常,但是当我尝试在从头开始构建的测试项目中重用.aupreset文件时,Trombone.aupreset不起作用.深入研究.我发现.aupreset文件中的音频样本路径看起来很奇怪.
plist中的路径(下图)指向:
file://localhost//Library/Audio/Sounds/Tbone/1a%23.caf
Run Code Online (Sandbox Code Playgroud)
但这不是正确的路径 - 根据项目目录结构.没有"库/音频"目录 - 虚拟或真实.所以我很困惑.Apple演示工作正常,但我从头开始项目没有(尝试加载示例时得到错误-43).加载样本的代码(在底部)没有做任何事情来在运行时重新激活路径.
有谁看到我在这里误解了什么?- 谢谢!


// 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;
}
Run Code Online (Sandbox Code Playgroud)
小智 5
我遇到了同样的问题,经过2个小时的比较"加载预设"-Demo和我的代码后,我找到了解决方案:
添加声音文件夹时检查选项:
| 归档时间: |
|
| 查看次数: |
3124 次 |
| 最近记录: |