Introduction
I've recently spent some time reading through some audio forums to increase my knowledge of audio amplifiers. I was building a headphone amplifier and wanted additional input into how the achieve the best bang for buck.
What I noticed is that there are many misconceptions about various computer audio elements that are causing many people to spend lots of money and time trying to achieve benefits in the wrong places.
Over the next few weeks I'm going to write some articles to try and dispel some of these misconceptions. My articles are going to concentrate on what can and can't effect the audio quality in a computer system (your PC), and the technical reasons why this is so.
The idea here is not to attempt to prove any subjectivists wrong over their beliefs, but to provide the information to enable them to make their own decisions.
In this article, I'm going to start off with a rather low-tech explanation of the difference between MP3 (as an example of lossy compression), FLAC (as an example of lossless compression) and WAV (an example of no compression) files.
For simplicity sake, when I refer to audio files in this article, I'm referring to CD quality 44 KHz 16 Bit rips to WAV, FLAC and MP3.
What is digital audio?
Here is a little info to form a basis of what digital audio is to help understand the following parts of this article.
Audio typically starts by being produced in the analogue world, that is, what musicians play on instruments and what we hear with our ears - this is all analogue. This analogue sound is a bunch of sound waves that are processed by a ADC (an Analogue to Digital Converter) to create a bunch of samples using a process call pulse code modulation. Don't worry about the full technical details in those links unless you're interested in them, you won't need to read or understand them to follow this article. A great detailed page to start on if you're interested in the gory details is the Wikipedia page on digital audio, but again, this is only for information and is not required for this article.
To listen to this digital audio it must be converted back into an analogue wave (sound). This is done using the opposite process by a device called an digital to analogue converter (DAC). The DAC takes the data generated by the ADC and converts it back to analogue so we can hear it.
WAV Files - No compression
A wave file just contains the numbers that the ADC produced, saved to a file. To reverse the process, the numbers are read from the file and given to a DAC that converts it back to analogue. Quite simple, not much can go wrong here.
Lossless Compression - FLAC
Flac files contain the same data as WAV files except they are compressed using a lossless compression algorithm.
I consider the algorithm used for FLAC files too complicated for this article, so instead of explaining it's implementation I'll use a simple form of lossless compression to explain how lossless compression works and why it will never lose any information due to its compression.
I'll describe a technique of substitution which is simple to understand and illustrates lossless compression well.
Let's take this simple block of text that we want to compress, but we don't want any loss of information.
i have a feline, it sat on a mat. i like the feline because his fur is black. the feline that sat, is black. the mat is black, the feline is black. his fur is on the mat.
Now, I'm providing a very loose example here that will yield poor compression, but this is only to show you how the process works.
Let's assign a number to represent each word exists in that text, we'll call this the 'map':
i = 2
have = 3
a = 4
it = 5
sat = 6
mat = 7
on = 8
the = 9
like = 8
his = 10
fur = 12
is = 13
that = 14
black = 15
because = 16
Now that we have a number for each word, we can replace each instance of the word with its corresponding number.
2 3 4 1, 5 6 8 4 7. 2 8 9 1 16 10 12 13 15. 9 1 14 6, 13 15. 9 7 13 15, 9 1 13 15. 10 12 13 8 9 7.
Now, as you can see that the text is compressed into a much smaller sentence. Now this is rather poor compression as you need to include the 'map' of words to numbers. This will be more effective for larger blocks of text with more repeating words. For example if our text was repeated many times the compression is more effective. Remember this technique is only for illustration purposes and is not a practical implementation of lossless compression.
As you can see, to get the original text back you would just replace each number with its corresponding word. There will be no lost information and the result will be identical to the original block of text.
As shown in this example, the data in a Flac file when uncompressed is exactly the same as the data that was used before compression, that is, there is no loss of data what-so-ever.
This is very different from lossy compression.
MP3 lossy compression
MP3s use what is called lossy compression, that is, information is lost in the compression process and the original can never be recreated from the compressed version.
The main technique behind MP3 compression is to remove parts of the audio data that is believed to no be perceivable to humans, that is, we won't hear the difference. The higher the compression rate, the more information is removed and the lower the quality. Now whether we can perceive this removed data is not part of this article, although I may touch on that in a later article.
To illustrate lossy compression, I'm going to use an even less effective compression example (and somewhat ridiculous one at that) as I want to illustrate the idea in a simple manner.
Let's take our original block of text again
i have a feline, it sat on a mat. i like the feline because his fur is black. the feline that sat, is black. the mat is black, the feline is black. his fur is on the mat.
Now if I was to attempt to compress this block of text by removing (or changing) things that I don't think make a difference, the text can still convey its message but the original will be lost, here is my attempt.
i have a cat sat on a mat i like the cat coz his fur is blck the cat that sat is blck the mat is black the cat is blck his fur is on the mat
Now, in my poor attempt to compress this block of text, I've replaced 'feline' with 'cat', removed all punctuation, misspelt 'black' as 'blck' etc. Now if I sent that text to a friend and asked them to reproduce the exact original, this could not be done it might be close, but is very unlikely to be the same. But the text still portrays a very similar message (albeit poorly).
Summary
Ok, so I've attempted to show you how lossy versus lossless compression techniques differ and why lossless is lossless, there is never any degradation of the data, when played back it will be exactly the same as the original, every time.
If you came here believing that WAV files are superior to FLAC (or other lossless compressed files) then I hope I have dispelled that misconception and you can happily compress your WAV files to FLAC knowing that you're not losing any data in the process.
Note also, that the FLAC file format allows other additional meta data like ID3 tags to be embedded in the file, such as track name, artist info, images, etc. The WAV file format does not provide this facility and is a major drawback.
I hope this has helped you, if it has or if you think I've got something wrong or could explain something better, please leave a comment.
