%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Generate the dial tone for the digit 1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

fs = 44100;    % sampling frequency

freqA =  697;  % the first frequency
freqB = 1209;  % the second frequency

% Create time interval from 0 to 1 second
t = 0 : 1/fs : 1;
	
% Calculate the two waves and add them
waveA = sin(2 * pi * freqA * t);
waveB = sin(2 * pi * freqB * t);
	
waveSum = (waveA + waveB) / 2;
    
% Play it on the speakers 
sound(waveSum, fs);
pause(2)

% Save it to a .WAV file
audiowrite('touch-tone-1.wav',  waveSum, fs);

% Plot the wave
figure;  plot(1:1000, waveSum(1:1000));
xlabel('Sample number (only the first 1000)');
ylabel('Amplitude');
title('The dial tone wave for the digit 1');

% Plot the sampled wave
figure;  plot(1:1000, waveSum(1:1000));
hold on; plot(1:1000, waveSum(1:1000), 'r.');
xlabel('Sample number (only the first 1000)');
ylabel('Amplitude');
title('The sampled dial tone wave for the digit 1');

% Plot waveA
figure;  plot(1:1000, waveA(1:1000));
xlabel('Sample number (only the first 1000)');
ylabel('Amplitude');
title('The first requency at 697 Hz for the digit 1');

% Plot waveB
figure;  plot(1:1000, waveB(1:1000));
xlabel('Sample number (only the first 1000)');
ylabel('Amplitude');
title('The second requency at 1209 Hz for the digit 1');
