Revision as of 13:28, 17 January 2011 by Khaver (Talk | contribs)

Smoke on the Water MATLAB Code

%% Beat Length
deltat = 0.00005;
beatlength = 60/112;

%% Note Lengths
Qnote = 0:deltat:beatlength;
Enote = 0:deltat:(beatlength/2);
Hnote = 0:deltat:(beatlength*2);
DQnote = 0:deltat:(beatlength*1.50);

%% Frequencies
fA = 440;
fG = (2^((-2)/12)) * fA;
fBf = (2^(1/12)) * fA;
fC = (2^(3/12)) * fA;
fDf = (2^(4/12)) * fA;

%% Notes
qG = sin(2*pi*fG*Qnote);
hG = sin(2*pi*fG*Hnote);

qBf = sin(2*pi*fBf*Qnote);

dqC = sin(2*pi*fC*DQnote);
hC = sin(2*pi*fC*Hnote);

eDf = sin(2*pi*fDf*Enote);

%% Play Tunes
tune = [qG qBf dqC qG qBf eDf hC qG qBf dqC qBf qG];

% Regular Speed
sound(tune, 1/deltat)

% 2X Speed
% half beatlength
beatlength = beatlength/2;
Qnote = 0:deltat:beatlength;
Enote = 0:deltat:(beatlength/2);
Hnote = 0:deltat:(beatlength*2);
DQnote = 0:deltat:(beatlength*1.50);
qG = sin(2*pi*fG*Qnote);
hG = sin(2*pi*fG*Hnote);
qBf = sin(2*pi*fBf*Qnote);
dqC = sin(2*pi*fC*DQnote);
hC = sin(2*pi*fC*Hnote);
eDf = sin(2*pi*fDf*Enote);

tune = [qG qBf dqC qG qBf eDf hC qG qBf dqC qBf qG];

sound(tune, 1/deltat)

% X(2t)
% half beatlength and double frequency
qG = sin(2*pi*2*fG*Qnote);
hG = sin(2*pi*2*fG*Hnote);
qBf = sin(2*pi*2*fBf*Qnote);
dqC = sin(2*pi*2*fC*DQnote);
hC = sin(2*pi*2*fC*Hnote);
eDf = sin(2*pi*2*fDf*Enote);

tune = [qG qBf dqC qG qBf eDf hC qG qBf dqC qBf qG];
sound(tune, 1/deltat)

File:Https://www.projectrhea.org/rhea/index.php/Image:Smoke on the water.wav

Alumni Liaison

To all math majors: "Mathematics is a wonderfully rich subject."

Dr. Paul Garrett