(One intermediate revision by the same user not shown) | |||
Line 62: | Line 62: | ||
[Beatles, f] = wavread('Beatles.wav'); %Set the variable Beatles to the song | [Beatles, f] = wavread('Beatles.wav'); %Set the variable Beatles to the song | ||
+ | |||
Rev = flipud(Beatles); % Set the variable Rev to the reverse of Beatles | Rev = flipud(Beatles); % Set the variable Rev to the reverse of Beatles | ||
wavwrite(Rev, f, 'Reversed'); % Outputs the wav file | wavwrite(Rev, f, 'Reversed'); % Outputs the wav file | ||
+ | |||
+ | Sorry I don't know how to upload the files. I should have done it ahead of time. I hope you can understand. Please let me know if I can do it sometime later. |
Latest revision as of 12:49, 19 January 2011
% Name: Allan Diaz % Date: 01/19/2010 % ECE 301 Homework #1
% Part One: Playing Music
Fa = 440; % Frequency of the A4 Note
tempo = 60/112; % Original Tempo 112 BPM
tstep = 0.00005; % Step size for time
H = 0:tstep:tempo*2; %Length of a half note Q = 0:tstep:tempo; %Length of a quarter note E = 0:tstep:tempo/2; %Length of a eight note DQ = 0:tstep:tempo*3/2; %Length of a dotted quarter note S = 0:tstep:tempo*5/2; %Length of silence
% Smoke on the Water
QG = sin(2*pi*2^(-2/12)*Fa*Q); % G note (Quarter QBf = sin(2*pi*2^(1/12)*Fa*Q); % B-Flat note (Quarter) DQC = sin(2*pi*2^(3/12)*Fa*DQ); % C note (Dotted Quarter) EDf = sin(2*pi*2^(4/12)*Fa*E); % D-Flat note (Eight) HC = sin(2*pi*2^(3/12)*Fa*H); % C note (Half) Si = sin(S); % Silence
Smoker = [QG, QBf, DQC, QG, QBf, EDf, HC, QG, QBf, DQC, QBf, QG, Si];
sound(Smoker, 1/tstep); wavwrite(Smoker,1/tstep,32, 'Smoker')
% Smoke on the water tuned twice as fast
2QG = sin(2*pi*2^(-2/12)*Fa*Q/2); % G note (Quarter 2QBf = sin(2*pi*2^(1/12)*Fa*Q/2); % B-Flat note (Quarter) 2DQC = sin(2*pi*2^(3/12)*Fa*DQ/2); % C note (Dotted Quarter) 2EDf = sin(2*pi*2^(4/12)*Fa*E/2); % D-Flat note (Eight) 2HC = sin(2*pi*2^(3/12)*Fa*H/2); % C note (Half) 2Si = sin(S/2) % Silence
Smokef = [2QG, 2QBf, 2DQC, 2QG, 2QBf, 2EDf, 2HC, 2QG, 2QBf, 2DQC, 2QBf, 2QG, 2Si];
sound(Smokef, 1/tstep); wavwrite(Smokef,1/tstep,32, 'Smokef')
% Smoke on the water. Part c
cQG = sin(4*pi*2^(-2/12)*Fa*Q); % G note (Quarter cQBf = sin(4*pi*2^(1/12)*Fa*Q); % B-Flat note (Quarter) cDQC = sin(4*pi*2^(3/12)*Fa*DQ); % C note (Dotted Quarter) cEDf = sin(4*pi*2^(4/12)*Fa*E); % D-Flat note (Eight) cHC = sin(4*pi*2^(3/12)*Fa*H); % C note (Half) cSi = sin(4*S) % Silence
Smokec = [cQG, cQBf, cDQC, cQG, cQBf, cEDf, cHC, cQG, cQBf, cDQC, cQBf, cQG, cSi];
sound(Smokec, 1/tstep); wavwrite(Smokec,1/tstep,32, 'Smokec')
% Part Two: Reverse Playback
[Beatles, f] = wavread('Beatles.wav'); %Set the variable Beatles to the song
Rev = flipud(Beatles); % Set the variable Rev to the reverse of Beatles
wavwrite(Rev, f, 'Reversed'); % Outputs the wav file
Sorry I don't know how to upload the files. I should have done it ahead of time. I hope you can understand. Please let me know if I can do it sometime later.