(New page: ==Matlab File== <pre> %Bavorndej Chanyasak %ECE 301 hw1.1 %Problem 1a clear clc %According to the scale from Pythagoras, the following notes are G,G,A,B,C %letting C = 264 Notes = [396, 39...)
 
(Matlab File)
Line 1: Line 1:
 +
[[hail_purdue_ECE301Fall2008mboutin.wav]]
 +
 
==Matlab File==
 
==Matlab File==
 
<pre>
 
<pre>

Revision as of 15:30, 4 September 2008

hail_purdue_ECE301Fall2008mboutin.wav

Matlab File

%Bavorndej Chanyasak
%ECE 301 hw1.1
%Problem 1a
clear
clc
%According to the scale from Pythagoras, the following notes are G,G,A,B,C
%letting C = 264
Notes = [396, 396, 440, 495, 528];
%This is the duration of each note in the phrase 'Hail Hail to old Purdue'
time = [1.4, 0.4, 0.9, 0.7, 0.9];
song = ones(1);
for i = 1:5 %5 corresponds to the number of notes played
  delta = 0.00005;
  t = 0:delta:time(i) ;
  y = sin(2*pi*Notes(i)*t);
  sound (y, 1/delta); 
  song = [song, y];
end

%Problem 1b (play twice as fast)
for i = 1:5 
  delta = 0.00005;
  t = 0:delta:time(i)*0.5 ;
  y = sin(2*pi*Notes(i)*t);
  sound (y, 1/delta); 
  song = [song, y];
end

%Problem 1c (scaled to y = x(2t)
for i = 1:5 
  delta = 0.00005;
  t = 0:delta:time(i) ;
  y = sin(2*pi*Notes(i)*2*t);
  sound (y, 1/delta); 
  song = [song, y];
end

wavwrite(song, 44100, 32, 'hail_purdue.wav')

%when the time is decreased, the song is faster, and when the frequency
%increases, the tune of the song is higher

Alumni Liaison

ECE462 Survivor

Seraj Dosenbach