(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
% Question 1
+
% Question 1:
function[] = question1()
+
function[] = question1()
N1 = sin(2*pi*391.995436*[0:0.0001:1]);        %G quarter note
+
N1 = sin(2*pi*391.995436*[0:0.0001:1]);        %G quarter note
N2 = sin(2*pi*466.1637615*[0:0.0001:1]);        %Bflat quarter
+
N2 = sin(2*pi*466.1637615*[0:0.0001:1]);        %Bflat quarter
N3 = sin(2*pi*523.2511306*[0:0.0001:1.5]);      %C dotted quarter
+
N3 = sin(2*pi*523.2511306*[0:0.0001:1.5]);      %C dotted quarter
N4 = sin(2*pi*391.995436*[0:0.0001:1]);        %G quarter
+
N4 = sin(2*pi*391.995436*[0:0.0001:1]);        %G quarter
N5 = sin(2*pi*466.1637615*[0:0.0001:1]);        %Bflat quarter
+
N5 = sin(2*pi*466.1637615*[0:0.0001:1]);        %Bflat quarter
N6 = sin(2*pi*554.3652618*[0:0.0001:0.5]);      %Csharp eigth
+
N6 = sin(2*pi*554.3652618*[0:0.0001:0.5]);      %Csharp eigth
N7 = sin(2*pi*523.2511306*[0:0.0001:2]);        %C half
+
N7 = sin(2*pi*523.2511306*[0:0.0001:2]);        %C half
  
rest = [0:0.0001:2.5];                        %rest half and an eigth
+
rest = [0:0.0001:2.5];                        %rest half and an eigth
  
%smoke on the water (part a):
+
% smoke on the water (part a):
tune = [N1 N2 N3 N4 N5 N6 N7 N1 N2 N3 N2 N1 rest];
+
tune = [N1 N2 N3 N4 N5 N6 N7 N1 N2 N3 N2 N1 rest];
 +
wavwrite(0.02*tune, 18667, 'question1a.wav');
 +
 +
% twice as fast (part b):
 +
wavwrite(0.02*tune, 37333, 'question1b.wav');
  
newtune = [1:1:(length(tune)/2)];
+
% y(t) = x(2t)  (part c):
% newtune(t) = tune(2t)
+
newtune = [1:1:(length(tune)/2)];
for i=1:(length(tune)/2)
+
for i=1:(length(tune)/2)
    newtune(1,i) = tune(1,2*i);
+
    newtune(1,i) = tune(1,2*i);
end
+
end
 +
wavwrite(0.02*newtune, 18667, 'question1c.wav');
 +
  
%all three parts:
 
alltunes = [tune newtune newtune];
 
  
 +
Sound files:  [[Media:question1a.wav]]
 +
              [[Media:question1b.wav]]
 +
              [[Media:question1c.wav]]
  
wavwrite(0.02*alltunes, 18667, 'question1.wav');
+
  
  
1. Repeated phrase "number nine".
+
 
2. I don't hear anything in the reversed message.
+
% Question 2:
 +
function[] = question2()
 +
[y, Fs] = wavread('Beatles.wav');
 +
y = flipud(y);
 +
wavwrite(y, Fs, 'question2.wav');
 +
 
 +
 
 +
 
 +
Sound file:  [[Media:question2.wav]]
 +
 
 +
1. The repeated phrase was "number nine".
 +
2. I couldn't hear any message in the reversed version.

Latest revision as of 20:18, 14 January 2011

% Question 1:
function[] = question1()
N1 = sin(2*pi*391.995436*[0:0.0001:1]);         %G quarter note
N2 = sin(2*pi*466.1637615*[0:0.0001:1]);        %Bflat quarter
N3 = sin(2*pi*523.2511306*[0:0.0001:1.5]);      %C dotted quarter
N4 = sin(2*pi*391.995436*[0:0.0001:1]);         %G quarter
N5 = sin(2*pi*466.1637615*[0:0.0001:1]);        %Bflat quarter
N6 = sin(2*pi*554.3652618*[0:0.0001:0.5]);      %Csharp eigth
N7 = sin(2*pi*523.2511306*[0:0.0001:2]);        %C half
rest = [0:0.0001:2.5];                         %rest half and an eigth
% smoke on the water (part a):
tune = [N1 N2 N3 N4 N5 N6 N7 N1 N2 N3 N2 N1 rest];
wavwrite(0.02*tune, 18667, 'question1a.wav'); 

% twice as fast (part b):
wavwrite(0.02*tune, 37333, 'question1b.wav');
% y(t) = x(2t)  (part c):
newtune = [1:1:(length(tune)/2)];
for i=1:(length(tune)/2)
    newtune(1,i) = tune(1,2*i);
end
wavwrite(0.02*newtune, 18667, 'question1c.wav');


Sound files:  Media:question1a.wav
              Media:question1b.wav
              Media:question1c.wav



% Question 2:
function[] = question2()
[y, Fs] = wavread('Beatles.wav');
y = flipud(y);
wavwrite(y, Fs, 'question2.wav');


Sound file:  Media:question2.wav
1. The repeated phrase was "number nine".
2. I couldn't hear any message in the reversed version.

Alumni Liaison

Have a piece of advice for Purdue students? Share it through Rhea!

Alumni Liaison