[英]What's the best format for sound effects on iPhone
What is the recommended audio format for storing and playing back short (2-3 sec) audio sound effects on the iPhone or iToouch? 在iPhone或iToouch上存储和播放短(2-3秒)音频音效的推荐音频格式是什么?
The iPhone audio SDK documentation indicates that the iPhone supports audio in several formats - however there are drawbacks to each: iPhone音频SDK文档表明iPhone支持多种格式的音频 - 但每种格式都有缺点:
Any recommendations would be appreciated... it would also be helpful if someone could recommend a reasonably priced tool for processing audio that can generate the recommended format. 任何建议都将受到赞赏...如果有人可以推荐一个价格合理的工具来处理可以生成推荐格式的音频,也会有所帮助。 Thanks.
谢谢。
You can use IMA4 compressed files, which provide a 1:4 compression from WAV files and are decompressed by hardware (you can load them with an AVAudioPlayer
). 您可以使用IMA4压缩文件,这些文件从WAV文件提供1:4压缩,并由硬件解压缩(您可以使用
AVAudioPlayer
加载它们)。
As for MP3, you can only play one file simultaneously in that format, that's why it's not recommended for sound effects where you could have more than one at the same time. 至于MP3,你只能以这种格式同时播放一个文件,这就是为什么不建议你同时拥有多个音效的音效。
I'm using IMA4 files with OpenAL, so I'm decompressing them manually with a code based on this post . 我正在使用OpenAL的IMA4文件,所以我用基于这篇文章的代码手动解压缩它们。
I've had pretty good luck with CAF format files although WAV comes close in size. 虽然WAV的尺寸接近,但我对CAF格式文件运气不错。
As for tools, Audacity is free and reasonably functional. 至于工具,Audacity是免费且功能相当的。 I mainly use Amadeus Pro (around US$40).
我主要使用Amadeus Pro(约40美元)。 Pretty decent and generates all the iPhone supported audio formats (including MP3, AIFF, WAVE, AAC, and CAF).
相当不错并生成所有iPhone支持的音频格式(包括MP3,AIFF,WAVE,AAC和CAF)。 A nice feature is that it supports AudioUnit and VST plug-ins so you can add SoundFX.
一个很好的功能是它支持AudioUnit和VST插件,因此您可以添加SoundFX。
I've also heard good things about Fission (by Rogue Amoeba) but haven't actually used it. 我也听过关于Fission的好消息(由Rogue Amoeba提供),但实际上并没有使用它。 Their other audio products are pretty solid.
他们的其他音频产品非常稳固。
The AVAudioPlayer
framework is pretty good at playing short clips, but you may want to pre-load the sounds (call prepareToPlay
) and keep them around if you can spare the memory. AVAudioPlayer
框架非常适合播放短片,但你可能想要预先加载声音(调用prepareToPlay
)并保留它们,如果你可以节省内存。
Take a look at the afconvert command line utility on your Mac. 看一下Mac上的afconvert命令行实用程序。 It does many conversions between different audio formats, and if you have a lot of sounds, you can script the conversions...
它在不同的音频格式之间进行了很多转换,如果你有很多声音,你可以编写转换脚本......
I use SoundToolbox and AVAudioPlayer with sounds mostly in uncompressed linear PCM, created in GarageBand. 我使用SoundToolbox和AVAudioPlayer,声音主要是在GarageBand中创建的未压缩线性PCM。
SoundToolbox is great for playing a short little "Boing" or "click" or other sounds that you trigger to play and you don't care about stopping or messing with their volume etc. SoundToolbox非常适合播放短小的“Boing”或“click”或其他您触发的声音,而您不关心停止或搞乱音量等。
If you want to stop a playing sound or to know if the sound is done playing, AVAudioToolbox is nice. 如果你想停止播放声音或者知道声音是否播放完毕,AVAudioToolbox很不错。 If you want to play sounds with control over the left and right components of the sound, then look at OpenAL.
如果您想通过控制声音的左右分量来播放声音,请查看OpenAL。
If you haven't already, read Apple's iPhone Application Programming Guide on Sound support. 如果您还没有,请阅读Apple的iPhone应用程序编程指南中的声音支持。
If sound is important to your app, you may want to take advantage of some of features available to you for very little work. 如果声音对您的应用程序很重要,您可能希望利用一些可用的功能来完成很少的工作。
The only format I've been able to get to work is CAF. 我能够使用的唯一格式是CAF。 It is also the one in most the code examples from apple.
它也是苹果代码示例中最多的一个。 If you are using short sound effects the size won't be a problem.
如果您使用的是短音效,则尺寸不会有问题。
I've been using Microsoft ADPCM WAV format which compresses from 3.25:1 (high quality) to 3.98:1 (default quality). 我一直在使用Microsoft ADPCM WAV格式,它从3.25:1(高质量)压缩到3.98:1(默认质量)。 Also I reduce sample rate to 32000 or even 22050 depending on the sound.
此外,我根据声音将采样率降低到32000甚至22050。 There is no need to save some files in stereo - mono also reduces the size of file pretty well.
没有必要在立体声中保存一些文件 - mono也可以很好地减小文件的大小。
For background music mp3 is fine. 对于背景音乐mp3很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.