MATLAB

%Justin Kietzman
%jkkietzm@purdue.edu
%ECE301
%Fur Elise
%Source of Sheet Music:
%http://www.virtualsheetmusic.com/LookInside/EliseFl.html
%This Program is a memory hog.  I apologize, my coding is rusty.

%Clear the workspace
clear;
clc;

%Define the Notes
%Looked up actual frequencies on
%http://www.phy.mtu.edu/~suits/notefreqs.html

C = 261.63;
D = 293.66;
E = 329.63;
F = 349.23;
G = 392.00;
A = 440;
B = 493.88;
CC = 523.25;
DD = 587.33;
EE = 659.26;

%Define any Sharps or Flats
EEb = 622.25; %1/2 step between D and E
GS  = 415.30; %1/2 step between G and A

%Define Sampling Rate
delta = 1/20000;


%HW 1_1
%Define Durations
Eg = 0:delta:.5;
S = 0:delta:.25;

%Define Notes
EES = sin(2*pi*EE*S);
EEbS = sin(2*pi*EEb*S);
BS = sin(2*pi*B*S);
CS = sin(2*pi*C*S);
ES = sin(2*pi*E*S);
AS = sin(2*pi*A*S);
GSS = sin(2*pi*GS*S);
CCS = sin(2*pi*CC*S);
DDS = sin(2*pi*DD*S);
RS = sin(2*pi*0*S);

AEg = sin(2*pi*A*Eg);
BEg = sin(2*pi*B*Eg);


%NOTE = [EE EEb EE EEb EE B DD CC A C E A B E GS B CC 0 E EE EEb EE EEb ...
%        EE B DD CC A C E A B E CC B A EE EEb EE EEb EE B DD CC A C E ...
%        A B E GS B CC 0 E EE EEb EE EEb EE B DD CC A C E A B E CC B A];

%TIME = [S S S S S S S S Eg S S S Eg S S S S S S S S S S S S S S Eg S ...
%        S S Eg S S S Eg S S S S S S S S Eg S S S Eg S S S S S S S S S ...
%        S S S S S Eg S S S Eg S S S Eg]; 

FurElise = [EES EEbS EES EEbS EES BS DDS CCS AEg CS ES AS BEg ES GSS ...
            BS CCS RS ES EES EEbS EES EEbS EES BS DDS CCS AEg CS ES  ...
            AS BEg ES CCS BS AEg];
            %EES EEbS EES EEbS EES BS DDS CCS AEg ...
            %CS ES AS BEg ES GSS BS CCS RS ES EES EEbS EES EEbS EES BS ...
            %DDS CCS AEg CS ES AS BEg ES CCS BS AEg];
fprintf('\nUnaltered\n')
sound(FurElise, 1/delta);
wavwrite(FurElise, 1/delta, 32, 'hw1_1FurElise.wav'); 
pause(10);
%HW 1_2
%Just half the durations of t to speed the song up by 2x.
%ex. sin(2*pi*440*t/2) where t can some value of time specified earlier

%Define Durations sped up
Eg = 0:delta:.5/2;
S = 0:delta:.25/2;

%Define Notes for sped up
EES = sin(2*pi*EE*S);
EEbS = sin(2*pi*EEb*S);
BS = sin(2*pi*B*S);
CS = sin(2*pi*C*S);
ES = sin(2*pi*E*S);
AS = sin(2*pi*A*S);
GSS = sin(2*pi*GS*S);
CCS = sin(2*pi*CC*S);
DDS = sin(2*pi*DD*S);
RS = sin(2*pi*0*S);

AEg = sin(2*pi*A*Eg);
BEg = sin(2*pi*B*Eg);

fprintf('2x Speed\n')
FurEliseSpeed = [EES EEbS EES EEbS EES BS DDS CCS AEg CS ES AS BEg ES ...
            GSS BS CCS RS ES EES EEbS EES EEbS EES BS DDS CCS AEg CS ES ...
            AS BEg ES CCS BS AEg];
            %EES EEbS EES EEbS EES BS DDS CCS AEg ...
            %CS ES AS BEg ES GSS BS CCS RS ES EES EEbS EES EEbS EES BS ...
            %DDS CCS AEg CS ES AS BEg ES CCS BS AEg];
sound(FurEliseSpeed, 1/delta);
wavwrite(FurEliseSpeed, 1/delta, 32, 'hw1_2FurEliseSpeed.wav');

pause(5);
%HW 1_3
%Transform by x(2t).  Replace t in all functions with 2*t

%Define Durations
Eg = 0:delta:.5;
S = 0:delta:.25;

%Define Notes
EES = sin(2*pi*EE*S*2);
EEbS = sin(2*pi*EEb*S*2);
BS = sin(2*pi*B*S*2);
CS = sin(2*pi*C*S*2);
ES = sin(2*pi*E*S*2);
AS = sin(2*pi*A*S*2);
GSS = sin(2*pi*GS*S*2);
CCS = sin(2*pi*CC*S*2);
DDS = sin(2*pi*DD*S*2);
RS = sin(2*pi*0*S*2);

AEg = sin(2*pi*A*Eg*2);
BEg = sin(2*pi*B*Eg*2);

fprintf('2x Pitch\n')
FurEliseXform = [EES EEbS EES EEbS EES BS DDS CCS AEg CS ES AS BEg ES ...
            GSS BS CCS RS ES EES EEbS EES EEbS EES BS DDS CCS AEg CS ES ...
            AS BEg ES CCS BS AEg];
            %EES EEbS EES EEbS EES BS DDS CCS AEg ...
            %CS ES AS BEg ES GSS BS CCS RS ES EES EEbS EES EEbS EES BS ...
            %DDS CCS AEg CS ES AS BEg ES CCS BS AEg];
sound(FurEliseXform, 1/delta);
wavwrite(FurEliseXform, 1/delta, 32, 'hw1_3FurEliseXform.wav');

Media:hw1_1FurElise_ECE301Fall2008mboutin.wav Media:hw1_2FurEliseSpeed_ECE301Fall2008mboutin.wav Media:hw1_3FurEliseXform_ECE301Fall2008mboutin.wav

Alumni Liaison

Sees the importance of signal filtering in medical imaging

Dhruv Lamba, BSEE2010