Revision as of 07:42, 19 January 2011 by Mcreddy (Talk | contribs)

Media:Normal_Song.wav
Media:Twice_as_fast.wav
Media:Transformation_x(2t).wav
%Megha Reddy
%ECE 301

clear
clc
%Part 1
G_freq = 391.995;
Bflat_freq = 466.164;
C_freq = 523.251;
Dflat_freq = 544.365;

bpm = 112; %number of beats per minute
beats_per_sec = bpm/60; %number of beats per second
rev_bps = 1/beats_per_sec; %calculates the time for each beat

delta = 0.00005;

Q = 0:delta:1*rev_bps; %duration of a quarter note
E = 0:delta:0.5*rev_bps; %duration of an eight note
H = 0:delta:2*rev_bps; %duration of a half note
DQ = 0:delta:1.5*rev_bps; %duration of a dotted quarter note

G_Q = sin(2*pi*G_freq*Q); %calculates a G quarter note
Bflat_Q = sin(2*pi*Bflat_freq*Q); %calculates a B flat quarter note
Cdot = sin(2*pi*C_freq*DQ); %calculates a C dotted quarter note
Dflat_E = sin(2*pi*Dflat_freq*E); %calculates a D flat eighth note
C_H = sin(2*pi*C_freq*H); %calculates a C half note
rest_E = zeros(E/delta,1); %calculates an eighth rest
rest_H = zeros(H/delta,1); % calculates a half rest

%puts the notes in an array to be able to play the song
song = [G_Q,Bflat_Q,Cdot,G_Q,Bflat_Q,Dflat_E,C_H,G_Q,Bflat_Q,Cdot,Bflat_Q,G_Q,rest_E,rest_H];
sound(song,1/delta);

%plays song two times faster
sound(song,2/delta);

%doubles the time interval for each note
newQ = 2*Q;
newE = 2*E;
newH = 2*H;
newDQ = 2*DQ;

G_Q = sin(2*pi*G_freq*newQ);
Bflat_Q = sin(2*pi*Bflat_freq*newQ);
Cdot = sin(2*pi*C_freq*newDQ);
Dflat_E = sin(2*pi*Dflat_freq*newE);
C_H = sin(2*pi*C_freq*newH);
rest_E = zeros(E/delta,1);
rest_H = zeros(H/delta,1);

%plays the song with the new time interval
song = [G_Q,Bflat_Q,Cdot,G_Q,Bflat_Q,Dflat_E,C_H,G_Q,Bflat_Q,Cdot,Bflat_Q,G_Q,rest_E,rest_H];
sound(song,1/delta);

clear
clc

%Part 2
[song,Fs] = wavread('Beatles.wav'); %reads the given file and stores it in an array

song_rev = flipud(song); %flips the array

sound(song_rev,Fs); %plays the reversed song

%The reverse song does contain it message, the words are not clear but it
%says "turn me on dead man"

Alumni Liaison

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

Francisco Blanco-Silva