% Script: playPhoneButtons
% Play and plot each of the twelve button tones
  
% Sampling rate. This many numbers/sec in the digital signal:
  Fs = 32768;
  
% Duration of the tone is .25 sec. So these are the sample times...
  t = 0:(1/Fs):.25;
  
% The touchpad frequencies for the rows...
  fR = [ 697  770  852  941];
  
% The touchpad frequencies for the columns...
  fC = [ 1209  1336  1477];
  
  Buttons = {'1', '2', '3'; '4', '5', '6'; '7', '8', '9'; '*', '0', '#'};
  
  close all
  for i = 1:4
      for j = 1:3
        % Select the two frequencies and add...
         yR  = sin(2*pi*fR(i)*t);
         yC  = sin(2*pi*fC(j)*t);
         y  = (yR + yC)/2;
        % Display a representative part the sinusoid...
         m = 300;
         plot(t(1:m),y(1:m),t(1:m),zeros(1,m),'-r') 
         axis([0 t(m) -1.2 1.2]) 
         shg 
         title(sprintf('Button = %s    Freq = (%4d,%4d)',Buttons{i,j},...
                                              fR(i),fC(j)),'Fontsize',14)
        % Play the tone...
         sound(y,Fs); 
         pause(1)
      end
  end
        
         
        