% Visualization of a time-discrete audio signal
% Example: ex:audiosig

% Read signal into column vector y
[y,Fs,nbits,opts] = wavread('hello.wav');
N = length(y);

% display 16 samples (using the MATLAB stem plotting option)
figure;
h = stem(29000:29015,y(29000:29015),'r'); 
set(h,'linewidth',3);
xlabel('{\bf index i of sample}','fontsize',14);
ylabel('{\bf y_i}','fontsize',14);
title('{\bf sampled audio signal}','fontsize',14);
grid on;
print -depsc2 '../PICTURES/audiosig.eps';

% Plot entire audio signal
figure;
plot(1/Fs*(0:N-1),y,'b-');
xlabel('{\bf time t [s]}','fontsize',14);
ylabel('{\bf normalized sound pressure}','fontsize',14);
title('sound signal "Hello"','fontsize',14);
print -depsc2 '../PICTURES/hellosig.eps';

% Demonstration signal decomposition
x = rand(6,1); Id = eye(6);
for k=1:6
  figure;
  h = stem((0:5),Id(:,k),'m'); 
  set(h,'linewidth',3);
  axis([-0.1 5.1 -0.1 1.1]);
  print('-depsc2',sprintf('../PICTURES/pulse%i.eps',k-1));
end

figure;
h = stem((0:5),x,'r'); 
set(h,'linewidth',3);
axis([-0.1 5.1 -0.1 1.1]);
print -depsc2 '../PICTURES/simplesig.eps';





