(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
Christian Rivera
 +
ECE 301
 +
HW 1
 +
 
%HW 1 Problem 1a
 
%HW 1 Problem 1a
  
Line 163: Line 167:
  
  
% The reverse song doesn't sound like anything to me. After a quick google
+
% The reversed song doesn't sound like anything to me. After a quick google
 
search its suppose to say "turn me on dead man" and then can I kind of
 
search its suppose to say "turn me on dead man" and then can I kind of
hear it.
+
hear it, but sounds more like "bring me on deadman".

Latest revision as of 17:06, 18 January 2011

Christian Rivera ECE 301 HW 1

%HW 1 Problem 1a

clear all

clc


f_A = 440; % Frequency of A4

tempo = 112/60; % Tempo of the song

delta = 5e-5; % Spacing between data

fs = 1/delta; % Frequency at which the song will be played


G = 2^(-2/12)*f_A; % Calculates the frequency of G

C = 2^(3/12)*f_A; % Calculates the frequency of C

Bflat = 2^(1/12)*f_A; % Calculates the frequency of B flat

Dflat = 2^(4/12)*f_A; % Calculates the frequency of D flat


H = 0:delta:(2/tempo); % Creates a matrix for the length of a half note

Q = 0:delta:(1/tempo); % Creates a matrix for the length of a quater note

E = 0:delta:((1/2)/(tempo)); % Creates a matrix for the length of a eigth note

DQ = 0:delta:((3/2)/(tempo)); % Creates a matrix for the length of a dotted quater note


% Creates Matrix for the song based on the note and the time it is held

z = [sin(2*pi*G*Q), sin(2*pi*Bflat*Q), sin(2*pi*C*DQ), sin(2*pi*G*Q), sin(2*pi*Bflat*Q), sin(2*pi*Dflat*E), sin(2*pi*C*H), sin(2*pi*G*Q), sin(2*pi*Bflat*Q), sin(2*pi*C*DQ), sin(2*pi*Bflat*Q), sin(2*pi*G*Q)];


sound(z, fs) % Plays the song

wavwrite(z, fs, 'Question1A.wav'); %Writes song into wav file


Media:Question1A.wav


%HW 1 Problem 1b

clear all

clc


f_A = 440; % Frequency of A4

tempo = 112/60; % Tempo of the song

delta = 5e-5;  % Spacing between data

fs = 1/delta; % Frequency at which the song will be played


G = 2^(-2/12)*f_A; % Calculates the frequency of G

C = 2^(3/12)*f_A; % Calculates the frequency of C

Bflat = 2^(1/12)*f_A; % Calculates the frequency of B flat

Dflat = 2^(4/12)*f_A; % Calculates the frequency of D flat


H = 0:delta:(2/tempo); % Creates a matrix for the length of a half note

Q = 0:delta:(1/tempo); % Creates a matrix for the length of a quater note

E = 0:delta:((1/2)/(tempo)); % Creates a matrix for the length of a eigth note

DQ = 0:delta:((3/2)/(tempo)); % Creates a matrix for the length of a dotted quater note


% Creates Matrix for the song based on the note and the time

z = [sin(2*pi*G*Q), sin(2*pi*Bflat*Q), sin(2*pi*C*DQ), sin(2*pi*G*Q), sin(2*pi*Bflat*Q), sin(2*pi*Dflat*E), sin(2*pi*C*H), sin(2*pi*G*Q), sin(2*pi*Bflat*Q), sin(2*pi*C*DQ), sin(2*pi*Bflat*Q), sin(2*pi*G*Q)];


sound(z, 2*(fs)) % Plays the song the two times faster by multiplying the frequency by 2

wavwrite(z ,2*(fs) ,'Question1B.wav'); %Writes song into wav file


Media:Question1B.wav


%HW 1 Problem 1c

clear all

clc


f_A = 440; % Frequency of A4

tempo = 112/60; % Tempo of the song

delta = 5e-5;  % Spacing between data

fs = 1/delta; % Frequency at which the song will be played


f_A = 2*f_A; % Rescales the song according to the transformation function y(t) = x(2t)

G = 2^(-2/12)*f_A; % Calculates the frequency of G

C = 2^(3/12)*f_A; % Calculates the frequency of C

Bflat = 2^(1/12)*f_A; % Calculates the frequency of B flat

Dflat = 2^(4/12)*f_A; % Calculates the frequency of D flat


H = 0:delta:(2/tempo); % Creates a matrix for the length of a half note

Q = 0:delta:(1/tempo); % Creates a matrix for the length of a quater note

E = 0:delta:((1/2)/(tempo)); % Creates a matrix for the length of a eigth note

DQ = 0:delta:((3/2)/(tempo)); % Creates a matrix for the length of a dotted quater note


% Creates Matrix for the song based on the note and the time

z = [sin(2*pi*G*Q), sin(2*pi*Bflat*Q), sin(2*pi*C*DQ), sin(2*pi*G*Q), sin(2*pi*Bflat*Q), sin(2*pi*Dflat*E), sin(2*pi*C*H), sin(2*pi*G*Q), sin(2*pi*Bflat*Q), sin(2*pi*C*DQ), sin(2*pi*Bflat*Q), sin(2*pi*G*Q)];


sound(z, fs) % Plays the rescaled song

wavwrite(z, fs, 'Question1C.wav'); %Writes song into wav file


Media:Question1C.wav


%HW 1 Problem 2

clear all

clc


[x,f] = wavread('Beatles.wav'); %Reads Beatles wav file and places it a matrix x for the data and variable f for the frequency

y = flipud(x); %System which flips the data for the song allowing it to be reveresed


wavplay(y,f) % Plays the reversed song

wavwrite(y, f, 'Question2.wav'); %Writes song into wav


Media:Question2.wav


% The reversed song doesn't sound like anything to me. After a quick google search its suppose to say "turn me on dead man" and then can I kind of hear it, but sounds more like "bring me on deadman".

Alumni Liaison

Ph.D. 2007, working on developing cool imaging technologies for digital cameras, camera phones, and video surveillance cameras.

Buyue Zhang