We noticed that many young indie developers ask the question what is the best music format for their games. There are so many audio file formats these days. Which ones to choose? In this article we will look at this topic more closely and show you the advantages and disadvantages of various solutions and their practical application in real situations.
General Audio Types
There are compressed and uncompressed audio files, which may have either a lossy or lossless quality to it. They can be divided into three types:
- Files without compression - they take up the most space and their quality is determined by the sampling frequency and bit resolution. The main representative of this type of file is WAVE (WAV).
- Files with lossless compression - these files contain exactly the same information as files without compression, but thanks to intelligent coding techniques take up less space. In this group there are many formats such as: WMA, FLAC, Apple Lossless and others.
- Files with lossy compression - these files, using compression algorithms, do not contain full information, only the part that is the most audible for the human ear. There are many formats in this group, such as MP3, Ogg, AAC and others
MIDI, WAV, AIF, AIFF, MP2, MPG, MPE, MPEG, MPEG2, MP3... Why are so many different types of formats? The answer is simple each of the devices has a different characteristics and limited space. If space is premium, such as on smartphones or portable game consols then the smaller-sized compressed files are really all you need.
So how do you choose? Here’s a breakdown of common format types, some of their important characteristics, and reasons why you would use them.
MP3: Designed by the Moving Pictures Experts Group (MPEG), an organization that develops standards for coded audio and video programs, the MPEG-1/MPEG-2 Layer 3 (MP3) is arguably the most common and supported audio file type.
MP3 is both a compressed and lossy audio format, with bit rates ranging from 8 kbit/s up to a maximum of 320 kbit/s, and sampling frequencies ranging from 16 kHz to a maximum of 48 kHz. The smaller file sizes of MP3s means faster file transfers and less space used, but at the cost of some reduction in sound quality when compared to lossless file formats.
AAC: Made popular by Apple iTunes, the Advanced Audio Coding (AAC) format is similar to MP3, but with one added benefit of greater efficiency.
AAC is both a compressed and lossy audio format, with bit rates ranging from 8 kbit/s up to a maximum of 320 kbit/s, and sampling frequencies ranging from 8 kHz to a maximum—with the right encoding process—of 96 kHz.
AAC files can deliver the same audio quality as an MP3 while taking up less space. ACC also supports up to 48 channels, while most MP3 files can handle only two. AAC is widely compatible with but not limited to iOS, Android, and handheld gaming devices.
WMA: Developed by Microsoft as a competitor to the MP3, Windows Media Audio files offer a similar, albeit proprietary experience. The standard WMA is both a compressed and lossy audio format, although newer, distinct sub-versions with more advanced codecs can offer a lossless option.
While many types of portable media and home entertainment players support WMA files by default, few mobile devices like smartphones and tablets do. Many require downloading a compatible app in order to play WMA audio, which can make it less convenient to use versus MP3 or AAC.
FLAC: Developed by the Xiph.Org Foundation, the Free Lossless Audio Codec (FLAC) has much appeal because of its royalty-free licensing and open format.
FLAC is both a compressed and lossless audio format, with file quality able to reach up to 32-bit/96 kHz (by comparison, a CD is 16-bit/44.1 kHz). FLAC enjoys the advantage of a reduced file size (about 30 to 40 percent smaller than the original data) without having to sacrifice audio quality, which makes it an ideal medium for digital archiving (i.e., using it as the master copy in order to create compressed/lossy files for general listening).
ALAC: Apple's version of FLAC, the Apple Lossless Audio Codec (ALAC) shares much with respect to audio quality and file size with FLAC.
ALAC is both a compressed and lossless audio format. It's also fully-supported by iOS devices and iTunes, whereas FLAC may not be supported. As such, ALAC would most commonly be used by those using Apple products.
WAV: Also developed by Microsoft, the Waveform Audio File Format is a standard for Windows-based systems and compatible with a variety of software applications.
WAV is both an uncompressed (but can also be coded as compressed) and lossless audio format, essentially an exact copy of the source data. Individual files can take up a significant amount of space, making the format more ideal for archiving and audio editing. WAV audio files are similar to PCM and AIFF audio files.
AIFF: Also developed by Apple, the Audio Interchange File Format (AIFF) is a standard for storing audio on Mac computers.
AIFF is both an uncompressed (there is also a compressed variant) and lossless audio format. Like Microsoft's WAV file format, AIFF files can take up a lot of digital storage space, making it best for archiving and editing.
PCM: Used to digitally represent analog signals, Pulse Code Modulation (PCM) is the standard audio format for CDs, but also for computers and other digital audio applications.
PCM is both an uncompressed and lossless audio format, quite often acting as the source data for creating other audio file types.
File formats vs Game engines
For general use, it is best to use WAV, MP3 or FLAC files. The last deserves to be distinguished to be recognized for its abilities. However, in your production you can use one of the lossy formats and change your mind in the future. You can always convert from one lossy format to another, however, such a conversion degrades the quality of the sound. So the best way to avoid a wrong decision is to save losslessly compressed originals. It is difficult to predict how quickly data carriers will grow up, but it is possible that in the future memory limitations on mobile devices will be less important, and lossless compression will replace lossy compression.