% quant_demo.m % Demonstration of uniformly quantizing speech with various numbers of levels. % % ELEC 470, Spring 1998, R. Kozick % Load speech signal % Choose number of bits R to set L = 2^R quantization levels R = 7; L = 2^R; s = auread('/home/pleiades/ACM/snd/clint_eastwood.au'); % Normalize amplitudes to range [+0.5, -0.5] s = s/max(s)*0.5; % Perform the quantization sq = round(s*L)/L; % Play the original sound(s) % Play the quantized version sound(sq) fprintf('Quantized with R = %d bits = %d levels\n', R, L); fprintf('Signal-to-quantization-noise ratio = %f dB\n', 1.8 + 6*R);