Revision as of 07:54, 19 January 2011 by Bepp (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

clear

clc

%Global Variables

Gfreq = 2^(-2/12)*440; %Frequency of a G

Bbfreq = 2^(1/12)*440; %Frequency of a B flat

Cfreq = 2^(3/12)*440; %Frequency of a C

Dbfreq = 2^(4/12)*440; %Frequency of a D flat


delta = 1/8192; %Sampling Frequency


bpm = 112; %Beat per minute

bps = bpm/60; %Beats per second


Qnote = 1/bps; %Length of a quater note in seconds


Qlength = 0:delta:Qnote; %Array for a quater note

Elength = 0:delta:Qnote/2; %Array for an eighth note

DQlength = 0:delta:Qnote*1.5; %Array for a dotted quater note

Hlength = 0:delta:Qnote*2; %Array for a half note


%Song

GQnote = sin(2*pi*Gfreq*Qlength); %G with a quater note length

BbQnote = sin(2*pi*Bbfreq*Qlength); %G with a quater note length

CDQnote = sin(2*pi*Cfreq*DQlength); %G with a quater note length

DbEnote = sin(2*pi*Dbfreq*Elength); %G with a quater note length

CHnote = sin(2*pi*Cfreq*Hlength); %G with a quater note length

Erest = 0*Elength; %G with a quater note length

Hrest = 0*Hlength; %G with a quater note length


SotW = [GQnote,BbQnote,CDQnote,GQnote,BbQnote,DbEnote,CHnote,GQnote,BbQnote,CDQnote,BbQnote,GQnote,Erest,Hrest];


%Song

sound(SotW,1/delta) %Regular speed

wavwrite(SotW,1/delta,'Smoke Regular'); %Regular speed


Qnote = 1/(2*bps); %Length of a quater note in seconds


Qlength = 0:delta:Qnote; %Array for a quater note

Elength = 0:delta:Qnote/2; %Array for an eighth note

DQlength = 0:delta:Qnote*1.5; %Array for a dotted quater note

Hlength = 0:delta:Qnote*2; %Array for a half note

%Song

GQnote = sin(2*pi*Gfreq*Qlength); %G with a quater note length

BbQnote = sin(2*pi*Bbfreq*Qlength); %G with a quater note length

CDQnote = sin(2*pi*Cfreq*DQlength); %G with a quater note length

DbEnote = sin(2*pi*Dbfreq*Elength); %G with a quater note length

CHnote = sin(2*pi*Cfreq*Hlength); %G with a quater note length

Erest = 0*Elength; %G with a quater note length

Hrest = 0*Hlength; %G with a quater note length


SotW = [GQnote,BbQnote,CDQnote,GQnote,BbQnote,DbEnote,CHnote,GQnote,BbQnote,CDQnote,BbQnote,GQnote,Erest,Hrest];


%Song

sound(SotW,1/delta) %Twice the Speed

wavwrite(SotW,1/delta,'Smoke Twice Speed'); %Twice the Speed


Qnote = 2/bps; %Length of a quater note in seconds

Qlength = 0:delta:Qnote; %Array for a quater note

Elength = 0:delta:Qnote/2; %Array for an eighth note

DQlength = 0:delta:Qnote*1.5; %Array for a dotted quater note

Hlength = 0:delta:Qnote*2; %Array for a half note


%Song

GQnote = sin(2*pi*Gfreq*Qlength); %G with a quater note length

BbQnote = sin(2*pi*Bbfreq*Qlength); %G with a quater note length

CDQnote = sin(2*pi*Cfreq*DQlength); %G with a quater note length

DbEnote = sin(2*pi*Dbfreq*Elength); %G with a quater note length

CHnote = sin(2*pi*Cfreq*Hlength); %G with a quater note length

Erest = 0*Elength; %G with a quater note length

Hrest = 0*Hlength; %G with a quater note length


SotW = [GQnote,BbQnote,CDQnote,GQnote,BbQnote,DbEnote,CHnote,GQnote,BbQnote,CDQnote,BbQnote,GQnote,Erest,Hrest];


%Song

sound(SotW,1/delta) %Twice the Length

wavwrite(SotW,1/delta,'Smoke Half Speed'); %Twice the Length


[Beatles,Fs] = wavread('Beatles.wav'); %Creating an array of the Beatles Song

Bealtesrev = flipud(Beatles); %Reversing the Song


sound(Beatlesrev,Fs)

wavwrite(Beatlesrev,Fs,'Bealtes song backwards');


%Fowards is Number Nine and reverse is Turn me on dead man

Alumni Liaison

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

Buyue Zhang