简体   繁体   English

iPhone应用程序的声音格式

[英]Sound format for iPhone app

What kind of audio files are you using in your iPhone games/apps? 您在iPhone游戏/应用程序中使用了哪些音频文件?

I have a game with 30MB of sounds in .wav format and I'm thinking of maybe converting to .mp3 to reduce the app size... Is there a major difference in performance? 我有一个30MB的.wav格式的游戏,我想可能转换为.mp3以减少应用程序的大小...性能有很大差异吗? Any other issues? 还有其他问题吗?

Keep in mind that certain codecs run in hardware and others in software. 请记住,某些编解码器在硬件中运行,其他编解码器在软件中运行。 Therefore not all compressions will allow for simultaneous playback of more than one sound. 因此,并非所有按压都允许同时回放多个声音。 For example, if you have a sound playing, a UI sound like a beep may not play if both were trying to use the same codec. 例如,如果您正在播放声音,如果两者都试图使用相同的编解码器,则可能无法播放类似哔声的UI声音。 For more info, see: 有关详细信息,请参阅:

http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AudioandVideoTechnologies/AudioandVideoTechnologies.html#//apple_ref/doc/uid/TP40007072-CH19-SW6 http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AudioandVideoTechnologies/AudioandVideoTechnologies.html#//apple_ref/doc/uid/TP40007072-CH19-SW6

iPhone Audio Hardware Codecs iPhone OS applications can use a wide range of audio data formats. iPhone音频硬件编解码器iPhone OS应用程序可以使用多种音频数据格式。 Starting in iPhone OS 3.0, most of these formats can use software-based encoding and decoding. 从iPhone OS 3.0开始,大多数这些格式都可以使用基于软件的编码和解码。 You can simultaneously play multiple sounds in all formats, although for performance reasons you should consider which format is best in a given scenario. 您可以同时播放所有格式的多种声音,但出于性能原因,您应该考虑在给定方案中哪种格式最佳。 Hardware decoding generally entails less of a performance impact than software decoding. 硬件解码通常比软件解码具有更少的性能影响。

The following iPhone OS audio formats can employ hardware decoding for playback: 以下iPhone OS音频格式可以采用硬件解码进行播放:

AAC ALAC (Apple Lossless) MP3 The device can play only a single instance of one of these formats at a time through hardware. AAC ALAC(Apple Lossless)MP3设备一次只能通过硬件播放其中一种格式的单个实例。 For example, if you are playing a stereo MP3 sound, a second simultaneous MP3 sound will use software decoding. 例如,如果您正在播放立体声MP3声音,则第二个同步MP3声音将使用软件解码。 Similarly, you cannot simultaneously play an AAC and an ALAC sound using hardware. 同样,您无法使用硬件同时播放AAC和ALAC声音。 If the iPod application is playing an AAC sound in the background, your application plays AAC, ALAC, and MP3 audio using software decoding. 如果iPod应用程序在后台播放AAC声音,则应用程序将使用软件解码播放AAC,ALAC和MP3音频。

To play multiple sounds with best performance, or to efficiently play sounds while the iPod is playing in the background, use linear PCM (uncompressed) or IMA4 (compressed) audio. 要播放具有最佳性能的多种声音,或在iPod在后台播放时有效播放声音,请使用线性PCM(未压缩)或IMA4(压缩)音频。

To learn how to check which hardware and software codecs are available on a device, read the discussion for the kAudioFormatProperty_HardwareCodecCapabilities constant in Audio Format Services Reference. 要了解如何检查设备上可用的硬件和软件编解码器,请阅读“音频格式服务参考”中有关kAudioFormatProperty_HardwareCodecCapabilities常量的讨论。

Both AAC and CAF formats work fine and offer decent file sizes. AAC和CAF格式都可以正常工作并提供合适的文件大小。 For certain background looping tracks I found MP3 files getting too big, but YMMV. 对于某些背景循环音轨,我发现MP3文件太大,但是YMMV。 Experimenting with a decent sound editing app is the only way to find the right balance between size and quality. 尝试使用体面的声音编辑应用程序是在尺寸和质量之间找到适当平衡的唯一方法。 I've had pretty good luck with Audacity and Amadeus Pro. 我和Audacity以及Amadeus Pro都有相当不错的运气。

Suggest listening to the output with a pair of really good noise-isolating headphones on the device itself. 建议在设备上使用一对非常好的隔音耳机听输出。 Most people won't be listening to your stuff with these but as you decrease sound quality to shrink file sizes you'll start getting static and hum artifacts. 大多数人不会用这些来听你的东西但是当你降低音质以缩小文件大小时,你会开始获得静态和嗡嗡声的文物。 It's just a matter of balancing size vs. quality and what you're willing to live with. 这只是平衡尺寸与质量以及您愿意接受的问题。

I use a combination of WAV files (for sound effects) and MP3 (for music), which seems to work fine. 我使用WAV文件(用于音效)和MP3(用于音乐)的组合,这似乎工作正常。 You can have trouble if you try to play multiple MP3 files at the same time - drop outs, or performance degradation, depending on your AudioSession settings. 如果您尝试同时播放多个MP3文件 - 丢失或性能下降,则可能会遇到问题,具体取决于您的AudioSession设置。

If I had to compress my sound effects, I'm not sure which codec has the least decoding overhead. 如果我不得不压缩我的声音效果,我不确定哪个编解码器具有最少的解码开销。 Something like Apple Lossless would likely work well, and would cut the size roughly in half. 像Apple Lossless这样的东西可能效果很好,并且可以将大小缩小一半。

我发现mp3很好,但请记住,iPhone / Touch2G上的解码只有大约2.5倍的实时速度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM