Being an electronic music producer, file format is something I have to consider at some point. I usually export my songs as .wavs and then convert them to .mp3s later (since they are smaller than .wavs). But can someone tell me which is better concerning sound quality or other factors?
The executive summary of Charles' very detailed answer is:
- Use WAV for recording and editing.
- Use your audio editor's native file format with references to the WAV files to keep disk space under control
- use MP3 for distribution. 44.1 and 160kbps is lots, unless your audience has a home stereo that is worth more than their car and ears to match.
Wave is an uncompressed or lossless format, whereas MP3 is compressed or lossy. Technically .wav is just a container format and can hold various types of compressed or uncompressed audio, but typically you'll see it containing LPCM uncompressed audio (the same as on audio CDs). With .wav files, you are essentially getting a raw bitstream representation of the audio signal in digital form. An analog sound produced in the real world contains essentially an infinite amount of information because it is a wave that is constantly changing (see below). In order to bring these sounds into the digital domain you need to sample the signal at various intervals to make an approximation of the sound. For .wav the audio signal is usually sampled at 44,100 times per second or more, and each sampled value is recorded so the sound wave can be reproduced:
The analog sound wave is sampled at every T interval to make a digital approximation of the original signal. (For digital audio T is usually 1/44,100th of a second or less)
MP3s are compressed in order to squeeze the same audio information into a smaller file size. The .wav format is great for very faithful representations of the analog signal, but as you probably know that's usually at the cost of larger file sizes. Compressed audio (and video in a similar fashion) is designed to reduce the file size while still maintaining a respectable level of fidelity. In layman's terms, compression attempts to remove the unnecessary data from the stream and reduce the signal to its most necessary components. With MP3, the compression and encoding algorithms use a model of how we hear to analyze the audio in the frequency domain and remove any unnecessary information. For instance, due to auditory masking if there are two sounds at close frequencies, often we will only hear the louder one if the difference in volume between the two is significant. So for MP3, the lower volume sound could be discarded and the audio would sound essentially he same to our ears. More info on the technical side of MP3 encoding here.
In practice, both .wav and MP3 have their uses. For production, .wav is the standard because it will almost always be a 100% accurate, bit-for-bit reproduction of the source material. MP3s can be a decent alternative at high enough bitrates. The bitrate is the measure of how many bits per second the MP3 encoding will use, meaning the higher the bitrate, the closer the MP3 will be to the original, uncompressed stream. Bitrate is usually measured in kilobits per second (kbps). I like high audio quality for my digital music collection, so when I have the option I usually encode MP3s at a constant 256 or 320kbps. That is the higher end of what MP3s are capable of, and unfortunately a lot of digital music out there is not encoded that high. When the bitrate comes down, you can usually hear it first in the high frequencies, for example the cymbals from a drum kit will sound off. 160kbps is tolerable, but anything lower than that and you will really start to notice. But again, with a high enough bitrate the differences between MP3 and .wav are barely distinguishable, especially to an untrained listener (most listeners).
For .wav files we mostly look at bit depth and sample rate or frequency. Bit depth is the number of bits used to encode each sampled value. The sample rate tells how many times per second the audio is sampled. CD (.wav) and MP3 are encoded at 44,100 Hz sample rate (Hertz meaning "cycles per second"). Newer computers and audio hardware/software are now accommodating higher sample rates, including 48kHz or 96kHz. For .wav the bit depth is usually 16-bits or 24-bits on the newer systems. For most purposes, when using .wav, 16-bit and 44.1kHz is sufficient, but if you have the capabilities it's usually worth upgrading to 24-bit, 48kHz.
Some example file sizes for a stereo five minute recording:
- .wav, 16-bit, 44.1kHz: 50 MB
- .wav, 24-bit, 48kHz: 82 MB
- .wav, 24-bit, 96kHz: 164 MB
- MP3, 128kbps, 44.1kHz: 4.5 MB
- MP3, 192kbps, 44.1kHz: 7 MB
- MP3, 320kbps, 44.1kHz: 11 MB
- FLAC, 24-bit, 44.1kHz: 28 MB
- FLAC, 24-bit, 48kHz: 31 MB
- FLAC, 24-bit, 96kHz: 61 MB
There is also a variable bitrate option for MP3 encoding, which should offer slightly smaller file sizes for the same quality. It uses an encoding scheme that changes (varies) the bitrate for different portions of the song depending on complexity and how many samples would be needed to recreate a given section faithfully.
[Edit: FLAC] There is a third category as well: lossless compression. FLAC is a good example of this, and has the quality and fidelity of a .wav file but with smaller file sizes (still considerably larger than MP3 though). One downside of FLAC, especially in a production setting, is that not all software can play it. I use it for certain albums in my personal digital music collection where I want a more faithful reproduction than MP3. But for production I usually stick with .wav and MP3.
[TL;DR] I keep my samples and loops as .wav if I can help it, and usually encode my finished tracks to MP3 for distribution. If you have the option, go with .wav. But if there are space constraints or you only have an MP3 version of something, as long as it's a high enough bitrate (at least 256kpbs is ideal), most people can't tell the difference.