音频解码

1. 音频格式

有两类主要的音频文件格式:

  • 无损格式,例如WAV,PCM,TTA,FLAC,AU,APE,TAK,WavPack(WV)
  • 有损格式,例如MP3,Windows Media Audio(WMA),Ogg Vorbis(OGG),AAC
    有损文件格式是基于声学心理学的模型,除去人类很难或根本听不到的声音,例如:一个音量很高的声音后面紧跟着一个音量很低的声音。MP3就属于这一类文件。
    无损的音频格式(例如TTA)压缩比大约是2:1,解压时不会产生数据/质量上的损失,解压产生的数据与未压缩的数据完全相同。如需要保证音乐的原始质量,应当选择无损音频编解码器。例如,用免费的TTA无损音频编解码器你可以在一张DVD-R碟上存储相当于20张CD的音乐。
    有损压缩应用很多,但在专业领域使用不多。有损压缩具有很大的压缩比,提供相对不错的声音质量。

游戏中应该使用OGG格式的音频文件用于游戏的发布,然后在第一次运行时解压成WAV格式:

You can’t really ask OGG or WAV, because OGG is used for distribution and publishing, while WAV is used for raw material and editing.
Of course if someone uses WAV for distribution and publishing, he should be hanged.
MP3 is out of the question, since it kills high frequencies, making all AAA songs sound like crap. Besides, I think every single MP3 on the planet is illegal, since you should pay license fees to Frauenheimer for each self-made, listened, bought, and otherwise handled MP3. Nobody does that, so everyone is a criminal who uses MP3.

Well, for mobile devices (like the iPhone), decompressing OGG’s takes too much processor time, compared to WAV’s. So an approach would be to include ogg in the package for the small size, but uncompress them at load-time (just once) so that you can play them faster…

理由:

  • 音乐质量相对较高,压缩比较大,且是一种免费的开源格式;
  • WAV格式压缩比太小,增大游戏安装包的资源;
  • MP3格式的文件大多是非法的,且去除了很多高音频和低音频的部分,效果较差。


    音频解码_第1张图片
    FMOD6.png

Ref:

http://zh.wikipedia.org/wiki/%E9%9F%B3%E9%A2%91%E6%96%87%E4%BB%B6%E6%A0%BC%E5%BC%8F
http://www.gameproducer.net/2009/10/23/ogg-or-wav/
http://developer.android.com/guide/appendix/media-formats.html

你可能感兴趣的:(音频解码)