Line 1: Line 1:
 +
=[[Homework_1_ECE301Fall2008mboutin|HW1]], [[ECE301]], Prof. [[user:mboutin|Boutin]]=
 +
In this homework assignment, we were asked to write a Matlab code to play the "Hail Purdue" song with different speeds and pitch. I thought in class that we were supposed to do a song "such as" Hail Purdue, but it seems like I'm the only one who didn't do Hail Purdue... I hope this is OK.
 +
 +
This is the first part of 'Autumn Leaves':
 +
 
== Audio Files ==
 
== Audio Files ==
 
*[[Media:Browdues_301Song_ECE301Fall2008mboutin.wav | Browdues_301Song]]
 
*[[Media:Browdues_301Song_ECE301Fall2008mboutin.wav | Browdues_301Song]]
 
*[[Media:Browdues_301Melody_2xFast_ECE301Fall2008mboutin.wav | Browdues_301Melody_2xFast]]
 
*[[Media:Browdues_301Melody_2xFast_ECE301Fall2008mboutin.wav | Browdues_301Melody_2xFast]]
 
*[[Media:Browdues_301Melody_2tTRANSFORM_ECE301Fall2008mboutin.wav | Browdues_301Melody_2tTRANSFORM]]
 
*[[Media:Browdues_301Melody_2tTRANSFORM_ECE301Fall2008mboutin.wav | Browdues_301Melody_2tTRANSFORM]]
 
 
 
I thought in class that we were supposed to do a song "such as" Hail Purdue, but it seems like I'm the only one who didn't do Hail Purdue... I hope this is OK.
 
 
This is the first part of 'Autumn Leaves'
 
  
 
== M-File ==
 
== M-File ==

Latest revision as of 08:35, 27 August 2010

HW1, ECE301, Prof. Boutin

In this homework assignment, we were asked to write a Matlab code to play the "Hail Purdue" song with different speeds and pitch. I thought in class that we were supposed to do a song "such as" Hail Purdue, but it seems like I'm the only one who didn't do Hail Purdue... I hope this is OK.

This is the first part of 'Autumn Leaves':

Audio Files

M-File

% Nicholas Browdues
% Ece 301 HW1--Song
% 9/5/08


% The notes 
A= 220; B= 220*2^(2/12); C= 220*2^(3/12); Cs= 220*2^(4/12);
D= 220*2^(5/12); Ds= 220*2^(5/12); E= 220*2^(7/12); Fs= 220*2^(9/12);
G= 220*2^(10/12);

A1= 440; B1=440*2^(2/12); C1= 440*2^(3/12); Cs1= 440*2^(4/12);
D1= 440*2^(5/12); Ds1= 440*2^(5/12); E1= 440*2^(7/12); Fs1= 440*2^(9/12);
G1= 440*2^(10/12);

% The sampling Rate 
delta_t=1/20000;

% I define note durations (tempo 108 bpm). 
Eth=30/108;
Q=2*Eth;
DQ=3*Eth;

H=4*Eth;
DH= H+Q;
W=8*Eth;

% Here goes the Melody

Melody  =[E,Fs,G,  C1, D,E,Fs ,B1,B1,  C,D,E, A1,  B,Cs,Ds, G];
Mel_Rthm=[Q,Q ,Q, W+Q,Q,Q, Q  ,H, DH,  Q,Q,Q, W+Q, Q, Q, Q,  W*2];

% Here goes the Harmony

x=       [0;0;0;A; D ; G  ; C; Fs; B ; E  ]; 
y=       [0;0;0;C; Fs; B1 ; E; A1; Ds; G  ]; 
z=       [0;0;0;E; C1; Fs1; G; C1; Fs; B1 ];
Har_Rthm=[Q,Q,Q,W,  W,   W, W,  W,  W, W*2];

% Here I create some vectors that will ultimately vibrate the speaker box

AutumnLeaves_Harm = [];
for index = 1:length(x)
    t=0:delta_t:Har_Rthm(index);
    H=(1/3)*(sin(2*pi*x(index)*t)+sin(2*pi*y(index)*t)+sin(2*pi*z(index)*t));
    AutumnLeaves_Harm= [AutumnLeaves_Harm; H(:)];
end

Autumnhead = [];
for index = 1:length(Melody)
    t=0:delta_t:Mel_Rthm(index);
    N=sin(2*pi*Melody(index)*t);
    Autumnhead= [Autumnhead; N(:)];
end

% I resize the harmony and melody vectors (so they are equal and I can
% add them) then create a wav file.

AutumnHead=imresize(Autumnhead, [length(AutumnLeaves_Harm) 1]);
AutumnLeaves=.5*(AutumnHead+AutumnLeaves_Harm);
wavwrite(AutumnLeaves, 20000, 'Browdues_301Song.wav')

% The first 16 bars of Autumn Leaves 

sound(AutumnLeaves,1/delta_t)

pause(20)   

% Here's JUST the melody (no harmony) twice as fast
sound(Autumnhead,2/delta_t)
wavwrite(Autumnhead, 40000, 'Browdues_301Melody_2xFast.wav')
pause(10)



% Here's the transformation y(t)=x(2*t) on JUST the melody
Autumnhead2t=[];
for index = 1:length(Melody)
    t=0:delta_t:.5*Mel_Rthm(index);
    N=sin(2*pi*Melody(index)*2*t);
    Autumnhead2t= [Autumnhead2t; N(:)];
end

sound(Autumnhead2t,1/delta_t)

wavwrite(Autumnhead2t, 20000, 'Browdues_301Melody_2tTRANSFORM.wav')

Alumni Liaison

Questions/answers with a recent ECE grad

Ryne Rayburn