%Charles W. Peak %ECE 301 %Homework 1 %Prof. Mimi Boutin

%Play the following using Matlab %Part 1 %1.The main melody of the song "Smoke On The Water" by Deep Purple. %You have to play the melody at its original tempo (112 beats per minute).

%2.The tune of a) played 2 times faster.

%3.Take the signal x(t) corresponding to the tune of a) and rescale it according to the transformation y(t) = x(2t).

%Part 2 %1.What is the forward repeated phrase. %2.Write a Matlab routine to extract the subliminal message by playing the extract backwards.

%Part 1 %G Bf C G Bf Df C G Bf C Bf G %Q Q DQ Q Q E H Q Q DQ Q Q %Tempo 110 BPM %f = 2 ^ (n / 12) * Fa

clc; clear; delta = 0.0005; for part = 1:3 %loop to determine if the song is to be played at regular speed, twice as fast of rescaled.

if part == 2

   tempo = 224; % for a song twice as fast the tempo must be doubled.

else

   tempo = 112;  % the normal tempo for "Smoke on the Water"

end

%calculation of note lengths in seconds Q = 0:delta: (1 * 60/tempo); E = 0:delta: (0.5 * 60/tempo); H = 0:delta: (2 * 60/tempo); DQ = 0:delta: (1.5 * 60/tempo);

%Frequencies of pitches used in Smoke On The Water if part == 3

   fa = 880; %Rescaling the pitch of A4 for part 3 to be y(t) = x(2t)

else

   fa = 440; %Pitch for A440

end

%Frequencies of remaining dependent pitches. These pitches are dependent %on the frequency of A4 fG = 2 ^ (-2/12) * fa; fBf = 2 ^ (1/12) * fa; fC = 2 ^ (3/12) * fa; fDf = 2 ^ (4/12) * fa;

%Calculation of Actual note lengths based on the formula presented. GQ = sin(2 * pi * fG * Q); BfQ = sin(2 * pi * fBf * Q); CH = sin(2 * pi * fC * H); CDQ = sin(2 * pi * fC * DQ); DfE = sin(2 * pi * fDf * E);

%To play the song smoke_on_the_water = [GQ, BfQ, CDQ, GQ, BfQ, DfE, CH, GQ, BfQ CDQ, BfQ, GQ]; sound(smoke_on_the_water, 1/delta);

%Write the song if part == 1

   wavwrite(smoke_on_the_water,1/delta,32,'Normal_Speed') 

elseif part == 2

   wavwrite(smoke_on_the_water,1/delta,32,'Double_Speed')

else

   wavwrite(smoke_on_the_water,1/delta,32,'Rescale')

end

end

%Part 2

clear clc %Read the Beatles song and stores it in an array for Matlab to use [song,Fs] = wavread('Beatles.wav'); %Flipud reverses the song and stores it again as an array Reversed_song = flipud(song); %Playing of the reversed Beatles song sound(Reversed_song,Fs);

%When the song is played forward, it say "number nine"

%The reversed message is difficult to interpret though resembles "Turn me %on dead man"

Alumni Liaison

Questions/answers with a recent ECE grad

Ryne Rayburn