Must be done using MATLAB. The audio needs to be recorded first and then passed
ID: 2083442 • Letter: M
Question
Must be done using MATLAB. The audio needs to be recorded first and then passed through the code to analyze it. We were told that the audio must be split into sections based on whether the microphone is getting above a certain level of volume. Must be done using MATLAB
EE3303-002: Linear System Analysis Spring 2017 Matlab Project Write a Matlab script that 1) Uses your computer's audio device to record a multiple DTMF tones as generated by a cell phone or an app. 2) Decodes and displays the numbers associated with the recorded tone This is a group project, with each group consisting of two students. Demonstrate the project to the instructor before 4:00 PM on Tuesday, May 9th. Upload your code (one per group to Blackboard before 4:00 PM on 05/09/2017.Explanation / Answer
The code is explained in comments
CODE
clc
clear all
close all
%%
% Read the wav file
[y,Fs,bits] = wavread('123456789ABCD');
% find the number of samples
Nsamps = length(y);
% find total time
t = (1/Fs)*(1:Nsamps); %Prepare time data for plot
%Do Fourier Transform
y_fft = abs(fft(y)); %Retain Magnitude
%Prepare freq data for plot
f = Fs*(0:Nsamps-1)/Nsamps;
%Plot Sound File in Time Domain
figure(1)
plot(t, y)
xlabel('Time (s)')
ylabel('Amplitude')
title('PhoneNumberA frequency in Time Domain')
%Plot Sound File in Frequency Domain
figure(2)
plot(f, y_fft)
axis([0,1800 0 600])
xlabel('Frequency (Hz)')
ylabel('Amplitude')
title('PhoneNumberA frequency in Frequency domain')
%% Splitting data
% Each point is of 0.1 ms with a pause of 0.1 ms
n=floor(Nsamps/16);
f1 = Fs*(0:n-1)/n;
% splitting data for each tone
for i = 1:16
A(:,i) = y(1+(i-1)*n:n*i);
end
fft_A = fft(A);
% dumping half data points so as not to get image freq.
fft_A = fft_A(1:n/2,:);
% Sorting fft matrix to get the indices of highest and second highest freq
% This will help us find the highest and second highest freq
[val ind] = sort(fft_A);
% Highest index vector
max_ind = ind(end,:);
%Second highest index matrix
max1_ind = ind(end-1,:);
% highest freq
freq1 = f1(1,max_ind);
% Second highest freq
freq2 = f1(1,max1_ind);
% Sortinf highest and second highest freq
freq = [freq1 ; freq2]
freq = sort(freq);
% Finding corresponding tone
% here we have used freq more than the actual as to leave no room for error
for i = 1:16
j = freq(1,i);
k = freq(2,i);
if j<=732.59 & k<=1270.91;
disp('---> Key Pressed is 1');
elseif j<=732.59 & k<=1404.73;
disp('---> Key Pressed is 2');
elseif j<=732.59 & k<=1553.04;
disp('---> Key Pressed is 3');
elseif j<=732.59 & k>1553.05;
disp('---> Key Pressed is A');
elseif j<=809.96 & k<=1270.91;
disp('---> Key Pressed is 4');
elseif j<=809.96 & k<=1404.73;
disp('---> Key Pressed is 5');
elseif j<=809.96 & k<=1553.04;
disp('---> Key Pressed is 6');
elseif j<=809.96 & k>1553.05;
disp('---> Key Pressed is B');
elseif j<=895.39 & k<=1270.91;
disp('---> Key Pressed is 7');
elseif j<=895.39 & k<=1404.73;
disp('---> Key Pressed is 8');
elseif j<=895.39 & k<=1553.04;
disp('---> Key Pressed is 9');
elseif j<=895.39 & k>1553.05;
disp('---> Key Pressed is C');
elseif j>895.40 & k<=1270.91;
disp('---> Key Pressed is *');
elseif j>895.40 & k<=1404.73;
disp('---> Key Pressed is 0');
elseif j>895.40 & k<=1553.04;
disp('---> Key Pressed is #');
elseif j>895.40 & k>1553.05;
disp('---> Key Pressed is D');
end
end
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.