MATLAB code for quantization

To load a .wav file into MATLAB use the wavread command:

 

>Y=wavread(‘filename.wav’);

 

To quantize this signal to n bits, use the function p2_Quantize:

 

>Yquant=p2_Quantize(Y,n);

 

To save this quantized signal as a .wav with sampling frequency Fs, use the wavwrite command:

 

>wavwrite(Yquant,Fs,’filename.wav’);

 

Note: all the sound files used in this demo have a sampling frequency of 11025 Hz.

 

Below are links to the code for the function p2_Quantize. This function uses the class fixed, which is also provided.

 

p2_Quantize.m

fixed.m


Back


Last updated 2003