% Script: playTwoNotes
% Play Middle C and the A above it...

close all

Fs = 32768; % sampling rate
tFinal = 2;
t = 0:(1/Fs):tFinal;
m = 500; % no. of samples to plot

% Middle C = C3
% Play and plot...
figure
C3 = 261.62;
yC3 = sin(2*pi*C3*t);
plot(t(1:m),yC3(1:m))
axis([0 t(m) -1.2 1.2])
title('Middle C = C3 = 261.62 Hz','Fontsize',14)
sound(yC3,Fs)
pause(3)

% The A above Middle C, i.e., A4
% Play and Plot...
figure
A4 = 440.00;
yA4 = sin(2*pi*A4*t);
plot(t(1:m),yA4(1:m))
axis([0 t(m) -1.2 1.2])
title('A4 = 440.00 Hz','Fontsize',14)
sound(yA4,Fs)
pause

% Play the two notes together
figure
y = (yC3 + yA4)/2;
plot(t(1:m),y(1:m))
axis([0 t(m) -1.2 1.2])
title('C3 and A4 together','Fontsize',14)
sound(yA4,Fs)