(New page: %Homework #1 %ECE 301 - Spring 2011 %Kyle Richmond %Part 1a: Play "Smoke on the Water" at original tempo tempo = 112; %Beats per minute delta = .00005; %Sampling rate %Frequencies of nece...) |
|||
Line 1: | Line 1: | ||
%Homework #1 | %Homework #1 | ||
+ | |||
%ECE 301 - Spring 2011 | %ECE 301 - Spring 2011 | ||
+ | |||
%Kyle Richmond | %Kyle Richmond | ||
+ | |||
%Part 1a: Play "Smoke on the Water" at original tempo | %Part 1a: Play "Smoke on the Water" at original tempo | ||
+ | |||
tempo = 112; %Beats per minute | tempo = 112; %Beats per minute | ||
+ | |||
delta = .00005; %Sampling rate | delta = .00005; %Sampling rate | ||
+ | |||
%Frequencies of necessary notes | %Frequencies of necessary notes | ||
+ | |||
G = (2^(-2/12))*440; %G note frequency | G = (2^(-2/12))*440; %G note frequency | ||
+ | |||
B_f = (2^(1/12))*440; %B flat note frequency | B_f = (2^(1/12))*440; %B flat note frequency | ||
+ | |||
C = (2^(3/12))*440; %C note frequency | C = (2^(3/12))*440; %C note frequency | ||
+ | |||
D_f = (2^(4/12))*440; %D flat note frequency | D_f = (2^(4/12))*440; %D flat note frequency | ||
+ | |||
%Time spans for necessary notes | %Time spans for necessary notes | ||
+ | |||
Q = [0:delta:(60/tempo)]; %Quarter note length | Q = [0:delta:(60/tempo)]; %Quarter note length | ||
+ | |||
DQ = [0:delta:(90/tempo)]; %Dotted quarter note length | DQ = [0:delta:(90/tempo)]; %Dotted quarter note length | ||
+ | |||
E = [0:delta:(30/tempo)]; %Eighth note length | E = [0:delta:(30/tempo)]; %Eighth note length | ||
+ | |||
H = [0:delta:(120/tempo)]; %Half note length | H = [0:delta:(120/tempo)]; %Half note length | ||
+ | |||
%Notes | %Notes | ||
+ | |||
G_Q = sin(2*pi*G*Q); %G quarter note | G_Q = sin(2*pi*G*Q); %G quarter note | ||
+ | |||
B_f_Q = sin(2*pi*B_f*Q); %B flat quarter note | B_f_Q = sin(2*pi*B_f*Q); %B flat quarter note | ||
+ | |||
C_DQ = sin(2*pi*C*DQ); %C dotted quarter note | C_DQ = sin(2*pi*C*DQ); %C dotted quarter note | ||
+ | |||
D_f_E = sin(2*pi*D_f*E); %D flat eighth note | D_f_E = sin(2*pi*D_f*E); %D flat eighth note | ||
+ | |||
C_H = sin(2*pi*C*H); %C half note | C_H = sin(2*pi*C*H); %C half note | ||
+ | |||
%Song | %Song | ||
+ | |||
smoke = [G_Q,B_f_Q,C_DQ,G_Q,B_f_Q,D_f_E,C_H,G_Q,B_f_Q,C_DQ,B_f_Q,G_Q]; | smoke = [G_Q,B_f_Q,C_DQ,G_Q,B_f_Q,D_f_E,C_H,G_Q,B_f_Q,C_DQ,B_f_Q,G_Q]; | ||
+ | |||
sound(smoke, 1/delta); %Play "Smoke on the Water" | sound(smoke, 1/delta); %Play "Smoke on the Water" | ||
+ | |||
%Create sound file | %Create sound file | ||
+ | |||
wavwrite(smoke,1/delta,32,'Kyle_Richmond_DeepPurple_Regular'); | wavwrite(smoke,1/delta,32,'Kyle_Richmond_DeepPurple_Regular'); | ||
+ | |||
%Part 1b: Play "Smoke on the Water" at twice the original tempo | %Part 1b: Play "Smoke on the Water" at twice the original tempo | ||
+ | |||
tempo = 224; %Beats per minute | tempo = 224; %Beats per minute | ||
+ | |||
delta = .00005; %Sampling rate | delta = .00005; %Sampling rate | ||
+ | |||
%Frequencies of necessary notes | %Frequencies of necessary notes | ||
+ | |||
G = (2^(-2/12))*440; %G note frequency | G = (2^(-2/12))*440; %G note frequency | ||
+ | |||
B_f = (2^(1/12))*440; %B flat note frequency | B_f = (2^(1/12))*440; %B flat note frequency | ||
+ | |||
C = (2^(3/12))*440; %C note frequency | C = (2^(3/12))*440; %C note frequency | ||
+ | |||
D_f = (2^(4/12))*440; %D flat note frequency | D_f = (2^(4/12))*440; %D flat note frequency | ||
+ | |||
%Time spans for necessary notes | %Time spans for necessary notes | ||
+ | |||
Q = [0:delta:(60/tempo)]; %Quarter note length | Q = [0:delta:(60/tempo)]; %Quarter note length | ||
+ | |||
DQ = [0:delta:(90/tempo)]; %Dotted quarter note length | DQ = [0:delta:(90/tempo)]; %Dotted quarter note length | ||
+ | |||
E = [0:delta:(30/tempo)]; %Eighth note length | E = [0:delta:(30/tempo)]; %Eighth note length | ||
+ | |||
H = [0:delta:(120/tempo)]; %Half note length | H = [0:delta:(120/tempo)]; %Half note length | ||
+ | |||
%Notes | %Notes | ||
+ | |||
G_Q = sin(2*pi*G*Q); %G quarter note | G_Q = sin(2*pi*G*Q); %G quarter note | ||
+ | |||
B_f_Q = sin(2*pi*B_f*Q); %B flat quarter note | B_f_Q = sin(2*pi*B_f*Q); %B flat quarter note | ||
+ | |||
C_DQ = sin(2*pi*C*DQ); %C dotted quarter note | C_DQ = sin(2*pi*C*DQ); %C dotted quarter note | ||
+ | |||
D_f_E = sin(2*pi*D_f*E); %D flat eighth note | D_f_E = sin(2*pi*D_f*E); %D flat eighth note | ||
+ | |||
C_H = sin(2*pi*C*H); %C half note | C_H = sin(2*pi*C*H); %C half note | ||
+ | |||
%Song | %Song | ||
+ | |||
smoke = [G_Q,B_f_Q,C_DQ,G_Q,B_f_Q,D_f_E,C_H,G_Q,B_f_Q,C_DQ,B_f_Q,G_Q]; | smoke = [G_Q,B_f_Q,C_DQ,G_Q,B_f_Q,D_f_E,C_H,G_Q,B_f_Q,C_DQ,B_f_Q,G_Q]; | ||
+ | |||
sound(smoke, 1/delta); %Play "Smoke on the Water" | sound(smoke, 1/delta); %Play "Smoke on the Water" | ||
+ | |||
%Create sound file | %Create sound file | ||
+ | |||
wavwrite(smoke,1/delta,32,'Kyle_Richmond_DeepPurple_Faster'); | wavwrite(smoke,1/delta,32,'Kyle_Richmond_DeepPurple_Faster'); | ||
+ | |||
%Part 1c: Play "Smoke on the Water" with transformation y(t)=x(2t) | %Part 1c: Play "Smoke on the Water" with transformation y(t)=x(2t) | ||
+ | |||
tempo = 112; %Beats per minute | tempo = 112; %Beats per minute | ||
+ | |||
delta = .00005; %Sampling rate | delta = .00005; %Sampling rate | ||
+ | |||
%Frequencies of necessary notes | %Frequencies of necessary notes | ||
+ | |||
G = (2^(-2/12))*880; %G note frequency | G = (2^(-2/12))*880; %G note frequency | ||
+ | |||
B_f = (2^(1/12))*880; %B flat note frequency | B_f = (2^(1/12))*880; %B flat note frequency | ||
+ | |||
C = (2^(3/12))*880; %C note frequency | C = (2^(3/12))*880; %C note frequency | ||
+ | |||
D_f = (2^(4/12))*880; %D flat note frequency | D_f = (2^(4/12))*880; %D flat note frequency | ||
+ | |||
%Time spans for necessary notes | %Time spans for necessary notes | ||
+ | |||
Q = [0:delta:(60/tempo)]; %Quarter note length | Q = [0:delta:(60/tempo)]; %Quarter note length | ||
+ | |||
DQ = [0:delta:(90/tempo)]; %Dotted quarter note length | DQ = [0:delta:(90/tempo)]; %Dotted quarter note length | ||
+ | |||
E = [0:delta:(30/tempo)]; %Eighth note length | E = [0:delta:(30/tempo)]; %Eighth note length | ||
+ | |||
H = [0:delta:(120/tempo)]; %Half note length | H = [0:delta:(120/tempo)]; %Half note length | ||
+ | |||
%Notes | %Notes | ||
+ | |||
G_Q = sin(2*pi*G*Q); %G quarter note | G_Q = sin(2*pi*G*Q); %G quarter note | ||
+ | |||
B_f_Q = sin(2*pi*B_f*Q); %B flat quarter note | B_f_Q = sin(2*pi*B_f*Q); %B flat quarter note | ||
+ | |||
C_DQ = sin(2*pi*C*DQ); %C dotted quarter note | C_DQ = sin(2*pi*C*DQ); %C dotted quarter note | ||
+ | |||
D_f_E = sin(2*pi*D_f*E); %D flat eighth note | D_f_E = sin(2*pi*D_f*E); %D flat eighth note | ||
+ | |||
C_H = sin(2*pi*C*H); %C half note | C_H = sin(2*pi*C*H); %C half note | ||
+ | |||
%Song | %Song | ||
+ | |||
smoke = [G_Q,B_f_Q,C_DQ,G_Q,B_f_Q,D_f_E,C_H,G_Q,B_f_Q,C_DQ,B_f_Q,G_Q]; | smoke = [G_Q,B_f_Q,C_DQ,G_Q,B_f_Q,D_f_E,C_H,G_Q,B_f_Q,C_DQ,B_f_Q,G_Q]; | ||
+ | |||
sound(smoke, 1/delta); %Play "Smoke on the Water" | sound(smoke, 1/delta); %Play "Smoke on the Water" | ||
+ | |||
%Create sound file | %Create sound file | ||
+ | |||
wavwrite(smoke,1/delta,32,'Kyle_Richmond_DeepPurple_HighPitch'); | wavwrite(smoke,1/delta,32,'Kyle_Richmond_DeepPurple_HighPitch'); | ||
+ | |||
%Part 2: Play a Beatles song in reverse | %Part 2: Play a Beatles song in reverse | ||
+ | |||
%Read the file | %Read the file | ||
+ | |||
[Beatles, fs] = wavread('Beatles.wav'); | [Beatles, fs] = wavread('Beatles.wav'); | ||
+ | |||
%Reverse the file | %Reverse the file | ||
+ | |||
Backwards = flipud(Beatles); | Backwards = flipud(Beatles); | ||
+ | |||
%Play the reversed file | %Play the reversed file | ||
+ | |||
sound(Backwards,fs); | sound(Backwards,fs); | ||
+ | |||
%Create sound file | %Create sound file | ||
+ | |||
wavwrite(Backwards,fs,32,'Kyle_Richmond_BeatlesReversed'); | wavwrite(Backwards,fs,32,'Kyle_Richmond_BeatlesReversed'); | ||
+ | |||
%The original file is the verse "Number nine" repeated several times | %The original file is the verse "Number nine" repeated several times | ||
+ | |||
%However, when the signal is reversed it sounds like they are saying | %However, when the signal is reversed it sounds like they are saying | ||
+ | |||
%"Turn me on dead man" repeatedly | %"Turn me on dead man" repeatedly | ||
+ | |||
[[Media:Kyle_Richmond_DeepPurple_Regular.wav]] | [[Media:Kyle_Richmond_DeepPurple_Regular.wav]] | ||
+ | |||
[[Media:Kyle_Richmond_DeepPurple_Faster.wav]] | [[Media:Kyle_Richmond_DeepPurple_Faster.wav]] | ||
+ | |||
[[Media:Kyle_Richmond_DeepPurple_HighPitch.wav]] | [[Media:Kyle_Richmond_DeepPurple_HighPitch.wav]] | ||
+ | |||
[[Media:Kyle_Richmond_BeatlesReversed.wav]] | [[Media:Kyle_Richmond_BeatlesReversed.wav]] |
Latest revision as of 17:52, 18 January 2011
%Homework #1
%ECE 301 - Spring 2011
%Kyle Richmond
%Part 1a: Play "Smoke on the Water" at original tempo
tempo = 112; %Beats per minute
delta = .00005; %Sampling rate
%Frequencies of necessary notes
G = (2^(-2/12))*440; %G note frequency
B_f = (2^(1/12))*440; %B flat note frequency
C = (2^(3/12))*440; %C note frequency
D_f = (2^(4/12))*440; %D flat note frequency
%Time spans for necessary notes
Q = [0:delta:(60/tempo)]; %Quarter note length
DQ = [0:delta:(90/tempo)]; %Dotted quarter note length
E = [0:delta:(30/tempo)]; %Eighth note length
H = [0:delta:(120/tempo)]; %Half note length
%Notes
G_Q = sin(2*pi*G*Q); %G quarter note
B_f_Q = sin(2*pi*B_f*Q); %B flat quarter note
C_DQ = sin(2*pi*C*DQ); %C dotted quarter note
D_f_E = sin(2*pi*D_f*E); %D flat eighth note
C_H = sin(2*pi*C*H); %C half note
%Song
smoke = [G_Q,B_f_Q,C_DQ,G_Q,B_f_Q,D_f_E,C_H,G_Q,B_f_Q,C_DQ,B_f_Q,G_Q];
sound(smoke, 1/delta); %Play "Smoke on the Water"
%Create sound file
wavwrite(smoke,1/delta,32,'Kyle_Richmond_DeepPurple_Regular');
%Part 1b: Play "Smoke on the Water" at twice the original tempo
tempo = 224; %Beats per minute
delta = .00005; %Sampling rate
%Frequencies of necessary notes
G = (2^(-2/12))*440; %G note frequency
B_f = (2^(1/12))*440; %B flat note frequency
C = (2^(3/12))*440; %C note frequency
D_f = (2^(4/12))*440; %D flat note frequency
%Time spans for necessary notes
Q = [0:delta:(60/tempo)]; %Quarter note length
DQ = [0:delta:(90/tempo)]; %Dotted quarter note length
E = [0:delta:(30/tempo)]; %Eighth note length
H = [0:delta:(120/tempo)]; %Half note length
%Notes
G_Q = sin(2*pi*G*Q); %G quarter note
B_f_Q = sin(2*pi*B_f*Q); %B flat quarter note
C_DQ = sin(2*pi*C*DQ); %C dotted quarter note
D_f_E = sin(2*pi*D_f*E); %D flat eighth note
C_H = sin(2*pi*C*H); %C half note
%Song
smoke = [G_Q,B_f_Q,C_DQ,G_Q,B_f_Q,D_f_E,C_H,G_Q,B_f_Q,C_DQ,B_f_Q,G_Q];
sound(smoke, 1/delta); %Play "Smoke on the Water"
%Create sound file
wavwrite(smoke,1/delta,32,'Kyle_Richmond_DeepPurple_Faster');
%Part 1c: Play "Smoke on the Water" with transformation y(t)=x(2t)
tempo = 112; %Beats per minute
delta = .00005; %Sampling rate
%Frequencies of necessary notes
G = (2^(-2/12))*880; %G note frequency
B_f = (2^(1/12))*880; %B flat note frequency
C = (2^(3/12))*880; %C note frequency
D_f = (2^(4/12))*880; %D flat note frequency
%Time spans for necessary notes
Q = [0:delta:(60/tempo)]; %Quarter note length
DQ = [0:delta:(90/tempo)]; %Dotted quarter note length
E = [0:delta:(30/tempo)]; %Eighth note length
H = [0:delta:(120/tempo)]; %Half note length
%Notes
G_Q = sin(2*pi*G*Q); %G quarter note
B_f_Q = sin(2*pi*B_f*Q); %B flat quarter note
C_DQ = sin(2*pi*C*DQ); %C dotted quarter note
D_f_E = sin(2*pi*D_f*E); %D flat eighth note
C_H = sin(2*pi*C*H); %C half note
%Song
smoke = [G_Q,B_f_Q,C_DQ,G_Q,B_f_Q,D_f_E,C_H,G_Q,B_f_Q,C_DQ,B_f_Q,G_Q];
sound(smoke, 1/delta); %Play "Smoke on the Water"
%Create sound file
wavwrite(smoke,1/delta,32,'Kyle_Richmond_DeepPurple_HighPitch');
%Part 2: Play a Beatles song in reverse
%Read the file
[Beatles, fs] = wavread('Beatles.wav');
%Reverse the file
Backwards = flipud(Beatles);
%Play the reversed file
sound(Backwards,fs);
%Create sound file
wavwrite(Backwards,fs,32,'Kyle_Richmond_BeatlesReversed');
%The original file is the verse "Number nine" repeated several times
%However, when the signal is reversed it sounds like they are saying
%"Turn me on dead man" repeatedly
Media:Kyle_Richmond_DeepPurple_Regular.wav
Media:Kyle_Richmond_DeepPurple_Faster.wav