% Script: playTwoNotes
% Play F and A above Middle C...

close all

Fs = 32768;    % sampling rate
tFinal = 2;
t = 0:(1/Fs):tFinal;
m = 500;       % plot subvector (first m samples)

% The F above Middle C = F3
% Play and plot...
figure
F3  = 349.23;
yF3 = sin(2*pi*F3*t);
plot(t(1:m),yF3(1:m))
axis([0 t(m) -1.2 1.2])
title('F3 = 523.25 Hz','Fontsize',14)
sound(yF3,Fs)
pause(3)

% The A above Middle C, i.e., A4
% Play and Plot...
figure
A4  = 440;
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 = (yF3 + yA4)/2;
plot(t(1:m),y(1:m))
axis([0 t(m) -1.2 1.2])
title('F3 and A4 together','Fontsize',14)
sound(y,Fs)