Revision as of 15:50, 4 September 2008 by Cztan (Talk)

Sound File

MATLAB Code

% HW 1.1 - Playing Hail Purdue

% Caleb Tan

% Defining notes according to their frequencies

% Source: http://www.phy.mtu.edu/~suits/notefreqs.html

Eb4 = 311.13;

F4 = 349.23;

G4 = 392.00;

Ab4 = 415.30;

Bb4 = 466.16;

A4 = 440.00;

C5 = 523.25;

Db5 = 554.37;

B4 = 493.88;

Eb5 = 622.25;


% Defining vector for song score

Score = [Eb4 F4 G4 Ab4 G4 Ab4 G4 Ab4 G4 Ab4 Bb4 Ab4 Eb4 F4 G4...

        G4 Ab4 A4 Bb4 A4 Bb4 A4 Bb4 A4 Bb4 C5 Bb4 Eb4 Db5 C5...
        Eb4 F4 G4 Ab4 G4 Ab4 G4 Ab4 G4 Ab4 Eb5 C5 Bb4 Ab4 Db5 Ab4...
        Bb4 Bb4 B4 B4 C5 Db5 Eb5 C5 Bb4 G4 C5 Bb4 Ab4 Bb4...
        Eb4 F4 G4 Ab4 Bb4 C5 C5 Db5 Db5 Db5 Ab4 Bb4 B4 C5...
        C5 C5 Bb4 Ab4 Bb4 C5 C5 Bb4 F4 G4 Ab4 G4 F4 Bb4 Bb4 Eb5...
        Eb4 Eb4 F4 G4 Ab4 Bb4 C5 C5 C5 Db5 Db5 Ab4 Bb4 C5...
        F4 G4 Ab4 F4 Eb4 Ab4 C5 Eb4 F4 C5 Bb4 Ab4];

% sampling frequency

delta = 0.00005;

% Tempo = 140 beats per minute, therefore a quarter note is 60/140 seconds long

% Defining note lengths

Q = 60/140;  % Quarter note

W = 4*Q;  % Whole note

H = 2*Q;  % Half note

E = Q/2;  % Eighth note

S = Q/4;  % Sixteenth note

DQ = Q + E;  % Dotted Quarter

DH = H + Q;  % Dotted Half

% Time vector for the respective notes

Time = [Q Q Q Q Q Q E E E E Q Q Q Q DH ...

       Q Q Q Q Q Q E E E E Q Q Q Q DH ... 
       Q Q Q Q Q Q E E E E Q Q Q Q DH ...
       E E DQ E DQ E Q E E E E E E H H W ... 
       H Q Q DQ E Q Q Q E E Q E E DH ...
       H Q Q DQ E Q Q Q E E Q E E W ... 
       DQ E Q Q DQ E Q E E Q Q Q Q W ... 
       DQ E Q Q Q Q Q Q DQ E DQ E 1.5*W];

% 1.1(a)

for c = 1:length(Score)

   t = 0:delta:Time(c);
   y = sin(2*pi*Score(c)*t);
   sound(y,1/delta);

end


% 1.1(b) - Double the playing rate


for c = 1:length(Score)

   t = 0:delta:(Time(c))/2;
   y = sin(2*pi*Score(c)*t);
   sound(y,1/delta);

end


% 1.1(c) - y(t) = x(2t)


for c = 1:length(Score)

   t = 0:delta:Time(c);
   y = sin(2*pi*Score(c)*2*t);
   sound(y,1/delta);

end

Alumni Liaison

Ph.D. on Applied Mathematics in Aug 2007. Involved on applications of image super-resolution to electron microscopy

Francisco Blanco-Silva