% MATLAB script: Compression of audio signal by orhtogonal projection (low pass filtering)
% Read signal into column vector v. Also read sample rate, number of bits
% per sample
[v,Fs,nbits] = wavread('hello.wav'); 
v = reshape(v,length(v),1);
% Next, play sound through the computer's audio output device
soundsc(v,Fs,nbits);
% Now do low pass filtering retaining only half of the information content
vsmall = encode(v);
% The coefficients stored in vsmall are transmitted over a channel
% Now recover a signal in the original format
vnew = decode(vsmall);
% Play the compressed signal
soundsc(vnew,Fs,nbits);