Sonia Nagala

sonian@ccrma.stanford.edu


220a Final Project:

Exploring the Effects of Quantization Noise


Overview:

For my final project, I wanted to get back to the basics of digital audio and gain a hands-on understanding of how audio compression causes some loss of original data contained within a file. I decided to use a clip from my own music to explore the effects of quantization noise and determine at what point the original file is no longer recognizable. I used the starter C++ code from a homework assignment I found in the syllabus of Music 422 and coded up the quantize.c file to convert the original signal into sample clips ranging from 1-bit to 8-bit versions. I was surprised to find that even with only 1 bit of information, the original clip is still somewhat recognizable. I was also surprised to hear that in going from the 16 bit to 8 bit sample, which is basically a reduction of half of the original data, the file still sounds relatively good. I think it'd be interesting to explore at what exact number of bits the resulting file is completely unrecognizable and useless. In addition to creating WAV files with bit per sample ranges from 1 to 8 (along with the original 16 bit file) I opened each of the files in snd to analyze the waveforms and see when you can visually notice the effects of further compressions.


Background:


The digital representationof audio data offers several benefits, including high noise immunity, stability, and reproducibility. Audio in digital form also allows for the use of complex audio processing functions, like mixing, filtering, equalization, etc. The conversion from the analog to the digital domain begins by sampling the audio input in regular, discrete intervals of time and quantizing the sampled values into a discrete number of evenly-spaced levels. The digital audio data consits of a sequence of binary values representing the number of quantizer levels for each audio sample. The number of quantizer levels is typically a power of 2 to make full use of a fixed number of bits per audio sample to represent the quantized values. With uniform quantizer step spacing, each additional bit has the potential of increasing the signal-to-noise (SNR) ratio, or equivalently the dynamic range, of the quantized amplitude roughly 6 decibels. Similarly, using one less bit can potentially reduce the SNR ratio and dynamic range by 6 decibels. The typical number of bits per sample used for digital audio ranges from 8 to 16, but my project instead looks at clips with the range of bits per sample being 1 to 8.


When I decrease the number of bits per sample in each of the following examples, I am using lossy data compression—that is, where the process of compression has resulted in a loss of some of the original data. In the case of lossy digital audio formats, the data that is lost or thrown away is intended to be data that is not heard, therefore producing a copy that is nearly aurally distinguishable from the original. However, as you can hear in each of the following examples, the lossy data compression has created much quantization noise that is very noticeable. I notice the quantization noise most in going from the 5 bit sample to the 4 bit sample, (and you can see this visually in looking at the waveforms below) although the sound quality starts to degrades gradually already from the original 16-bit file.


Effects of Quantization Noise:

16 bit (original)

We Wish You A Merry Christmas

8 bit

We Wish You A Merry Christmas

7 bit

We Wish You A Merry Christmas

6 bit

We Wish You A Merry Christmas

5 bit

We Wish You A Merry Christmas

4 bit

We Wish You A Merry Christmas

3 bit

We Wish You A Merry Christmas

2 bit

We Wish You A Merry Christmas

1 bit

We Wish You A Merry Christmas



Links to the waveforms in snd:


16 bit (original)


8 bit


7 bit


6 bit


5 bit


4 bit


3 bit


2 bit


1 bit



C++ code used to compress original file:

audiofile.c (provided)

audiofile.h (provided)

codec.c (provided)

codec.h (provided)

file.h (provided)

file.c (provided)

Makefile (provided)

quantize.c (main file)

vector.h (provided)

vector.c (provided)