Documente Academic
Documente Profesional
Documente Cultură
Part 1
2. The sound file tones2015.wav sounds like a high frequency sinusoid, with little
oscillation occurring in the waves amplitude; a singular tone. The resolution at
which a person can hear differences in waveforms is quite limited, so very few
reliable distinctions can be made using auditory senses alone.
3. The Matlab code used for this question was identical to that provided in the
laboratory documentation; the following graph was generated:
Furthermore, using rough extrapolations from the graph, the first sinusoid has a
frequency of (1 wavelength/0.58ms period)*1000 = 1720 Hz, the second sinusoid
was approximately twice this frequency value (3340 Hz), and the third sinusoid has
a frequency of roughly twice the second sinusoid (6880 Hz). The approximations for
the second and third sinusoidal frequencies were derived by gauging by the slope
changes between peaks, and concluding that the large upward rising slope was
approximately the same magnitude coming down from the highest peaks, but was
0.25 times in magnitude ascending the secondary peaks, and 0.5 times in
magnitude descending the secondary peaks.
These conclusions were found to be correct (albeit the frequencies were slightly
skewed due to visual estimations) in question 7, where the data used from the DFT
was used to generate the following graph, further exemplifying the accuracy of the
estimated values:
s1 = 0.4*sin(2*pi*2000*t);
s2 = 0.2*sin(2*pi*4000*t);
s3 = 0.2*sin(2*pi*6000*t);
% Plot the signal for t_plot msec
t_plot = 5;
msec_per_sec = 1000;
numSamples = t_plot*Fs/msec_per_sec;
plot(msec_per_sec*t(1:numSamples),
newSignal(1:numSamples), ...
msec_per_sec*t(1:numSamples), s1(1:numSamples), ...
msec_per_sec*t(1:numSamples), s2(1:numSamples), ...
msec_per_sec*t(1:numSamples), s3(1:numSamples))
5. Using the given Matlab code from the laboratory instructions, the following graph
was generated:
the given original waveform. Further analysis was performed using the following
Matlab code to identify the sinusoidal frequencies in the summated sine wave.
% The following four lines were simply left in the code to duplicate the
parameters for reconstructing a 5ms waveform; L, T, and t were the same values
needed for our new 5ms sine wave summation.
[signal, Fs, bits_per_sample] = wavread('tones2015.wav');
L = length(signal);
T = 1/Fs;
t = [0:L-1]*T;
%the following code was used to
%generate the given sinusoid using a summation of three distinct sine
%waves.
newSignal = 0.4*sin(2*pi*2000*t) + 0.2*sin(2*pi*4000*t) +
0.2*sin(2*pi*6000*t);
% Plot the signal for t_plot msec
t_plot = 5;
msec_per_sec = 1000;
numSamples = t_plot*Fs/msec_per_sec;
plot(msec_per_sec*t(1:numSamples), newSignal(1:numSamples))
title('Giuseppe Querques, 0749012 - Q6. Plot of New Signal')
xlabel('time (milliseconds)')
grid('minor');
Part 2
2. The given wave file has two segments of noise: High frequency static (ie.
Extraneous noise), and more distinct a medium-to-high frequency tone which varies
in pitch and volume at regular intervals. It is assumed that this second segment of
the wave file contains the information to be decoded.
3. The first step was to generate a DFT plot of the given wave file to find the
frequencies present. The following Matlab code (as derived from part one of the
laboratory report instructions) was used to do so:
[signal, Fs, bits_per_sample] = wavread('SecretMessage2015.wav');
L = length(signal);
T = 1/Fs;
t = [0:L-1]*T;
% Take the DFT
Y = fft(signal)/L;
f = Fs/2*linspace(0,1,L/2+1);
% Plot the single-sided magnitude spectrum.
plot(f,2*abs(Y(1:L/2+1)));
title('Giuseppe Querques, 0749012 - Part 2, Q3. Single-Sided Magnitude
Spectrum')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')
axis([0 Fs/2 0 .05]); %axis range limited from 0 to 0.05 for better magnitude
resolution
grid('minor');
4. After performing the decoding process as detailed on the next several pages, the
secret code was found to be: BETTER TO LIGHT A SINGLE CANDLE THAN TO CURSE
THE DARKNESS.
The following Matlab code was used to split the original wave file signal into one
second blocks to be processed, reorganized, and decoded:
clc;
[signal, Fs, bits_per_sample] = wavread('SecretMessage2015.wav');
L = length(signal);
T = 1/Fs;
t = [0:L-1]*T;
freq = [0:8000]';
%this loop splits up the 59 second wave file into 59 one second segments.
%each segment is fft analyzed and sorted by peak magnitude,
%where the index of each value sorted is stored in parallel to a
%frequency storage vector. The top four magnitude peaks have
%their corresponding frequencies stored in letter identification
%vector, letterStorage.
for j=1:59
Y = fft(signal(1+(j-1)*16000:j*16000))/16000;
fftData = [2*abs(Y(1:16000/2+1))];
[fftPeaks, frequency] = sort(fftData,'descend');
letterStorage(j,1)
letterStorage(j,2)
letterStorage(j,3)
letterStorage(j,4)
end
=
=
=
=
frequency(1)-1;
frequency(2)-1;
frequency(3)-1;
frequency(4)-1;
end
if sortedLetters(j,1) == 1000 && sortedLetters(j,2) == 2000 ...
&& sortedLetters(j,3) == 3000 && sortedLetters(j,4) == 7000;
secretMessage(j) = 'D';
end
if sortedLetters(j,1) == 1000 && sortedLetters(j,2) == 2000 ...
&& sortedLetters(j,3) == 4000 && sortedLetters(j,4) == 5000;
secretMessage(j) = 'E';
end
if sortedLetters(j,1) == 1000 && sortedLetters(j,2) == 2000 ...
&& sortedLetters(j,3) == 4000 && sortedLetters(j,4) == 6000;
secretMessage(j) = 'F';
end
if sortedLetters(j,1) == 1000 && sortedLetters(j,2) == 2000 ...
&& sortedLetters(j,3) == 4000 && sortedLetters(j,4) == 7000;
secretMessage(j) = 'G';
end
if sortedLetters(j,1) == 1000 && sortedLetters(j,2) == 2000 ...
&& sortedLetters(j,3) == 5000 && sortedLetters(j,4) == 6000;
secretMessage(j) = 'H';
end
if sortedLetters(j,1) == 1000 && sortedLetters(j,2) == 2000 ...
&& sortedLetters(j,3) == 5000 && sortedLetters(j,4) == 7000;
secretMessage(j) = 'I';
end
if sortedLetters(j,1) == 1000 && sortedLetters(j,2) == 2000 ...
&& sortedLetters(j,3) == 6000 && sortedLetters(j,4) == 7000;
secretMessage(j) = 'J';
end
if sortedLetters(j,1) == 1000 && sortedLetters(j,2) == 3000 ...
&& sortedLetters(j,3) == 4000 && sortedLetters(j,4) == 5000;
secretMessage(j) = 'K';
end
if sortedLetters(j,1) == 1000 && sortedLetters(j,2) == 3000 ...
&& sortedLetters(j,3) == 4000 && sortedLetters(j,4) == 6000;
secretMessage(j) = 'L';
end
if sortedLetters(j,1) == 1000 && sortedLetters(j,2) == 3000 ...
&& sortedLetters(j,3) == 4000 && sortedLetters(j,4) == 7000;
secretMessage(j) = 'M';
end
if sortedLetters(j,1) == 1000 && sortedLetters(j,2) == 3000 ...
&& sortedLetters(j,3) == 5000 && sortedLetters(j,4) == 6000;
secretMessage(j) = 'N';
end
if sortedLetters(j,1) == 1000 && sortedLetters(j,2) == 3000 ...
&& sortedLetters(j,3) == 5000 && sortedLetters(j,4) == 7000;
secretMessage(j) = 'O';
end
if sortedLetters(j,1) == 1000 && sortedLetters(j,2) == 3000 ...
&& sortedLetters(j,3) == 6000 && sortedLetters(j,4) == 7000;
secretMessage(j) = 'P';
end
if sortedLetters(j,1) == 1000 && sortedLetters(j,2) == 4000 ...
&& sortedLetters(j,3) == 5000 && sortedLetters(j,4) == 6000;
secretMessage(j) = 'Q';
end
if sortedLetters(j,1) == 1000 && sortedLetters(j,2) == 4000 ...
&& sortedLetters(j,3) == 5000 && sortedLetters(j,4) == 7000;
secretMessage(j) = 'R';
end
if sortedLetters(j,1) == 1000 && sortedLetters(j,2) == 4000 ...
&& sortedLetters(j,3) == 6000 && sortedLetters(j,4) == 7000;
secretMessage(j) = 'S';
end
if sortedLetters(j,1) == 1000 && sortedLetters(j,2) == 5000 ...
&& sortedLetters(j,3) == 6000 && sortedLetters(j,4) == 7000;
secretMessage(j) = 'T';
end
if sortedLetters(j,1) == 2000 && sortedLetters(j,2) == 3000 ...
&& sortedLetters(j,3) == 4000 && sortedLetters(j,4) == 5000;
secretMessage(j) = 'U';
end
if sortedLetters(j,1) == 2000 && sortedLetters(j,2) == 3000 ...
&& sortedLetters(j,3) == 4000 && sortedLetters(j,4) == 6000;
secretMessage(j) = 'V';
end
if sortedLetters(j,1) == 2000 && sortedLetters(j,2) == 3000 ...
&& sortedLetters(j,3) == 4000 && sortedLetters(j,4) == 7000;
secretMessage(j) = 'W';
end
if sortedLetters(j,1) == 2000 && sortedLetters(j,2) == 3000 ...
&& sortedLetters(j,3) == 5000 && sortedLetters(j,4) == 6000;
secretMessage(j) = 'X';
end
if sortedLetters(j,1) == 2000 && sortedLetters(j,2) == 3000 ...
&& sortedLetters(j,3) == 5000 && sortedLetters(j,4) == 7000;
secretMessage(j) = 'Y';
end
if sortedLetters(j,1) == 2000 && sortedLetters(j,2) == 3000 ...
&& sortedLetters(j,3) == 6000 && sortedLetters(j,4) == 6000;
secretMessage(j) = 'Z';
end
if sortedLetters(j,1) == 2000 && sortedLetters(j,2) == 4000 ...
&& sortedLetters(j,3) == 5000 && sortedLetters(j,4) == 6000;
secretMessage(j) = ' ';
end
if sortedLetters(j,1) == 2000 && sortedLetters(j,2) == 4000 ...
&& sortedLetters(j,3) == 5000 && sortedLetters(j,4) == 7000;
secretMessage(j) = '.';
end
end