Star Wars Theme Song - By Ryan Patout
The following code is a MatLab program that plays the Star Wars Main Theme Song
ECE 301 Professor Boutin, Fall 2018
Bonus Point Project: Star Wars Main Theme Song
Ryan Patout
clear
clc
%% - Initialing Timing Parameters
delta=1/8196; %sampling rate of sine wave
t1=0:delta:.5; %note length t1
t2=0:delta:.7; %note length t2
t3=0:delta:.9; %note length t3
t4=0:delta:1.5; %note length t4
t5=0:delta:3; %note length t5
%% - Initializing Note Frequencies
A3_t1=sin(2*pi*t1*220.000); %A3 played for tX seconds
A3_t2=sin(2*pi*t2*220.000); % ||
A3_t4=sin(2*pi*t4*220.000); % ||
A_3_t1=sin(2*pi*t1*233.082); %A3 sharp palyed for tX seconds
B3_t1=sin(2*pi*t1*246.942); %B3 played for tX seconds
B3_t2=sin(2*pi*t2*246.942); % ||
C4_t1=sin(2*pi*t1*261.626); %C4 played for tX seconds
C4_t2=sin(2*pi*t2*261.626); % ||
D3_t1=sin(2*pi*t1*146.832); %D3 played for tX seconds
D3_t2=sin(2*pi*t2*146.832); % ||
D4_t1=sin(2*pi*t1*293.665); %D4 played for tX seconds
D4_t2=sin(2*pi*t2*293.665); % ||
D4_t3=sin(2*pi*t3*293.665); % ||
D4_t4=sin(2*pi*t4*293.665); % ||
D4_t5=sin(2*pi*t5*293.665); % ||
D_4_t2=sin(2*pi*t2*311.1270); %D4 sharp played for tX seconds
E3_t1=sin(2*pi*t1*164.814); %E3 played for tX seconds
E3_t2=sin(2*pi*t2*164.814); % ||
E3_t3=sin(2*pi*t3*164.814); % ||
F4_t1=sin(2*pi*t1*349.2282); %F4 played for tX seconds
F_3_t1=sin(2*pi*t1*184.997); %F3 sharp played for tX seconds
F_3_t2=sin(2*pi*t2*184.997); % ||
G3_t1=sin(2*pi*t1*195.998); %G3 played for tX seconds
G3_t2=sin(2*pi*t2*195.998); % ||
G3_t4=sin(2*pi*t4*195.998); % ||
G4_t2=sin(2*pi*t2*391.995); %G4 played for tX seconds
G4_t4=sin(2*pi*t4*391.995); % ||
%% - Notes (In Order)
notes = [D3_t1, D3_t1, D3_t1, G3_t4, D4_t4, C4_t1, B3_t1, A3_t1, G4_t4, D4_t2, C4_t1, B3_t1, A3_t1, G4_t4, D4_t2, C4_t1, B3_t1, C4_t1, A3_t4, D3_t2, D3_t1, G3_t4, D4_t4, C4_t1, B3_t1, A3_t1, G4_t4, D4_t2, C4_t1, B3_t1, A3_t1, G4_t4, D4_t2, C4_t1, B3_t1, C4_t1, A3_t4, D3_t2, D3_t1, E3_t3, E3_t2, C4_t2, B3_t2, A3_t2, G3_t2, G3_t1, A3_t1, B3_t1, A3_t2, E3_t1, F_3_t2, D3_t2, D3_t1, E3_t3, E3_t2, C4_t2, B3_t2, A3_t2, G3_t2, D4_t2, A3_t1, A3_t4, D3_t2, D3_t1, E3_t3, E3_t2, C4_t2, B3_t2, A3_t2, G3_t2, G3_t1, A3_t1, B3_t1, A3_t2, E3_t2, F_3_t1, D4_t3, D4_t1, G4_t2, F4_t1, D_4_t2, D4_t1, C4_t2, A_3_t1, A3_t2, G3_t1, D4_t5];
%% - Song
sound(notes,1/.00005); %Play notes vector
%% - References
%Frequencies of notes on the piano
% http://www.sengpielaudio.com/calculator-notenames.htm