Take the 2-minute tour ×
Sound Design Stack Exchange is a question and answer site for sound engineers, producers, editors, and enthusiasts. It's 100% free, no registration required.

Anyone who works with audio either as a hobby or as a professional knows about MP3 and WAV, and the advantages and disadvantages of each. Namely:

  • MP3 (most commonly MPEG III)
  • WAV (Waveform Audio File Format)
    • disadvantage: audio data not compressed
      • relatively large file size
    • disadvantage: 4 GiB (232 - 1) file size limit
    • advantage: crystal clear quality

Being an audio "producer", I know to use WAV for everything. However, I'm in a dilemma. As stated above, WAV files are large. A 4 minute stereo song is about 50 megabytes. All those songs add up. In addition, WAV files don't support metadata like MP3 does as far as I've seen.

I can always compress the files with 7-zip's "ultra" option, but this isn't reasonable (or feasible) for files I'm currently working with.

What I'm looking for is an audio format that has the "crystal clear" quality that WAV has with the metadata ability and small file sizes of MP3. Essentially, an audio format that has losslessly compression and metadata. I would prefer it to be widely supported. Maybe just an MP3 codec that is lossless? Does anything like this exist?


audio quality depends on export or rip quality and speakers

share|improve this question

migrated from video.stackexchange.com Feb 21 at 10:44

This question came from our site for engineers, producers, editors, and enthusiasts spanning the fields of video, and media creation.

2 Answers 2

up vote 16 down vote accepted

Just four letters: FLAC.


Some explanation / thoughts on the subject

Warning: this includes personal opinions that aren't necessarily mainstream-accepted. See AJ Henderson's answer for a somewhat more moderate view.

I'd first like to say: being pedantic, there is no such thing as a lossless audio file. Audio is an analogue phenomenon, anything digital can only ever be an approximation. So there is no quite as fundamental difference between "lossless" and lossy codecs as it is always said. If you compare a 11.025 kHz / 8 bit mono .wav file to a 110 kbit/s 48 kHz .mp3 or .ogg by ear, the "lossy" format will clearly win quality-wise, while having almost the same size. That's because these lossy codecs omit information "cleverly", i.e. in such a way as to minimize the impact on how the audio sounds, whereas .wav just quantises time and amplitude everywhere uniformly1.

The human ear has some rather simply specifiable, and some more complicated limits.

  • Any Fourier components above ca. 20 kHz in a signal are virtually inaudible. So (by the Shannon-Nyqvist theorem), technically perfect PAM sampling with rates above 40 kHz yields a representation of the signal that our ears cannot distinguish from the original.

  • Since our body has a finite temperature, there is necessarily some noise floor in our ears. If any noise introduced by digital quantisation stays below this threshold, it won't be audible. Effectively, the dynamic range of the human ear is no more than 140 dB (oftentimes the useful range is much lower); 24-bit integers cover a range of 144 dB. So a properly dithered 24-bit PCM version of a 48 kHz PAM signal will still be indistinguishable (by bare ear) from the analogue original signal.

This is why we call such .wav files (or even CD-quality ones) lossless: the losses are inaudible, so for all relevant purposes they don't exist.

Wait a moment. Is listening really the only thing you do with an audio file? Why, no, you might first pull the signal through all kinds of audio effects. Many of those (e.g. reverb or basic EQing) won't really change anything about the sampling limit and dynamic range. But of others, this can't be said. Most obviously, a compressor takes in a signal with some dynamic range and outputs a signal with lower one. If you still want the final result to have "lossless" quality, you need to make sure the intermediate file has a higher dynamic range than what you want on your ears. This is why professional recordings are nowadays never done on less-than-24-bit files, even if you ultimately need only 16 bit CD-quality. High bit depths pretty much solve the problem for everything ever used in 99% of all audio productions, but it's quite obvious that there are effects where it's not enough: consider simply a strong pitch-down effect. You'd expect this to make ultrasonic sounds audible, but this can't possibly work if the recorded file has only 44.1 kHz sampling rate. Fortunately, such stuff is seldom needed.

Back to out ears' limits – I said there are more complicated ones. Which is why I'm not going to discuss them in detail here, but they're mostly about masking effects: during silence, even very quiet noise is audible, but while there is loud music much higher levels of noise would go unnoticed. So at these parts, you can quantise much rougher – that's easiest done with floating-point samples. This is especially efficient when not working purely in time space but confining the artifacts to frequency ranges where there is also high amounts of signal. To this extend, most lossy algorithms (apart from mp3 I'd like to mention Ogg Vorbis, which BTW doesn't have those patent issues) use a type of Fourier transform, usually DCT, before their main quantisation step. This can work very effectively, as demonstrated by small yet well-sounding .ogg files. In fact, continuing the logic used above: if we manage to produce such a file that humans can in a double-blind test not distinguish from the original, why should we not call this file lossless? It has "errors" (artifacts), but again a .wav file isn't exact either.

However, artifacts in .mp3 are much more complicated than simple quantisation noise or high-frequency band cutoffs. Even when they're still inaudible to the ear, they may have a much more significant effect when fed into further processing, like recompression to another format or audio effects. They're just not designed for that. OTOH, bandlimiting and quantisation noise are very well understood and modelled mathematically exact; you can transform between different sample rates without generation loss, you can re-dither to other bit depths etc.. This makes it acceptable to call lossless formats thus, even though really they aren't lossless. And it's why they are the right choice during audio processing2.

⟨/rant⟩

So how do formats like .flac fit into all this? Lossless means again to keep the benefits of plain PCM like .wav, i.e. not allowing bad-to-handle artifacts. In fact it means you are able to convert a .flac file back to a .wav that will be identical to the original source .wav.

Question is, do we have to live with he large size of PCM files?
If you think about it, there must be physical reasons why our ears are so insensitive to e.g. DCT-quantisation artifacts. From one point, it appears that they mechanically aren't able to properly follow those. From another point, you might also say that real-world sound happens to be of a kind that de-emphasises such artifacts. These arguments are in fact interchangable, as any sound transmitter is also a receiver and an instrument's body is in a way analogue to the eardrum (more literally, a microphone is equivalent to a small loudspeaker). So it should be possible to make up a compression scheme the other way around: instead of thinking "how do we leave out information so the difference won't be notable?" we go "where do we expect to find no information in the first place?" Because then we can use entropy coding, which basically just shuffles data around in a clever way, such that information that was already expected takes up little space while only (seldom-occurring) unexpected information is fully expanded. When we then feed such an algorithm with an audio file that conforms with our expectations (and thus with our ears', which has pretty good experience in those matters), the compressed version will be significantly smaller yet digitally equivalent to the .wav version. And this does in fact work quite well.


1 Actually, there are several rather crude "better-quality" compression schemes that .wav can use. Much more primitive than the DCT-based algorithms that mpeg or Vorbis employ.

2 (this isn't so much a footnote as a conclusion) I should still add that there's another consideration for audio processing: unlike in a simple music player, a DAW needs to access many audio files simultaneously, very quickly, and possibly non-sequentially. This is very easy with a format like .wav, which is encoded completely in the time domain: want to enter at 2:35? Why, just add the offset 155*samplerate*bytespersample to the file position and start playing from there. By contrast, both lossy and lossless compressed file formats have the data somewhat disordered by the various transformations. You usually still have some kind of time-chunks that you can each access directly, but you can't quite as easily just start playing at some arbitrary point – there's always some pre-load, latency, memory&processing overhead and whatnot. So even though .flac may seen the perfect alternative, I actually don't use it that much: disk space is cheap nowadays, so .wav is rather fine. If I need 20GB for a song I'm working on for 20 hours, the storage cost is pretty much neglectable: I can just get a new external HDD when I need it. So there's not much reason to switch to .flac and if it might cause latency issues during an important recording session, I'd have quite a problem. So that's not going to happen.

With finished mastered song files it's rather different: those are just going to be fed into your ears, nothing else. So here the crucial thing is subjectively lossless again: lossless to the ear. Now, I positively dislike the sound of so-called "CD-quality" 128 kBit/s .mp3 files, but for >200 kBit/s, done with a good encoder like lame (with the more maturely designed Vorbis or e.g. .aac you can go even lower) you won't be able to tell the difference. You just won't. So it ******* is lossless, and these files will be quite a lot smaller than the tightest that "lossless codecs" can do.

share|improve this answer
3  
I had to knock off my upvote because lossless isn't because it captures everything our ear can hear, it's because the compression does not degrade the sampled waveform. Increases in sampling frequency and bit depth both produce noticeable improvements in audio, so under your definition of lossless, no 48khz, 16 bit audio would be lossless. Sampling is always lossy, lossless formats simply don't lose any additional information. –  AJ Henderson Jul 11 '13 at 4:43
1  
Also, 320kbit is enough for most hardware, but if you have really good gear and a trained ear, the difference is still obvious, though not as obvious as the loss from live sound from a mixer vs a 48khz 16 bit recording. Unless you've spent years analysing sound though, you are correct, very few people actually hear the difference even when listening for it. –  AJ Henderson Jul 11 '13 at 4:47
1  
@AJHenderson: "Sampling is always lossy..." that was pretty much the whole point of my rant, wasn't it? The reason I don't really agree with calling .wav or .flac any more lossless than Vorbis or .mp3 is that there's nothing intrinsically special about PCM sampling – it is not even necessarily what AD converters use internally. The only meaningful definition of lossless is artifacts cannot be proven to exist under the targeted hearing conditions. Which is fulfilled by high-quality .wav as well as by high-quality .ogg files. –  leftaroundabout Jul 11 '13 at 11:30
1  
@leftaroundabout - I guess we'll just have to agree to disagree on what is discernible then. I've done blind tests of higher sample rates of PCM audio and have been able to pick out the higher quality sample. As the quality goes up, the amount of increase in quality to detect it goes up to as the differences become increasingly small, but that doesn't mean that there aren't artifacts present that can be detected, particularly when played against a significantly higher quality signal. It also depends on how much is going on in the signal though. A band is easier than a speaker to tell. –  AJ Henderson Jul 11 '13 at 13:57
2  
I love this post, but AJ is right - for flac the meaning of lossless is precise.it is equivalent to eg winzip being able to reproduce exactly the files compressed within it, despite the size of the zip file being much smaller than the original. The PCM file will be exactly reproduced, at bit level. –  Rory Alsop Jul 11 '13 at 17:28

FLAC (free, lossless audio codec) is a non-patent encumbered audio codec that utilizes lossless compression to store the audio. There are many other lossless options that support compression, but FLAC is more or less the defacto standard. Since it is lossless, the waveform from it will exactly match an uncompressed wav, however it looks for patterns in the audio that can be described exactly, thus finding some space savings. This is basically how all compression works, just lossy compression doesn't mind if it can't make a perfect fit where as lossless means that only an exact match will do.

It is worth noting that lossless files only mean that they store the exact sampled values. All digital audio sampling is an approximation of the analog audio source (unless it is natively produced electronic sounds.) Lossless files ensure you don't get any artifacts from compression though they require a lot of extra space for fairly minimal quality gain for the average listener.

On average gear, the difference between sufficiently high quality lossy and lossless files is going to be almost impossible to tell even with a trained ear. On high end audio gear, with a trained ear, it can be possible to recognize the differences mostly by picking up on artifacts in the sound that alter it subtly, but the average person won't typically notice the difference as long as it is a good quality level. (320kbps for example is more than sufficient data rate for probably 99.9% of the population to not recognize the difference between lossy and lossless.)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.