gpt4 book ai didi

ios - 如何将 .wav 文件转换为 .caf 文件以便在 iOS 中使用

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:54:10 24 4
gpt4 key购买 nike

我对音频或终端一无所知。我使用这个终端命令转换一个 wav 文件以在 iOS 中使用:

afconvert -v -f 'caff' -d LEI16 -s 1 /users/myUserName/Desktop/hibeep.wav /users/myUserName/Desktop/hibeep.caf

将文件添加到我的项目后,执行时没有任何反应:

NSURL * softURL = [[NSBundle mainBundle] URLForResource: @"hibeep" withExtension: @"caf"];
CFURLRef softSoundURL = (__bridge CFURLRef) softURL;
AudioServicesCreateSystemSoundID(softSoundURL, &_beepSound);
AudioServicesPlaySystemSound (_beepSound);

然而,当我在 Project Navigator 中单击 hibeep.caf 时,声音会正常播放。

我在模拟器和 iPad 上都试过了。

有什么建议吗?

谢谢

最佳答案

TL;DR;

afconvert /System/Library/Sounds/Submarine.aiff ~/Desktop/sub.caf -d ima4 -f caff -v

长版:我知道这已经过时了,但是这个线程已经解决了我的问题,所以这里是问题的解决方案。

CAF 只是一个容器,您对容器中保存的数据使用了错误的编解码器。引用苹果文档:

Custom alert sounds are played by the iOS system-sound facility, so they must be in one of the following audio data formats:

Linear PCM MA4 (IMA/ADPCM) µLaw aLaw

这是将 WAV 转换为 CAF (MA4) 时的正确终端命令

afconvert /System/Library/Sounds/Submarine.aiff ~/Desktop/sub.caf -d ima4 -f caff -v

关于ios - 如何将 .wav 文件转换为 .caf 文件以便在 iOS 中使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28255279/

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