MATLAB

%Chris Cadwallader
%Homework 1.1

delta = 1/44000;
tempo = 150; %bpm
beat = 60/150; %seconds
half = 2*beat;
eighth = .5*beat;

C = 261.63;
Db = 277.18;
D = 293.66;
E = 329.63;
F = 349.23;
Gb = 369.99; 
G = 392.00; 
A = 440;
B = 466;

%normal
sound(sin(2*pi*A*(0:delta:beat)), 1/delta);
sound(sin(2*pi*B*(0:delta:beat)), 1/delta);
sound(sin(2*pi*Db*(0:delta:beat)), 1/delta);
sound(sin(2*pi*D*(0:delta:beat)), 1/delta);
sound(sin(2*pi*E*(0:delta:beat)), 1/delta);
sound(sin(2*pi*Gb*(0:delta:beat)), 1/delta);
sound(sin(2*pi*Gb*(0:delta:beat)), 1/delta);
sound(sin(2*pi*G*(0:delta:beat)), 1/delta);
sound(sin(2*pi*G*(0:delta:beat)), 1/delta);
sound(sin(2*pi*G*(0:delta:beat)), 1/delta);
sound(sin(2*pi*D*(0:delta:beat)), 1/delta);
sound(sin(2*pi*E*(0:delta:beat)), 1/delta);
sound(sin(2*pi*F*(0:delta:beat)), 1/delta);

pause(2)

%doubletime
sound(sin(2*pi*A*(0:delta:eighth)), 1/delta);
sound(sin(2*pi*B*(0:delta:eighth)), 1/delta);
sound(sin(2*pi*Db*(0:delta:eighth)), 1/delta);
sound(sin(2*pi*D*(0:delta:eighth)), 1/delta);
sound(sin(2*pi*E*(0:delta:eighth)), 1/delta);
sound(sin(2*pi*Gb*(0:delta:eighth)), 1/delta);
sound(sin(2*pi*Gb*(0:delta:eighth)), 1/delta);
sound(sin(2*pi*G*(0:delta:eighth)), 1/delta);
sound(sin(2*pi*G*(0:delta:eighth)), 1/delta);
sound(sin(2*pi*G*(0:delta:eighth)), 1/delta);
sound(sin(2*pi*D*(0:delta:eighth)), 1/delta);
sound(sin(2*pi*E*(0:delta:eighth)), 1/delta);
sound(sin(2*pi*F*(0:delta:eighth)), 1/delta);

pause(2)

%octave up
sound(sin(4*pi*A*(0:delta:beat)), 1/delta);
sound(sin(4*pi*B*(0:delta:beat)), 1/delta);
sound(sin(4*pi*Db*(0:delta:beat)), 1/delta);
sound(sin(4*pi*D*(0:delta:beat)), 1/delta);
sound(sin(4*pi*E*(0:delta:beat)), 1/delta);
sound(sin(4*pi*Gb*(0:delta:beat)), 1/delta);
sound(sin(4*pi*Gb*(0:delta:beat)), 1/delta);
sound(sin(4*pi*G*(0:delta:beat)), 1/delta);
sound(sin(4*pi*G*(0:delta:beat)), 1/delta);
sound(sin(4*pi*G*(0:delta:beat)), 1/delta);
sound(sin(4*pi*D*(0:delta:beat)), 1/delta);
sound(sin(4*pi*E*(0:delta:beat)), 1/delta);
sound(sin(4*pi*F*(0:delta:beat)), 1/delta);

Alumni Liaison

Have a piece of advice for Purdue students? Share it through Rhea!

Alumni Liaison